FFmpeg DASH Multiple Audio Languages Guide
Configuring the FFmpeg DASH muxer to output multiple audio languages involves mapping several audio inputs, labeling each stream with its respective language metadata, and grouping them correctly using adaptation sets. This guide provides a straightforward, step-by-step approach and a practical command-line example to help you generate a Dynamic Adaptive Streaming over HTTP (DASH) presentation with multi-language audio support.
To output multiple audio languages using the FFmpeg DASH muxer, you
must map each audio track, assign the correct language metadata, and
configure the -adaptation_sets parameter.
Step 1: Map the Input Streams
First, import your video file and each languageās audio file. Use the
-map option to select which streams to include in the
output. For example, if you have one video file and two separate audio
files (English and Spanish):
-i video.mp4 -i audio_en.ac3 -i audio_es.ac3 -map 0:v -map 1:a -map 2:aStep 2: Set Language Metadata
To ensure media players recognize and display the correct language
options, you must assign ISO 639 language codes (such as
eng, spa, fra) to each audio
stream using the -metadata:s:a option:
-metadata:s:a:0 language=eng -metadata:s:a:1 language=spaHere, s:a:0 refers to the first mapped audio stream
(English), and s:a:1 refers to the second mapped audio
stream (Spanish).
Step 3: Configure Adaptation Sets
The -adaptation_sets option tells the DASH muxer how to
group the streams in the Media Presentation Description
(.mpd) manifest. For a multi-language setup, each audio
language must reside in its own adaptation set so players can toggle
between them.
Define this using stream descriptors:
-adaptation_sets "id=0,streams=v id=1,streams=1 id=2,streams=2"In this configuration: * id=0,streams=v groups all video
streams into Adaptation Set 0. * id=1,streams=1 places the
first audio stream (English, stream index 1) into Adaptation Set 1. *
id=2,streams=2 places the second audio stream (Spanish,
stream index 2) into Adaptation Set 2.
Full Command Example
Combining all these elements into a single command yields the following:
ffmpeg -i video.mp4 -i audio_en.mp3 -i audio_es.mp3 \
-map 0:v -map 1:a -map 2:a \
-c:v libx264 -c:a aac \
-metadata:s:a:0 language=eng -metadata:s:a:1 language=spa \
-f dash \
-adaptation_sets "id=0,streams=v id=1,streams=1 id=2,streams=2" \
output.mpdThis command encodes the inputs, tags the audio tracks with their
respective languages, structures them into distinct adaptation sets, and
outputs the final DASH manifest (output.mpd) along with the
media segments.