[FFmpeg-devel] [PATCH] libavformat/matroskaenc: omit segment UID for webm

Dave Rice dave at dericed.com
Wed Jun 22 22:16:30 CEST 2016

> On Jun 22, 2016, at 10:16 AM, Michael Bradshaw <mjbshaw at gmail.com> wrote:
> On Tue, Jun 21, 2016 at 12:22 PM, Michael Niedermayer
> <michael at niedermayer.cc> wrote:
>> what does "supported" / "unsupported" mean, is this defined somewhere ?
> As far as WebM is concerned, SegmentUID doesn't exist.
> In this situation, writing SegmentUID is Undefined-Ignore or
> Optional-Fail/Forbidden, depending on the file. I concur with Dave's
> analysis, but parsing may fail if SegmentUID is written and the master
> element has an unknown size (which will be the case if ffmpeg is
> writing to an unseakable output, like pipes). This is because master
> elements with unknown size are terminated by the first unrecognized
> would-be-child element[1], which would cause the parser to terminate
> the Info element.

I don’t quite think that the EBML specification agrees with this explanation. See:

"When EBML is used in transmission or streaming, data that is not part of an EBML Element is permitted to be present within a Master-element if `unknownsizeallowed` is enabled within that Master-element's definition. In this case, the reader should skip data until a valid Element ID of the same level or the next greater level of the Master-element is found. What Element IDs are considered valid within a Master-element is identified by the EBML Schema for that version of the EBML Document Type. Any data contained with a Master-element that is not part of an Element SHOULD be ignored."

In this case a SegmentUID Element (undefined in webm) should be skipped be the reader rather than cause the termination of the reader.

The end of an unknown-sized Element is determined by the beginning of the next known Element that is not a valid sub-element rather than the first unknown Element.

> This would continue to screw up parsing, because now
> there could be other children of Info (like DateUTC) after the
> SegmentUID, and since the Info element has terminated and those aren't
> valid children of Segment, it would cause the Segment element to
> terminate. At that point, the file is pretty broken because now there
> is no Segment element containing the Clusters and other elements.
> [1]: "The end of a Master-element with unknown size is determined by
> the beginning of the next element that is not a valid sub-element of
> that Master-element" (from the current EBML spec)

Best Regards,
Dave Rice

More information about the ffmpeg-devel mailing list