Why Naive ftypavif Substring Matching Fails on Real-World ISO BMFF Containers
Structural Parsing of mif1, msf1, pitm, iinf, and Sample Descriptions
Checking bytes 4..11 of an upload for the literal ASCII string ftypavif misclassifies valid AVIF files whose major brand is mif1, miaf, or avis while listing avif only inside the compatible_brands array—and worse, confuses HEVC-coded iPhone HEIC containers sharing generic mif1 headers. Reliable format dispatch requires walking length-prefixed 32-bit and 64-bit (largesize=1) ISO/IEC 14496-12 boxes with strict parent-boundary enforcement.
Our bounded parser traverses up to 512 boxes and 10 nesting levels without recursive buffer copies, extracting ftyp major/minor/compatible brands, primary item IDs (pitm), item info entries (iinf/infe), auxiliary alpha/premultiplied references (iref), item properties (ispe, pixi, av1C, colr), and movie sample tables (stsd, stts, stsz, stco, stss). Truncated or overlapping box lengths stop cleanly without out-of-bounds reads.
- Displays exact byte offset, box byte length, nesting depth, and decoded field summary for every container box.
- Distinguishes AV1 (av01 / av1C) items from HEVC (hvc1 / hvcC) items inside generic mif1 wrappers.
- Verifies whether dual-purpose avis files carry both a fallback pitm still and an av01 video sequence track.