Set Multi-Track MOV Metadata and Channel Layout in FFmpeg
This article provides a practical guide on how to configure track-level metadata and define specific channel layouts for multi-track MOV files using FFmpeg. You will learn the exact command-line syntax required to assign languages, track titles, and audio layouts (such as stereo or 5.1 surround sound) to individual audio streams within a QuickTime MOV container.
Understanding Stream Specifiers in FFmpeg
To target specific audio tracks in a multi-track file, FFmpeg uses
stream specifiers. The syntax -metadata:s:a:X allows you to
apply metadata to a specific stream, where: * s stands for
stream. * a stands for audio. * X is the
zero-based index of the audio stream (e.g., 0 for the first
audio track, 1 for the second).
Setting Track-Level Metadata (Language and Title)
You can set metadata tags such as language (using ISO
639-2 three-letter codes) and title for each individual
track.
The following command takes an input video with two audio tracks, maps them, and assigns unique titles and languages to each track:
ffmpeg -i input.mp4 \
-map 0:v \
-map 0:a:0 \
-map 0:a:1 \
-c:v copy \
-c:a copy \
-metadata:s:a:0 language=eng -metadata:s:a:0 title="English Stereo" \
-metadata:s:a:1 language=spa -metadata:s:a:1 title="Spanish Surround" \
output.movSetting Audio Channel Layouts
QuickTime MOV containers require explicit channel layouts for players
to decode the audio tracks correctly. You can set layouts like
stereo (2 channels) or 5.1 (6 channels) using
the -ch_layout option (or -channel_layout in
older FFmpeg versions).
To apply channel layouts to specific audio streams, append the stream specifier to the layout option:
ffmpeg -i input.wav \
-map 0:a \
-c:a pcm_s24le \
-ch_layout:a:0 stereo \
output.movCombining Metadata and Channel Layouts for Multi-Track MOV
For professional mastering, you often need to combine these commands. Below is a complete command that takes a video file and two separate stereo audio inputs, combines them into a single multi-track MOV file, transcodes the audio to PCM (commonly used in MOV), and applies custom channel layouts, languages, and titles to each track.
ffmpeg -i video_only.mp4 -i audio_en.wav -i audio_fr.wav \
-map 0:v \
-map 1:a \
-map 2:a \
-c:v copy \
-c:a pcm_s24le \
-ch_layout:a:0 stereo \
-metadata:s:a:0 language=eng \
-metadata:s:a:0 title="English Stereo" \
-ch_layout:a:1 stereo \
-metadata:s:a:1 language=fra \
-metadata:s:a:1 title="French Stereo" \
output.movVerifying the Output
To verify that your channel layouts and metadata were applied
correctly to the MOV container, use the ffprobe tool:
ffprobe -show_streams output.movLook for the channel_layout, TAG:language,
and TAG:title fields under each audio stream block in the
output to confirm the configuration.