[FFmpeg-devel] [PATCH]Fix default stream flag value wrt matroska muxing

Hendrik Leppkes h.leppkes at gmail.com
Mon Jan 28 12:55:09 CET 2013


On Mon, Jan 28, 2013 at 10:37 AM, Carl Eugen Hoyos <cehoyos at ag.or.at> wrote:
> On Monday 28 January 2013 12:17:58 am Carl Eugen Hoyos wrote:
>> Hi!
>>
>> The matroska specification describes a stream flag "FlagDefault" that
>> defaults to "default".
>> FFmpeg has a stream disposition AV_DISPOSITION_DEFAULT. Since disposition
>> is initialized to "0", the default value for the FFmpeg flag is "not
>> default". The result is that except for a corner case (forced flag set)
>> whenever a matroska stream is used as input, the output stream is set as
>> "default" in matroska files because either the flag was set and is written
>> or it was not set, then it is not written and the matroska default value
>> takes effect, see ticket #1815.
>>
>> Attached is a possibility to fix this problem by adding an additional flag
>> to tell if the value is set or not.
>> I am not convinced that always writing the matroska "FlagDefault" instead
>> is a better solution because it would suddenly make nearly all streams in
>> matroska files written by lavf "non-default".
>
> Alternative, simpler patch attached that makes AV_DISPOSITION_DEFAULT the
> default for new streams and only resets it in demuxers that set the flag
> correctly (missing nut tests and changes).
>
> Please review, Carl Eugen
>

Both attempts seem not-optimal. The demuxer already behaves as the
spec defines it, so it shouldn't be changed.

What i would do is check all input streams in the muxer (ie in
mkv_write_tracks), and if none have a default disposition, then mark
the first of each type as such (first audio, first video, first
subtitle). But if one stream is marked as default, then keep that
flag, and write it as 0 for all other streams. This is how other mkv
muxers behave, more or less.

Setting some global flags just for this Matroska case seems like it
will result in many sideeffects. The stream disposition should not
include a default flag if the format does not define one (explicitly
or implicitly), because it is misleading information.


More information about the ffmpeg-devel mailing list