WIP: libavformat/matroskadec.c: export profile container metadata #21787

Draft
toots wants to merge 1 commit from toots/matroska-webm-profile into master AGit
Member

It looks like it is not currently possible to distinguish between matroska and webm when working with AVFormatContext and AVInputFormat.

This PR adds a "doctype" metadata to the demuxer's metadata that can be used to make such distinction at runtime.

It looks like it is not currently possible to distinguish between `matroska` and `webm` when working with `AVFormatContext` and `AVInputFormat`. This PR adds a `"doctype"` metadata to the demuxer's metadata that can be used to make such distinction at runtime.
toots changed title from libavformat/matroskadec.c: export profile container metadata to to libavformat/matroskadec.c: export profile container metadata 2026-02-18 17:42:40 +00:00
Contributor

What is this information supposed to be good for?

Exporting this as metadata is problematic, because simply remuxing a matroska/webm file into a container (like Matroska) that supports the "profile" metadata (i.e. writes it) will add a such metadata from the demuxer, although it is likely wrong for the muxer. This is likely why fate doesn't pass for your commit.

What is this information supposed to be good for? Exporting this as metadata is problematic, because simply remuxing a matroska/webm file into a container (like Matroska) that supports the "profile" metadata (i.e. writes it) will add a such metadata from the demuxer, although it is likely wrong for the muxer. This is likely why fate doesn't pass for your commit.
toots force-pushed toots/matroska-webm-profile from 518aaeb592
Some checks failed
Lint / Pre-Commit (pull_request) Successful in 22s
Autolabel / Labeler (pull_request_target) Has been skipped
Test / Fate (linux-aarch64, static, 64 bit) (pull_request) Failing after 9m8s
Test / Fate (linux-amd64, static, 32 bit) (pull_request) Failing after 12m11s
Test / Fate (linux-amd64, shared, 64 bit) (pull_request) Failing after 11m55s
Test / Fate (Full, wine) (pull_request) Failing after 16m13s
to 9271f9ca75
Some checks failed
Autolabel / Labeler (pull_request_target) Successful in 9s
Lint / Pre-Commit (pull_request) Successful in 29s
Test / Fate (linux-aarch64, static, 64 bit) (pull_request) Failing after 9m46s
Test / Fate (linux-amd64, static, 32 bit) (pull_request) Failing after 12m29s
Test / Fate (linux-amd64, shared, 64 bit) (pull_request) Failing after 13m49s
Test / Fate (Full, wine) (pull_request) Has been cancelled
2026-02-18 18:19:42 +00:00
Compare
Author
Member

@mkver wrote in #21787 (comment):

What is this information supposed to be good for?

Exporting this as metadata is problematic, because simply remuxing a matroska/webm file into a container (like Matroska) that supports the "profile" metadata (i.e. writes it) will add a such metadata from the demuxer, although it is likely wrong for the muxer. This is likely why fate doesn't pass for your commit.

Yes this is the reason. I just pushed a change to exclude it from the muxer.

In the application I'm looking at, we want to be able to know the exact format to initialize a new output from a AVFormatContext and be specific regarding the underlying container.

The same issue exists with mov,mp4 etc. In this case, the metadata major_brand can be used so it felt natural to also use a metadata in this case.

Happy to consider other methods.

@mkver wrote in https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21787#issuecomment-26231: > What is this information supposed to be good for? > > Exporting this as metadata is problematic, because simply remuxing a matroska/webm file into a container (like Matroska) that supports the "profile" metadata (i.e. writes it) will add a such metadata from the demuxer, although it is likely wrong for the muxer. This is likely why fate doesn't pass for your commit. Yes this is the reason. I just pushed a change to exclude it from the muxer. In the application I'm looking at, we want to be able to know the exact format to initialize a new output from a `AVFormatContext` and be specific regarding the underlying container. The same issue exists with `mov,mp4` etc. In this case, the metadata `major_brand` can be used so it felt natural to also use a metadata in this case. Happy to consider other methods.
toots force-pushed toots/matroska-webm-profile from 9271f9ca75
Some checks failed
Autolabel / Labeler (pull_request_target) Successful in 9s
Lint / Pre-Commit (pull_request) Successful in 29s
Test / Fate (linux-aarch64, static, 64 bit) (pull_request) Failing after 9m46s
Test / Fate (linux-amd64, static, 32 bit) (pull_request) Failing after 12m29s
Test / Fate (linux-amd64, shared, 64 bit) (pull_request) Failing after 13m49s
Test / Fate (Full, wine) (pull_request) Has been cancelled
to ae24bfcf33
Some checks failed
Autolabel / Labeler (pull_request_target) Has been skipped
Lint / Pre-Commit (pull_request) Successful in 26s
Test / Fate (linux-amd64, shared, 64 bit) (pull_request) Has been cancelled
Test / Fate (linux-aarch64, static, 64 bit) (pull_request) Has been cancelled
Test / Fate (Full, wine) (pull_request) Has been cancelled
Test / Fate (linux-amd64, static, 32 bit) (pull_request) Has been cancelled
2026-02-18 18:34:33 +00:00
Compare
toots force-pushed toots/matroska-webm-profile from ae24bfcf33
Some checks failed
Autolabel / Labeler (pull_request_target) Has been skipped
Lint / Pre-Commit (pull_request) Successful in 26s
Test / Fate (linux-amd64, shared, 64 bit) (pull_request) Has been cancelled
Test / Fate (linux-aarch64, static, 64 bit) (pull_request) Has been cancelled
Test / Fate (Full, wine) (pull_request) Has been cancelled
Test / Fate (linux-amd64, static, 32 bit) (pull_request) Has been cancelled
to e49c3fcb1a
Some checks failed
Autolabel / Labeler (pull_request_target) Successful in 12s
Lint / Pre-Commit (pull_request) Successful in 26s
Test / Fate (linux-amd64, static, 32 bit) (pull_request) Failing after 11m37s
Test / Fate (linux-aarch64, static, 64 bit) (pull_request) Failing after 11m16s
Test / Fate (linux-amd64, shared, 64 bit) (pull_request) Failing after 15m40s
Test / Fate (Full, wine) (pull_request) Has been cancelled
2026-02-18 18:40:40 +00:00
Compare
toots force-pushed toots/matroska-webm-profile from e49c3fcb1a
Some checks failed
Autolabel / Labeler (pull_request_target) Successful in 12s
Lint / Pre-Commit (pull_request) Successful in 26s
Test / Fate (linux-amd64, static, 32 bit) (pull_request) Failing after 11m37s
Test / Fate (linux-aarch64, static, 64 bit) (pull_request) Failing after 11m16s
Test / Fate (linux-amd64, shared, 64 bit) (pull_request) Failing after 15m40s
Test / Fate (Full, wine) (pull_request) Has been cancelled
to 84b5740fb0
Some checks failed
Lint / Pre-Commit (pull_request) Successful in 53s
Test / Fate (linux-aarch64, static, 64 bit) (pull_request) Failing after 11m13s
Test / Fate (linux-amd64, static, 32 bit) (pull_request) Failing after 14m29s
Test / Fate (linux-amd64, shared, 64 bit) (pull_request) Failing after 15m58s
Test / Fate (Full, wine) (pull_request) Failing after 24m56s
Autolabel / Labeler (pull_request_target) Has been skipped
2026-02-18 19:04:12 +00:00
Compare
Author
Member

@mkver and, yes, the same metadata leak happens when re-encoding to e.g. ogg from mp4:

% ffprobe /tmp/bla.ogg                                                                                                                                13:04:41
...
Input #0, ogg, from '/tmp/bla.ogg':
  Duration: 00:00:03.00, start: 0.000000, bitrate: 227 kb/s
  Stream #0:0(und): Video: theora, yuv420p, 854x480 [SAR 1:1 DAR 427:240], 30 tbr, 30 tbn
    Metadata:
      encoder         : Lavc62.11.100 libtheora
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2avc1mp41

If you have any suggestion for a better approach, I'd be interested to hear.

@mkver and, yes, the same metadata leak happens when re-encoding to e.g. `ogg` from `mp4`: ```shell % ffprobe /tmp/bla.ogg 13:04:41 ... Input #0, ogg, from '/tmp/bla.ogg': Duration: 00:00:03.00, start: 0.000000, bitrate: 227 kb/s Stream #0:0(und): Video: theora, yuv420p, 854x480 [SAR 1:1 DAR 427:240], 30 tbr, 30 tbn Metadata: encoder : Lavc62.11.100 libtheora handler_name : VideoHandler vendor_id : [0][0][0][0] major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 ``` If you have any suggestion for a better approach, I'd be interested to hear.
Owner

Metadata may be the only feasible way to export this, but not as a "profile" key. Maybe "doctype" instead, much like mp4/mov export handler_name and *_brand.

Metadata may be the only feasible way to export this, but not as a "profile" key. Maybe "doctype" instead, much like mp4/mov export handler_name and *_brand.
toots force-pushed toots/matroska-webm-profile from 84b5740fb0
Some checks failed
Lint / Pre-Commit (pull_request) Successful in 53s
Test / Fate (linux-aarch64, static, 64 bit) (pull_request) Failing after 11m13s
Test / Fate (linux-amd64, static, 32 bit) (pull_request) Failing after 14m29s
Test / Fate (linux-amd64, shared, 64 bit) (pull_request) Failing after 15m58s
Test / Fate (Full, wine) (pull_request) Failing after 24m56s
Autolabel / Labeler (pull_request_target) Has been skipped
to 187818d7a6
Some checks failed
Autolabel / Labeler (pull_request_target) Successful in 10s
Lint / Pre-Commit (pull_request) Has been cancelled
Test / Fate (linux-amd64, static, 32 bit) (pull_request) Has been cancelled
Test / Fate (linux-aarch64, static, 64 bit) (pull_request) Has been cancelled
Test / Fate (linux-amd64, shared, 64 bit) (pull_request) Has been cancelled
Test / Fate (Full, wine) (pull_request) Has been cancelled
2026-02-19 12:01:24 +00:00
Compare
toots force-pushed toots/matroska-webm-profile from 187818d7a6
Some checks failed
Autolabel / Labeler (pull_request_target) Successful in 10s
Lint / Pre-Commit (pull_request) Has been cancelled
Test / Fate (linux-amd64, static, 32 bit) (pull_request) Has been cancelled
Test / Fate (linux-aarch64, static, 64 bit) (pull_request) Has been cancelled
Test / Fate (linux-amd64, shared, 64 bit) (pull_request) Has been cancelled
Test / Fate (Full, wine) (pull_request) Has been cancelled
to 72eaca523d
Some checks failed
Lint / Pre-Commit (pull_request) Successful in 28s
Autolabel / Labeler (pull_request_target) Has been skipped
Test / Fate (linux-amd64, shared, 64 bit) (pull_request) Failing after 9m46s
Test / Fate (linux-aarch64, static, 64 bit) (pull_request) Failing after 9m37s
Test / Fate (linux-amd64, static, 32 bit) (pull_request) Failing after 13m27s
Test / Fate (Full, wine) (pull_request) Failing after 27m56s
2026-02-19 12:01:41 +00:00
Compare
toots force-pushed toots/matroska-webm-profile from 72eaca523d
Some checks failed
Lint / Pre-Commit (pull_request) Successful in 28s
Autolabel / Labeler (pull_request_target) Has been skipped
Test / Fate (linux-amd64, shared, 64 bit) (pull_request) Failing after 9m46s
Test / Fate (linux-aarch64, static, 64 bit) (pull_request) Failing after 9m37s
Test / Fate (linux-amd64, static, 32 bit) (pull_request) Failing after 13m27s
Test / Fate (Full, wine) (pull_request) Failing after 27m56s
to dcb82456c4
Some checks failed
Lint / Pre-Commit (pull_request) Successful in 29s
Test / Fate (linux-aarch64, static, 64 bit) (pull_request) Failing after 7m29s
Test / Fate (linux-amd64, shared, 64 bit) (pull_request) Failing after 11m19s
Test / Fate (linux-amd64, static, 32 bit) (pull_request) Failing after 11m53s
Test / Fate (Full, wine) (pull_request) Failing after 25m26s
Autolabel / Labeler (pull_request_target) Has been skipped
2026-02-19 12:45:28 +00:00
Compare
Contributor

a) Run FATE locally and send patches that actually pass FATE.
b) Using "doctype" is still unacceptable: It makes it impossible to write a doctype tag into Matroska and doctype tags will leak into other containers.

a) Run FATE locally and send patches that actually pass FATE. b) Using "doctype" is still unacceptable: It makes it impossible to write a doctype tag into Matroska and doctype tags will leak into other containers.
Owner

@mkver wrote in #21787 (comment):

b) Using "doctype" is still unacceptable: It makes it impossible to write a doctype tag into Matroska and doctype tags will leak into other containers.

Then a proper way to signal this kind of information is needed, and implemented in mp4 too in order to also not leak the aforementioned tags into other containers.

@mkver wrote in https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21787#issuecomment-26307: > b) Using "doctype" is still unacceptable: It makes it impossible to write a doctype tag into Matroska and doctype tags will leak into other containers. Then a proper way to signal this kind of information is needed, and implemented in mp4 too in order to also not leak the aforementioned tags into other containers.
Author
Member

@mkver wrote in #21787 (comment):

a) Run FATE locally and send patches that actually pass FATE.

This is proving difficult on mac but I'll have another pass.

b) Using "doctype" is still unacceptable: It makes it impossible to write a doctype tag into Matroska and doctype tags will leak into other containers.

Tags already leak into other containers as exemplified above.

I'm not attached to any particular name but doctype works great for me because it is actually a technically accurate description of the value that's exported.

Re: tag leak, I think that it should be a different effort. I wrote on IRC about maybe using tags attached to dictionary values, somthing like: AV_DICT_INTERNAL that would prevent values with such tags from being re-exported.

Happy to get feedback on that!

@mkver wrote in https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21787#issuecomment-26307: > a) Run FATE locally and send patches that actually pass FATE. This is proving difficult on mac but I'll have another pass. > b) Using "doctype" is still unacceptable: It makes it impossible to write a doctype tag into Matroska and doctype tags will leak into other containers. Tags already leak into other containers as exemplified above. I'm not attached to any particular name but `doctype` works great for me because it is actually a technically accurate description of the value that's exported. Re: tag leak, I think that it should be a different effort. I wrote on IRC about maybe using tags attached to dictionary values, somthing like: `AV_DICT_INTERNAL` that would prevent values with such tags from being re-exported. Happy to get feedback on that!
toots changed title from libavformat/matroskadec.c: export profile container metadata to WIP: libavformat/matroskadec.c: export profile container metadata 2026-02-21 01:34:51 +00:00
Some checks failed
Lint / Pre-Commit (pull_request) Successful in 29s
Required
Details
Test / Fate (linux-aarch64, static, 64 bit) (pull_request) Failing after 7m29s
Required
Details
Test / Fate (linux-amd64, shared, 64 bit) (pull_request) Failing after 11m19s
Required
Details
Test / Fate (linux-amd64, static, 32 bit) (pull_request) Failing after 11m53s
Required
Details
Test / Fate (Full, wine) (pull_request) Failing after 25m26s
Required
Details
Autolabel / Labeler (pull_request_target) Has been skipped
This pull request has changes conflicting with the target branch.
  • doc/APIchanges
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin +refs/pull/21787/head:toots/matroska-webm-profile
git switch toots/matroska-webm-profile
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
FFmpeg/FFmpeg!21787
No description provided.