Merge audio and video files with FFmpeg

If the video has no audio:

ffmpeg -i video.mp4 -i audio.mp3 -c:v copy -c:a aac -strict experimental output.mp4

If the video already has audio:

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

When you start to manipulate stuff like this you should try to get a basic grasp of FFmpeg streams.

The example above is very basic so no need to dig deeper, but if you are editing a video with multiple audio tracks, for example, you should be a little careful.

Here is one example if you want to know more.

Leave a Reply

Your email address will not be published. Required fields are marked *