I would like to merge 2 videos : F1 + F2 = F3
F1.mp4
Stream #0:0\[0x1\](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, unknown/bt709/unknown, progressive), 1920x1080, 49 kb/s, 25 fps, 25 tbr, 12800 tbn (default)
Stream #0:1\[0x2\](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 2 kb/s (default)
F2.mkv
Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x1080 \[SAR 1:1 DAR 16:9\], 25 fps, 25 tbr, 1k tbn, start 0.003000 (default)
Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp, start -0.018000 (default)
Merge command
ffmpeg -i F1.mp4 -i F2.mkv -filter_complex "\[0:v\]\[0:a\]\[1:v\]\[1:a\]concat=n=2:v=1:a=1" -vsync vfr F3.mkv
F3.mkv
Stream #0:0: Video: h264 (High), yuv420p(tv, unknown/bt709/unknown, progressive), 1920x1080 \[SAR 1:1 DAR 16:9\], 25 fps, 25 tbr, 1k tbn, start 0.003000
Stream #0:1: Audio: vorbis, 48000 Hz, stereo, fltp
Why does the audio of the merged file is vorbis, despite the audio of the 2 input files is AAC?
I really need to get AAC audio for the merged file. Is the merge command incorrect?
1 Answer 1
Because (probably) vorbis is the default audio codec for mkv in ffmpeg.
To keep the audio in AAC, either specify -c:a copy to have the original audio stream simply concatenated (and remuxed) without re-encoding, or if re-encoding is necessary for the concatenation or so, -c:a aac. (Some ffmpeg builds might allow you to use libfdk_aac as well, or not.)
Note that -c:a in this case (i.e. for specifying the encoder to use) needs to be placed after all the -is. (Not sure if there is any subtle difference between placing it before and after the filter chain though.)
-
Thank you Tom. Adding the -c:a option works fine, except I had to remove the filter_complex option as I got an error message : Streamcopy requested for output stream fed from a complex filtergraph. Filtering and streamcopy cannot be used together.Mersing– Mersing2025年12月03日 18:12:02 +00:00Commented yesterday
-
@Mersing That's why I mentioned that you might need
-c:a aacinstead. (But I wonder if you should just use the concat demuxer approach instead, which may allow you to use-c:a copy: trac.ffmpeg.org/wiki/Concatenate#demuxer)Tom Yan– Tom Yan2025年12月03日 18:19:06 +00:00Commented yesterday
like this. I didn't know about this when I was new to the site, but it helps improve readability a lot.