To control which video, audio, and subtitle streams an FFmpeg output contains, identify the input and stream numbers first, then use one -map for each stream you want in that output. Once streams are explicitly mapped, FFmpeg includes the mapped streams rather than choosing one automatically for each acceptable media type. Decide separately whether each mapped stream should be copied or re-encoded, then inspect and play the output to confirm it matches your plan.
1. Make a stream inventory
Treat input numbers and stream numbers as separate indexes, both starting at zero. The first -i input is 0, the second is 1; within an input, stream index 2 means its third stream. A reference such as 1:2 therefore means stream 2 in the second input, not “video 2.” Stream indexes identify streams; media type and contents tell you what each one is.
Before building the output command, inspect each source's stream list with a media-probing tool. Record each stream's index, type, codec, duration, and relevant metadata such as language, and identify its actual content. FFmpeg's documentation describes demuxers as providing a list of input streams and their properties; use the stream list reported by your existing probe tool to make the inventory. For example, two audio streams could be narration and music, while another is a complete mix; do not infer their roles from stream order alone.
Use a mapping worksheet:
| Input | Stream | Type and observed content | Keep? | Output position |
|---|---|---|---|---|
| 0 | 0 | Video, generated scene | Yes | First video |
| 0 | 1 | Audio, narration | Yes | First audio |
| 0 | 2 | Audio, music-only | No | — |
| 1 | 0 | Subtitle, reviewed captions | Yes | First subtitle |
These are hypothetical observations, not details of a particular source file. If an index or stream role is uncertain, resolve that before writing the map list.
2. Map the desired output, not every input
For each output, list its required inputs first, then place that output's -map options and other output options before its filename. Each -map adds a selected stream to that output. With multiple outputs, put each output's maps and options before the corresponding filename; for example, FFmpeg documents -i INPUT.mkv -map 0:0 -c copy OUTPUT0.mp4 -map 0:1 -c copy OUTPUT1.mp4. For example, if input 0 contains the video and two audio streams, and input 1 contains the subtitle stream you want, a hypothetical selection could be expressed as -map 0:0 -map 0:1 -map 1:0. This selects those three streams in that order; it does not select input 0:2.
The FFmpeg stream selection documentation distinguishes manual mapping from automatic selection. Without a -map for an output, FFmpeg selects acceptable streams automatically, using criteria such as video resolution, audio channel count, and subtitle compatibility with the output format. Those criteria may not reflect the story or mix you intend to deliver. With explicit maps, only mapped streams are included, subject to the documented exception for unlabeled complex-filter outputs.
Multiple maps can also combine streams from multiple inputs. If one output should contain a video from one file, narration from another, and captions from a third, map each source stream to the same output. The order of the maps determines the order in which those selected streams are added. Do not assume the original stream numbers will remain the output stream numbers: inspect the finished file.
3. Choose copy or re-encoding for each mapped stream
Mapping answers “which streams?” Codec options answer “what happens to them?” With -c copy, FFmpeg copies the selected streams without decoding and encoding. This can avoid an encoding generation and is appropriate when you do not need to transform the stream and the target container supports it. But stream copy cannot apply filters, and it may fail when the output container cannot carry a source stream as-is.
If a selected video needs resizing or a selected audio track needs mixing, re-encoding is required for the affected output. FFmpeg’s documentation describes transcoding as decoding and encoding again; it is commonly needed for filters or when the destination cannot decode the original codec. You can set codec choices by stream type, for example -c:v for selected video and -c:a for selected audio. Check the target format’s support before choosing codecs, and do not expect stream copying to perform a conversion.
The FFmpeg streamcopy and transcoding sections explain this distinction. Apply output options in the context of the output they are meant to configure; FFmpeg options generally apply to the next specified input or output, so option placement matters.
4. Verify the file against the worksheet
Use this ordered check before delivery:
- List each input and record its zero-based input index.
- Read each input's stream list; identify stream index, type, actual content, codec, duration, and relevant metadata.
- Mark each stream keep or omit, then write the
-mapentries in the desired output order, grouped before their corresponding output filename. - Choose copy or a suitable encoder for each mapped stream; use encoding when a required transformation cannot be done by stream copy.
- Read the output's stream list and compare its count, types, codecs, and order with the worksheet. Play it to confirm the included picture, intended audio, and captions.
If the output differs, first check whether a required map is missing or points to the wrong input stream. If the maps are correct, check whether the container supports the selected stream types and codecs and whether the chosen copy or encoding path can produce them.
Suppose, hypothetically, the plan calls for one video, one narration track, and one subtitle stream, but probing the output shows two audio streams and no subtitle. Do not assume the player hid the captions: compare the command’s maps with the input inventory, check that the subtitle was present at the mapped input index, and confirm that the selected subtitle type and the output container are compatible. If the output has the expected count but the wrong audio content, the map may point to the wrong stream; return to the content notes rather than relying on stream index alone.
5. Separate mapping errors from output-format errors
If the output is wrong, check the maps first: confirm each input and stream index, and make sure every required stream is mapped to the intended output. If the maps are correct but FFmpeg cannot write the file, check whether the target container supports each selected stream type and codec. A filter requires decoding and re-encoding the affected stream; -c copy cannot apply filters or convert an incompatible stream.
Maps control stream selection, not language labels, default-track behavior, synchronization, or audio mixing. Subtitle compatibility depends on subtitle type and output format. Also account for the documented complex-filtergraph exception: unlabeled filter outputs may be added to the first output even when maps are present.
Does `-map 0` mean “keep everything”?
It selects all streams from input 0, rather than listing individual streams. Use it only when retaining every stream from that input is intentional and the output format supports them. For a curated delivery file, explicit per-stream maps make omissions and ordering easier to review.
Can the same input stream appear twice in one output?
A map adds a selected stream to an output; the documentation supports using repeated maps to add multiple streams. If you intend to duplicate a particular source stream, verify that the resulting output and target container handle that arrangement as expected. Do not infer the output order or player behavior without inspecting and playing the file.
Sources and next step
This guide interprets public documentation and uses explicitly hypothetical acceptance examples, not application tests. Controls and availability can change; verify the cited manual against your installed version.
For work created in Imagild, carry the input requirements and acceptance checklist into the film workspace. The external software controls discussed above belong to their respective products.