Skip to content

MP4: unify container box parsing and expand container box support#515

Open
klirktag wants to merge 1 commit intoWerWolv:masterfrom
klirktag:improve-mp4-parser
Open

MP4: unify container box parsing and expand container box support#515
klirktag wants to merge 1 commit intoWerWolv:masterfrom
klirktag:improve-mp4-parser

Conversation

@klirktag
Copy link
Copy Markdown
Contributor

@klirktag klirktag commented Mar 31, 2026

Background

MP4 files cosists of a tree of boxes. That means there are two different kinds of boxes: Container boxes and Leaf boxes. The Leaf boxes are the boxes that contains data, and the Container boxes contains other boxes. All container boxes in the MP4 files works exactly the same way, they just have different content. Before this PR all the container boxes had it's own duplicated implementation for each container box name

What this PR does

After this PR, all the container boxes are defined in an array called CONTAINER_BOX_TYPES

This array is used to check against to detect container boxes, and then all the contianer boxes uses exactly the same parser code.

This PR greatly simplifies the code by providing the same feature of parsing container boxes, but with much less code. Also adding new container boxes is much easier now

Additional container boxes

Since it is now much easier to support new container boxes then before, it also adds support for many new container boxes that are in the ISO/MP4 standard. This is done easily by just adding them to the CONTAINER_BOX_TYPES array

New boxes supported that was not supported before this PR:
mvex, moof, traf, mfra - fragmented MP4
udta, meta, ilst - metadata
meco - additional metadata
tref, trgr - track references/grouping
sinf, schi, ipro - content protection
iprp, ipco, iref, grpl - item properties/references (HEIF)
clip, matt - QuickTime legacy
strk, strd - sub track

@klirktag klirktag changed the title Improve MP4 parser by making it recurisve with simpler code. Easier to support new boxes MP4: unify container box parsing and expand container box support Mar 31, 2026
@klirktag klirktag force-pushed the improve-mp4-parser branch from fde0e31 to e23e932 Compare March 31, 2026 23:26
@klirktag klirktag force-pushed the improve-mp4-parser branch from e23e932 to 1d9e731 Compare March 31, 2026 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant