How to Map Specific Streams in FFmpeg

This article explains how to use the FFmpeg -map option to precisely select and route video, audio, and subtitle streams from your input files to your output file. You will learn the basic syntax of the -map option, see practical examples for single and multiple inputs, and discover how to exclude specific streams during processing.

By default, FFmpeg automatically selects only one video stream and one audio stream from your inputs. To gain full control over which streams are included in your output, you must use the -map option.

The Basic Syntax

The syntax for the -map option uses the following format:

-map input_file_index:stream_type_specifier:stream_index

Common Use Cases and Examples

1. Map All Streams from an Input

To copy every single video, audio, and subtitle stream from your first input file to the output:

ffmpeg -i input.mkv -map 0 -c copy output.mkv

2. Map Only the Video Stream

If you want to extract just the video from a file and discard all audio and subtitles:

ffmpeg -i input.mp4 -map 0:v output_video.mp4

3. Map a Specific Audio Track

If an input file has multiple language tracks and you want to select the second audio track (index 1):

ffmpeg -i input.mkv -map 0:v:0 -map 0:a:1 -c copy output.mkv

This command maps the first video stream (0:v:0) and the second audio stream (0:a:1).

4. Combine Streams from Multiple Input Files

To take the video from one file and the audio from another file:

ffmpeg -i video_input.mp4 -i audio_input.wav -map 0:v:0 -map 1:a:0 -c:v copy -c:a aac output.mp4

5. Exclude a Specific Stream (Negative Mapping)

You can use a negative sign - to exclude specific streams. For example, to map all streams from a file except the subtitles:

ffmpeg -i input.mkv -map 0 -map -0:s -c copy output.mkv

This maps everything from the first input (-map 0) and then explicitly removes all subtitle streams (-map -0:s).