Skip to the content.

Merge Video and Audio with FFmpeg

FFmpeg is a powerful tool for manipulating multimedia files. Here are some useful commands for merging video and audio files.

Replace Audio in a Video with MP3

To replace the audio in a video file with an MP3 file:

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

Explanation

Mix Audio with Existing Video Audio

To mix the new audio with the existing audio in the video:

ffmpeg -i video.mp4 -i audio.mp3 -filter_complex "[0:a][1:a]amix=inputs=2:duration=shortest" -map 0:v -c:v copy -c:a aac -shortest output.mp4

Explanation

Notes