ffmpeg stream specifiers

2024年7月24日


A video file ususally not only contains a video stream but also an audio stream. We use a stream specifier to select a stream from an input file. Stream specifiers have a number of forms:

  • stream_index where stream_index is an integer
  • stream_type[:additional_stream_specifier] where stream_type is a, v, V, d, or t
  • g:group_specifier[:additional_stream_specifier]
  • p:program_id[:additional_stream_specifier]
  • #stream_id
  • i:stream_id
  • m:key[:value]
  • u

Hence, by looking at the first letter, ffmpeg can determine which form of specifier it is.

The map option

The documented syntax of -map is shown in Listing , but in reality -map also accepts a link label in the form of "[" words "]".

$ ffmpeg --help full 2>&1| grep -- '-map\b'
-map <[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]>  set input stream mapping
: the official syntax of the -map option

The codec option

The documented syntax of -codec is shown in Listing .

$ ffmpeg --help full 2>&1| grep -- '-codec\b'
-codec[:<stream_spec>] <codec>  alias for -c (select encoder/decoder)
: the official syntax of the -codec option

Stream Specifiers

Filter Labels

The -filter_complex option in ffmpeg allows to apply multiple filters on streams. In the value of this option, as known as filtergraph, you typically will provide stream specifiers. In the syntax of filtergraph, stream specifiers are called labels because you can create custom labels, not only the 8 forms.

NAME             ::= sequence of alphanumeric characters and '_'
LINKLABEL        ::= "[" NAME "]"