What Does the ffmpeg -map 1:a:0 Notation Mean?
In multimedia processing, managing multiple audio, video, and
subtitle streams can be challenging. This article provides a clear,
concise breakdown of the -map 1:a:0 notation in FFmpeg,
explaining how it selects specific audio streams from your input files
and how you can apply this syntax to control your media transcoding
workflows.
Breaking Down the Notation
The -map option in FFmpeg tells the tool which streams
from the input files should be included in the output file. The value
1:a:0 is a precise colon-separated identifier that targets
a single stream based on three parameters: Input File
Index, Stream Type, and Stream
Index.
Here is the exact breakdown of 1:a:0:
1(Input File Index): This refers to the second input file loaded in your command. FFmpeg uses zero-based indexing, meaning-i(the first input) is0, and the next-i(the second input) is1.a(Stream Type): This specifies the media type of the stream. The letterastands for audio. Other common specifiers includevfor video andsfor subtitles.0(Stream Index): This refers to the first audio stream within that specific input file. Like file indexing, stream indexing is zero-based, so0is the first audio track,1is the second, and so on.
Therefore, -map 1:a:0 translates to: “Select the
first audio stream from the second input file.”
Practical Example
To see this notation in action, consider the following command:
ffmpeg -i video.mp4 -i audio.m4a -map 0:v:0 -map 1:a:0 output.mp4In this scenario: 1. video.mp4 is input 0.
2. audio.m4a is input 1. 3.
-map 0:v:0 selects the first video stream from the first
input (video.mp4). 4. -map 1:a:0 selects the
first audio stream from the second input (audio.m4a).
The resulting output.mp4 file will combine the video
from the first file and the audio from the second file, ignoring any
other streams that might have existed in either input.