The correct FFmpeg command is:
ffmpeg -i video.mp4 -i audio.mp4 -map 0:0 -map 1:0 -c copy output.mp4
This will supply two input streams, the video you already have and the audio, e.g. from an MP4 file with AAC audio, and merge them together using the -map
options.
Here, the first number in 0:0
is the input file (0
for the video file and 1
for the audio file), and the second number is the stream from that file (0
since there's only one stream each, video or audio). The two streams will be mapped to the one output file, so first video, then audio.
The bitstreams will be copied and not re-encoded using the -c copy
option. You can observe this in the FFmpeg output:
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #1:0 -> #0:1 (copy)
Sweet! Especially nice that you explained the arguments and the usage of the mapping. – poplitea – 2012-11-30T17:20:01.513
4Also you may want
-shortest
if you want it only to be the duration of the shortest input (helpful if the audio is music that is longer than the video). – mark4o – 2012-11-30T17:34:17.103