How to add multiple audio tracks to a single video using FFMpeg Open-source Tool?

Kavirajan ST
AV Transcode
Published in
3 min readDec 28, 2019

In this article, I’m going to help you learn how to add multiple audio tracks to a single video file using FFmpeg tool.

In this fast-paced world, we must agree the fact most of us spending money like buying a tool or software even for small things that we can do it by ourselves just by writing a one-line command.

Before digging deeper into the details, let’s just give a thought about why we should go for multiple audio tracks and how does this help?

Why go for multiple audio tracks?

Consider this, you have created a video and planning to run it for a presentation or upload it online for everyone to watch. Your audience might be from various demographics and you need to plan the audio tracks accordingly so that everyone would understand the video better.

Also let us say, in case your family/friends are comfortable or only understand their particular language, then we need to store individual video for every single audio file this will cost your storage size i.e language count * video storage (4 * 1.5GB = 6GB).

So Adding multiple audio tracks will help us to reduce storage size

About FFMPEG:

FFmpeg is a free and open-source project consisting of powerful audio and video converter software suite of libraries and programs for handling video, audio, and other multimedia files and streams.

Adding Multiple Audio tracks to single video using FFMPEG:

The below video tutorial explains in detail with step by step process of adding multiple audio tracks to a single video and this way you can add more audio files into a video file on your own.

For the testing purpose, here I’ve taken Captain Marvel video trailer with default English audio and 3 audio tracks namely Tamil, Telugu and Hindi.

The command for Multiple audio tracks:

The below command will convert single Video file captain-marvel-trailer.mp4 to multiple language audio tracks (English, Tamil, Telugu & Hindi) multilanguage.mp4 file.

FFmpeg expects the language can be specified as an ISO 639–2/T or ISO 639–2/B (3 letters) code. ISO 639 is a set of international standards that lists shortcodes for language names.

ffmpeg -i captain-marvel-trailer.mp4 -i tamil.mp3 -i telugu.mp3 -i hindi.mp3 -map 1 -map 2 -map 3 -metadata:s:a:0 language=eng -metadata:s:a:1 language=tam -metadata:s:a:2 language=tel -metadata:s:a:3 language=hin -codec copy multilanguage.mp4
  • Here -metadata:s:a:0 language=eng — indicating the English language for the first audio track.
  • In the same way, you can add metadata for all three languages namely Tamil, Telugu, and Hindi.
  • This command will support all types of video formats like MP4, MKV, AVI, etc.

The above image shows the preview screenshot of the video with multiple audio tracks for a single video.

Comment your queries below. Happy Encoding. Save storage :)

--

--

Kavirajan ST
AV Transcode

CEO at Innocrux, Making OTT Simple to Monetize your Content. Passionate about OTT, Live, VOD, WebRTC, and Video Encoding. Learn more at https://www.innocrux.com