2

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?

Franck Dernoncourt
25k67 gold badges239 silver badges417 bronze badges
asked yesterday
New contributor
Mersing is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
2
  • Hi Mersing! Just so you know, you can use backticks around the command lines in your post to format them like this. I didn't know about this when I was new to the site, but it helps improve readability a lot. Commented yesterday
  • Two steps I would prefer. 1. ffmpeg -i ... -c:v copy -c:a aac -b:a 256k -ar 48000 ..., you must insert the given bitrate instead of the value 256k. 2. ffmpeg -i firstvideo -i sec_video -c:a copy -c:v copy outputvideo Commented yesterday

1 Answer 1

2

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.)

answered yesterday
2
  • 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. Commented yesterday
  • @Mersing That's why I mentioned that you might need -c:a aac instead. (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) Commented yesterday

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.