Keep input codecs

1

I have an MKV file with H.264 video and AAC audio. With FFmpeg the default audio codec for MKV is AC3, so if you run a command such as

ffmpeg -i infile.mkv -ac 2 outfile.mkv

it will transcode the audio to AC3. I can run this command and all is well

ffmpeg -i infile.mkv -ac 2 -c:a libfdk_aac outfile.mkv

However is a way available to say "use the input codec"? Note that copy will not work because I am making a change to the audio stream.

Steven Penny

Posted 2014-03-04T17:47:17.247

Reputation: 7 294

Answers

2

There is no such option as far as I know. You will have to be explicit, rely on the defaults, or perform additional scripting.

If you believe this should be implemented as a feature you can create a feature request on the FFmpeg Bug Tracker (search first to see if one already exists).

Note that the default encoder for your output container format can change depending on your supported external encoding libraries. For example, if your ffmpeg build supported libvorbis it would use that instead of ac3 for mkv outputs.

ffprobe may help:

$ ffprobe -v 0 -of flat=s=_ -select_streams a:0 -show_entries stream=codec_name input.mkv
streams_stream_0_codec_name="aac"

Of course this may be of limited usefulness since codec_name may not be the same name of the encoder you want.

llogan

Posted 2014-03-04T17:47:17.247

Reputation: 31 929