[FFmpeg-user] Adding Audio to a video without re-encoding?

Werner Robitza werner.robitza at gmail.com
Sun Jan 25 10:30:37 CET 2015

On Sun, Jan 25, 2015 at 7:15 AM, <Meino.Cramer at gmx.de> wrote:
> I have an video file (h264), which is without audio. I want to add
> music to it and have an audio file of the correct length.
> Is it possible to add that audio file to the video file without
> re-encoding one or both files?
> And if yes, how can I accieve this?

ffmpeg -i video.mp4 -i audio.m4a -c copy -map 0:v -map 1:a output.mp4

assuming the audio codec is compatible with MP4 (i.e. AAC, MP3).
Or use Matroska, since it more or less handles all codecs:

ffmpeg -i video.mp4 -i audio.ogg -c copy -map 0:v -map 1:a output.mkv

Here, "0:v" refers to the video stream of the first input, and "1:a"
to the audio stream of the second input. "-c copy" copies the
bitstreams instead of re-encoding.

See also:

More information about the ffmpeg-user mailing list