When a batch contains AI shorts with inconsistent stream layouts, mark only genuinely optional streams with a trailing ? in their FFmpeg -map specifier. Keep required video or audio mappings unmarked. The question mark tells FFmpeg not to fail just because a matching stream is absent; it does not create that stream or guarantee it will appear in the output.
Decide what may be absent
Write down the delivery requirement before building the command. A short intended for a video platform may require one video stream and one audio stream, while subtitles, a second language track, or other supplemental streams may be optional. If the result must include a particular subtitle or alternate mix, that stream is required even if other files in the batch do not contain it.
FFmpeg’s stream-selection documentation explains that -map selects input streams for an output. Once you use -map for an output, only mapped streams are included, apart from the documented filtergraph-output exception. Therefore, an explicit map list is a selection policy, not a request to retain every input stream.
Build the mapping deliberately
Use this sequence for each input layout or batch policy:
- Inspect the input’s stream list and identify the input index and stream types. Do not infer stream numbers from another file: indices refer to streams in that particular input.
- Mark the main video and main audio as required if the deliverable depends on both. Map those streams without
?so their absence remains an error. - Mark subtitles, a second audio track, or other supplementary streams optional only if the deliverable is acceptable without them. Add
?to those map specifiers, for example-map 0:s?for available subtitle streams or-map 0:a:1?for a second audio stream in input 0.
Syntax illustration only, not a tested command: ffmpeg -i INPUT -map 0:v:0 -map 0:a:0 -map 0:s? -map 0:a:1? -c copy OUTPUT. Here the first video and audio maps are required; subtitle and second-audio maps are optional. Confirm that the selectors match each input’s actual stream layout. This illustration assumes one main video and one main audio; adapt it when the required streams differ.
4. Keep the output’s intended codec and container choices separate from the presence policy. Mapping determines selection; it does not establish that every selected stream can be copied or encoded into the chosen output format.
5. Write to a distinct output path, then inspect the completed file’s streams before accepting the batch item.
Accept presence and absence correctly
The following is a hypothetical batch policy, not a tested command result. Assume each input should contain one main video and one main audio stream; subtitles and a second audio stream are optional. The mapping policy requires the main streams and uses optional selectors for the extras.
| Hypothetical input observation | Expected mapping decision | Acceptance result |
|---|---|---|
| Video and audio present; no subtitles or second audio | Required maps match; optional maps match nothing | Continue; output has video and audio, with no claim that optional tracks were included |
| Video, audio, and subtitles present; no second audio | Required maps match; subtitle map matches | Continue only if the output probe confirms subtitles survived the chosen output settings |
| Video present; main audio absent | Required audio map has no match | Reject this item or route it for repair; do not classify optional-map tolerance as success |
| Audio present; main video absent | Required video map has no match | Reject this item or route it for repair |
Use this matrix as the acceptance procedure: check the output against the input observation and delivery requirement, confirming required streams remain present and any optional stream required for that item actually appears. An optional stream absent from both input and output is acceptable only when the delivery policy permits its absence.
Troubleshoot the result
If an item fails on a required map, inspect that specific input’s stream list and confirm whether the stream is genuinely absent, mapped from the wrong input index, or excluded by an incorrect stream selector. Do not make a required map optional merely to get a green batch run; that can turn a bad deliverable into an apparently successful one.
If FFmpeg completes but an expected optional track is missing, check whether the input actually had a matching stream, whether the mapping selector targeted it, and whether the output container and codec settings allow it. The optional suffix handles absence during selection; it does not resolve container compatibility, conversion, or encoding errors. Also remember that -map limits output to the streams you selected, so an unlisted track will not be retained by explicit mapping.
Does `?
` select a substitute, and does command success prove an expected track is present?
No to both. It makes only that mapping optional when no match exists; it does not choose a substitute. Check the output against the item’s requirement using the acceptance matrix.
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.