[FFmpeg-devel] [PATCH 25/25] avformat/matroskaenc: Redo handling of FlagDefault

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Fri Aug 20 11:55:44 EEST 2021


Nicolas George:
> Andreas Rheinhardt (12020-01-21):
>> Without a new option, one could not distinguish the case where the user
>> explicitly wants no dispositions at all and the case where one remuxes from
>> a source container that does not have the concept of default streams.
>> Furthermore, having an option allows to distinguish the infer and
>> "infer_no_subs" cases (the latter makes (some) players not show the
>> subtitles unless one explicitly enables them which is what (some) users
>> (including myself and apparently the guy behind #8416) want; I am actually
>> unsure whether infer_no_subs would make a better default value).
> 
> Hi. I am replying to this old discussion because I just lost a little
> time on an encode: I had "-disposition:2 -default" in my command line,
> and the track was still marked default, I was missing "-default_mode
> passthrough".
> 
> Silently ignoring or overriding user-given options is really not a good
> idea. How can we enhance that?
> 
> The obvious solution would be to make passthrough the default. That
> would make matroskaenc similar to other muxers. But I suppose you had a
> good reason to make infer the default?
> 

At the time of said patch, the definition of the default flag was: "Set
if that track (audio, video or subs) **SHOULD** be active if no language
found matches the user preference." This implies that if no language
found matches the user preference, then all default tracks should be
played simultaneously, so that it makes very little sense to mark more
than one track of a given type as default (there were also notes to the
spec which contradicted the main definition and said that in this case
the *first* default track should be used). For this reason mkvmerge
disallowed setting multiple default tracks of the same type. And given
that mkvmerge is the de-facto reference implementation, this meant that
simply passing the disposition through would have created files of
dubious validity. So I imitated what mkvmerge was doing.

The whole situation changed now; the meaning of the default flag has
been revised in a way that leaves no doubt that it is perfectly valid to
set the default flag for as many tracks as one wishes. Therefore I have
sent a patchset implementing this:
https://ffmpeg.org/pipermail/ffmpeg-devel/2021-August/284066.html

> We could try to find an heuristic to detect if the disposition was set,
> and print a warning if infer is used and it gets overridden. I do not
> like that much, because warnings are not a satisfactory solution.
> 
> We can try to find a real solution to detect if the disposition is set
> or not reliably, and use it (and then deprecate -default_mode). For
> example:
> 
> /**
>  * Set by demuxers when they know the disposition is reliable.
>  * Used by muxers to detect if they use the disposition or guess it.
>  */
> #define AV_DISPOSITION_SET 0x10000000
> 

I pondered doing such a thing then and now; I didn't do it last year
because a system as you propose would not have solved the main "problem"
(as I considered it at the time) of creating files where multiple tracks
of the same type are marked as default. I didn't do it now, because the
default course of action should always be just to preserve what the user
indicated. But if there are complaints, then I will probably implement
something like this.
(mkvmerge's strategy is btw: If the user set it explicitly on the
commandline, use this; else if the input file provides a default flag,
use this; else treat it as default track.)

- Andreas

PS: Sorry for taking so long to answer.


More information about the ffmpeg-devel mailing list