2
To automate scripts for manipulating video files, I would like to get a list of supported audio codecs - ideally with their encoder names - based on a video codec and container format (might also be known as muxer or demuxer), as supported by ffmpeg
.
Find out the video codec using:
ffprobe -v error -select_streams v:0 -show_entries stream=codec_name \
-of default=noprint_wrappers=1:nokey=1 video.mp4
which returns h264
. Find out the container format using:
ffprobe -v error -select_streams v:0 -show_format_entry format_name \
-of default=noprint_wrappers=1:nokey=1 video.mp4
Which returns mov,mp4,m4a,3gp,3g2,mj2
.
We assume the input video file has no audio stream, so we can't simply use:
ffprobe -v error -select_streams a:0 -show_entries \
stream=codec_name -of default=noprint_wrappers=1:nokey=1 video.mp4
which would otherwise return aac
.
The commands in https://stackoverflow.com/a/20587693/188159 might have the solution but I haven't been able to figure out how to filter them.
1Maybe I don't quite follow what you're trying to do, but
ffmpeg
will automatically choose an appropriate audio encoder based on the output format. You can view the default encoders, for your particularffmpeg
, withffmpeg -h muxer=mp4
. I'm not sure why you need a list of supported audio formats per output container format. Your "format" and "codec" commands are mislabeled by the way (swap them). – llogan – 2016-10-22T01:07:57.717