[FFmpeg-user] Confusion over stream specifier on -map, -codec,
Oliver Fromme
oliver at fromme.com
Thu Jul 25 19:08:09 EEST 2024
gqqnb2005 wrote:
> [...]
Please write your replies *below* the quoted text that you refer to,
not above. That makes it easier to follow the thread of conversation
in chronological order, and it reduces the risk of misquotes.
> Thank you for your reply. But I'm looking at the syntax of Stream
> specifiers. It clearly specifies 7 forms.
>
> 1. stream_index
> 2. stream_type[:additional_stream_specifier]
> 3. g:group_specifier[:additional_stream_specifier]
> 4. p:program_id[:additional_stream_specifier]
> 5. #stream_id or i:stream_id
> 6. m:key[:value]
> 7. u
>
> 0:1 fits none of the 7 forms.
> [LOW] fits none of the 7 forms.
>
> I wonder is it a documentation bug that it misses other forms of
> specifiers, or do I misunderstand something?
Note that -map and -codec have different syntax. For -codec, you give
a stream_specifier indeed, but for -map, the syntax is different:
-map [-]input_file_id[:stream_specifier][?] | [linklabel]
Let's take the examples that you mentioned:
In the argument ``0:1'', 0 is the input_file_id (i.e. the first input
file), and 1 is a stream_specifier that matches case 1 in the above
list that you quoted, i.e. it's a stream_index. In other words, this
is the second stream in the first input file.
The argument ``[LOW]'' is a linklabel, according to the syntax of the
-map option. A linklabel is not a stream_specifier, so it doesn't
appear in the list of seven cases above, and linklabels cannot be
used with the -codec option because the -codec option only accepts
stream_specifiers.
Also note that -map refers to streams of *input* files (that's why
you have to specify the input_file_id), while -codec and similar
options (like -b, -q, -pre etc.) refer to streams of the respective
*output* file.
> Mark Filipak <markfilipak.imdb at gmail.com> 於 2024年7月25日 週四 下午2:46寫道:
>
> > On 25/07/2024 00.56, gqqnb2005 wrote:
> > > Basically, I want to figure out how to specify streams for the option
> > -map,
> > > -codec, and -filter_complex.
> > >
> > > ffmpeg -i INPUT -map 0:1 out.wav
> > >
> > > Is 0:1 a stream specifier (
> > > https://ffmpeg.org//ffmpeg.html#Stream-specifiers-1)?
No, it isn't, it's an input_file_id ("0" in this case) followed by a
stream_specifier ("1").
> > Yes. Input 0, stream 1 (i.e., the 2nd stream, of any type). 'map' wires
> > things to the output.
> > No 'map', no output.
The last sentence is not correct. If there's no -map, then FFmpeg
selects the "best" stream per type automatically. The documentation
explains in detail what "best" means.
> > > ffmpeg -i INPUT -map 0 -c copy -c:v:1 libx264 -c:a:137 libvorbis OUTPUT
> > >
> > > v:1 and a:137 seem to follow the syntax of stream specifier because a
> > and v
> > > are stream_type.
> >
> > Yes, the 2nd video stream. There can't be 138 audio streams, so that has
> > to be wrong.
Of course there can be 138 audio streams, if the container format
supports it, and provided that the total bitrate is acceptable for
the particular use case. For example, the Matroska (MKV) format
supports an arbitrary number of streams (called "tracks" in the
MKV spec), as long as the track number fits in a 32 bit unsigned
integer.
Another example: While DVD video has a limit of 8 audio tracks
per title (and 32 subtitle tracks), Blu-ray video has no such limit
and only specifies a maximum total bitrate for audio + video.
When using low-bitrate AC3 streams, it's perfectly possible to
put more than 100 audio tracks on a Blue-ray title.
Whether there's a practical use case for that many audio tracks,
well, that's a different question. There are several thousand
languages in the world. And apart from that, additional audio
tracks are often used for commentary (they're usually low-bitrate
stereo or even mono streams), such as the producers, editors,
authors, actors, CGI engineers and whoever else might be involved
with the making of a movie.
> > > ffmpeg -i in.flac -filter_complex 'acrossover=split=1500[LOW][HIGH]' -map
> > > '[LOW]' low.wav -map '[HIGH]' high.wav
> > >
> > > Is '[LOW]' in the syntax of stream specifier?
No, it's not a stream_specifier, it's a linklabel, see above.
Best regards
-- Oliver
More information about the ffmpeg-user
mailing list