How to add audio to a video with FFMpeg

FFMpeg is a great framework when it comes to processing multimedia files, especially for someone who has not budget to spend on commercial software. Been using this tool for some time now, I am really grateful to the developers who have contributed their energies in putting together a very useful computer software such as FFMpeg.

Although the FFMpeg multimedia framework is very rich in features and utilities, there is only one command which you need to learn for the purpose of this short blog post. Through this article, you will learn how to add audio to a video with the help of the ffmpeg tool which is found in the FFMpeg framework.

Before going any further, make sure to launch a new console on your own machine. Then prepare two multimedia files needed for the purpose of this tutorial: an audio file and a video file.

What's the one thing every developer wants? More screens! Enhance your coding experience with an external monitor to increase screen real estate.

Once you have managed to open a new console and prepared the files which we are going to use through this tutorial, make use of the following command to add a specific audio stream to your video file.

ffmpeg -i video_input.mp4 -i audio_input.mp3 -c copy -map 0:v -map 1:a output.mp4

The above ffmpeg command takes as input two files, a video and an audio one. Then it copies the video stream from the video file, the audio stream from the video file, and combines them both in output file named output.mp4.

Based on my research on the Internet, there are some people complaining about the above command. According to them it does not work. Probably because of the incompatible codecs.

I highly recommend that you make use of the following command, if the above one does not successfully work.

ffmpeg -i video_input.mp4 -i audio_input.mp3 -c copy -map 0:v -map 1:a output.mkv

Based on my personal experience, the ffmpeg command being shared above works most of the times. It makes use of the Matroska, which more or less handles all codecs.

Final thoughts

Through this article you learned how to make use of the ffmpeg tool found in the FFMpeg multimedia framework with the main purpose of adding audio to your video.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Leave a Reply

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