A video file can hold several audio tracks, such as Japanese and English audio or a commentary track, and viewers choose one in their player. With FFmpeg you can add, extract and remove these tracks, tag each one with a language code such as jpn or eng, and choose which track plays by default.
Why You Need Multiple Audio Tracks
Common uses:
- Several languages (for example Japanese and English dubs)
- Audio commentary (a second audio track on a film)
- The same audio in two formats (for example AAC and Dolby AC-3)
- Stereo and 5.1ch surround in one file
Inspect Stream Information
First, check how many audio tracks the file has:
ffprobe -v quiet -show_streams -select_streams a input.mkv
Combine Two Audio Files into One Video
ffmpeg -i video.mp4 -i audio_ja.aac -i audio_en.aac \
-map 0:v:0 \
-map 1:a:0 \
-map 2:a:0 \
-c:v copy -c:a copy \
output_bilingual.mkv
0:v:0— the video stream of input 0 (video.mp4)1:a:0— the audio stream of input 1 (audio_ja.aac)2:a:0— the audio stream of input 2 (audio_en.aac)
Set Language Metadata
ffmpeg -i video.mp4 -i audio_ja.aac -i audio_en.aac \
-map 0:v:0 \
-map 1:a:0 \
-map 2:a:0 \
-c copy \
-metadata:s:a:0 language=jpn \
-metadata:s:a:1 language=eng \
output.mkv
-metadata:s:a:0 sets metadata on the first audio stream (audio streams are counted from 0). For the language, use three-letter ISO 639-2 codes: jpn, eng, fra, deu and so on.
Set the Default Audio Track
ffmpeg -i input.mkv \
-map 0 \
-c copy \
-disposition:a:0 default \
-disposition:a:1 0 \
output.mkv
-map 0— keep every stream. Without it, only one audio track is written and the other is dropped without any warning-disposition:a:0 default— make the first audio track (a:0) the default-disposition:a:1 0— clear the default flag on the second audio track (a:1)
Add an Audio Track to an Existing Video
ffmpeg -i existing.mp4 -i new_audio.aac \
-map 0 \
-map 1:a \
-c copy \
output_added.mkv
-map 0 keeps all streams of the existing file, and -map 1:a adds the new audio.
Extract Only a Specific Audio Track
ffmpeg -i input.mkv -map 0:a:1 -c:a copy audio_track2.mka
This copies out the second audio track (index 1, counting from zero) without re-encoding. A .mka (Matroska audio) file takes AAC, AC-3 or any other codec as it is. An .aac file works only when the track is AAC; with an AC-3 track, FFmpeg stops with adts muxer supports only codec aac.
Remove a Specific Audio Track
A -map with a minus sign removes a stream from the selection:
ffmpeg -i input.mkv -map 0 -map -0:a:1 -c copy output.mkv
-map 0 selects all streams, and -map -0:a:1 then removes the second audio track.
Convert the Codec of an Audio Track
This encodes the first audio track to AAC and copies the second one unchanged:
ffmpeg -i input.mkv \
-map 0:v -map 0:a:0 -map 0:a:1 \
-c:v copy \
-c:a:0 aac -b:a:0 192k \
-c:a:1 copy \
output.mkv
-c:a:0 and -c:a:1 set the codec for each audio stream separately.
Caveats with MP4
MP4 handles several language tracks less well than MKV:
| Feature | MKV | MP4 |
|---|---|---|
| Multiple audio tracks | ◯ Supported | ◯ Supported (check that your players handle it) |
| Language tags | ◯ | ◯ |
| Text-based subtitles | ◯ (ASS/SRT) | △ (mov_text format) |
| Unlimited track count | ◯ | △ (player-dependent) |
To archive files with several audio tracks, use MKV.
Common Problems
The File Became Too Large After Adding an Audio Track
Without -c copy, the video is re-encoded too, and the size changes. With -c copy, the file grows only by the size of the added audio (bitrate × duration). Uncompressed audio such as WAV is added as it is and takes a lot of space, so convert it to AAC or similar first.
The Player Doesn’t Recognize a Specific Audio Track
Keep every track with -map 0 and make the first one the default with -disposition:a:0 default, or check the audio track setting in the player.
List Audio Track Information
ffprobe -v quiet -select_streams a \
-show_entries stream=index,codec_name,channels:stream_tags=language \
-of csv input.mkv
Related Articles
FAQ
How do I keep a video that has multiple audio tracks?
Use -map 0 to keep the video and all audio streams (-map 0:a alone drops the video). Add -c copy to skip re-encoding, which is faster and loses no quality.
I want to switch between Japanese and English audio
Tag each audio track with its language, for example -metadata:s:a:0 language=jpn. Players such as VLC, mpv and Plex let you switch audio tracks from a menu even without tags. With tags, they know which track is in which language and can pick the viewer’s preferred one automatically.
Can I use multiple audio tracks in MP4?
Yes. However, some players cannot switch audio tracks, so test on the players your viewers use.
I want to specify which audio plays by default
Use the disposition flags: -map 0 -disposition:a:0 default -disposition:a:1 0. The first audio track (a:0) becomes the default and the second (a:1) does not. Keep -map 0; without it, only one audio track is written.
I want to downmix 5.1ch to 2ch
-ac 2 downmixes to stereo automatically. For finer control, use -af "pan=stereo|FL=...|FR=...".