imageio / imageio-ffmpeg

FFMPEG wrapper for Python
BSD 2-Clause "Simplified" License
221 stars 50 forks source link

Add support for encoding with audio from a path #51

Closed ksmoore17 closed 3 years ago

ksmoore17 commented 3 years ago

This adds support for encoding with an audio stream from a file path along with an option to provide an output audio codec.

Strings audio_path and audio_codec can be provided to the write_frames method.

It outputs a warning but successfully encodes the video when the stream provided as audio_path has no audio stream. It also adds an audio_codec key to the metadata when reading if an audio stream is present - with output gathered in a similar way to the video metadata.

Tried to keep it minimal; let me know if you want me to change anything.

50

almarklein commented 3 years ago

Late reply due to holidays & moving.

This looks really nice, thank! Just a few minor questions/comments.

ksmoore17 commented 3 years ago

Not a problem. That linked issue is funny because I decided to add to the metadata mostly because it was useful for testing. Would you like me to squash commits when I add -an and the documentation of default behavior?

almarklein commented 3 years ago

No need to squash. We can squash-merge.

ksmoore17 commented 3 years ago

Think the link I shared was only about video codecs. I believe the command line behavior for audio codecs is more like - if a format requires a less "standard" codec, you must specify one of these. That means either discovering each of cases and putting an if statement based on the format to set to one of its viable audio codecs, or letting ffmpeg give an error message.

almarklein commented 3 years ago

Looking good, is this ready from your end?

ksmoore17 commented 3 years ago

Yes

almarklein commented 3 years ago

Thanks!