From 54aab8593744329c7ceba011a2b3b0363d90547c Mon Sep 17 00:00:00 2001 From: kfrn Date: Fri, 2 Aug 2019 19:21:58 +1200 Subject: [PATCH] Add note to Stream Mapping entry about mapping with a failsafe Following Ben Turkus' comment here: https://github.com/amiaopensource/ffmprovisr/issues/383#issuecomment-516847829 --- index.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index fb6c486..bec6f28 100644 --- a/index.html +++ b/index.html @@ -178,8 +178,12 @@
  • -map 0:0 -map 0:2 means ‘take the first and third streams from the first input file’.
  • -map 0:1 -map 1:0 means ‘take the second stream from the first input file and the first stream from the second input file’.
  • -

    To map all streams in the input file to the output file, use -map 0. However, note that not all container formats can include all stream types: for example, .mp4 cannot contain timecode.

    When no mapping is specified in an ffmpeg command, the default for video files is to take just one video and one audio stream for the output: other stream types, such as timecode or subtitles, will not be copied to the output file by default. If multiple video or audio streams are present, the best quality one is automatically selected by FFmpeg.

    +

    To map all streams in the input file to the output file, use -map 0. However, note that not all container formats can include all stream types: for example, .mp4 cannot contain timecode.

    +

    Mapping with a failsafe

    +

    To safely process files that may or may not contain given a type of stream, you can add a trailing ? to your map commands: for example, -map 0:a? instead of -map 0:a.

    +

    This makes the map optional: audio streams will be mapped over if they are present in the file—but if the file contains no audio streams, the transcode will precede as usual, minus the audio stream mapping. Without adding the trailing ?, FFmpeg will exit with an error on that file.

    +

    This is especially recommended when batch processing video files: it ensures that all files in your batch will be transcoded, whether or not they contain audio streams.

    For more information, check out the FFmpeg wiki Map page, and the official FFmpeg documentation on -map.