ACIDCAT . FILE FORMAT REFERENCE

MP4 / M4A

ISO Base Mediacontainer . big-endian
rev 2026.06
magic "ftyp" @ 4
endian big
container nested boxes
codec AAC / ALAC

An MP4 / M4A is a tree of nested boxes (atoms): every box opens with a big-endian u32 size and a four-character type code, then holds either more boxes or a typed payload. Defined by ISO/IEC 14496-12 (ISO Base Media File Format), originally derived from QuickTime. Hover a field to light its bytes, click a + for its lookup table. Color marks kind (see the key).

box regions

Every MP4 is a flat sequence of top-level boxes; moov holds the entire metadata tree.

ftypfirst box . brand declaration
major_brand4cc identifying the primary spec, e.g. "M4A " for Apple AAC audio
minor_versioninformational; parsers must not gate playback on this value
compatible_brandsarray of 4cc to end of box; any match is sufficient for a reader
moovmovie container . entire metadata tree
mvhdtimescale, duration, creation and modification times
trakone per track; audio track contains mdia > minf > stbl > stsd
stsdsample description: "mp4a" = AAC, "alac" = Apple Lossless
udta / ilstiTunes tag atoms nested under moov > udta > meta > ilst
mdatmedia data . raw encoded samples

Raw encoded audio frames with no intrinsic framing. May appear before moov (streaming layout) or after it. The stco/co64 box inside stbl holds absolute file offsets into mdat; duration = stts sample count / mvhd timescale.

free / skippadding . in-place edit slack

Payload is zeroed or arbitrary. Sized to let moov be rewritten in place without moving stco sample offsets into mdat.

udta / meta / ilstiTunes tags
pathmoov > udta > meta > ilst > ©nam, ©ART, ©day, aART, trkn, covr
covrartwork: nested data atom, type flag 0x0D = JPEG, 0x0E = PNG
notemeta is a FullBox (version + 3-byte flags precede its children)
box header

8 bytes before every box. Example: 00 00 00 18 66 74 79 70 = size 24, type "ftyp".

ftyp box payload

16-byte payload after the 8-byte header (total box = 24 bytes). major_brand "M4A ", minor_version 0, compatible_brands "M4A " + "mp42".

the box tree

Typical top-level layout for an M4A audio file. All timing, codec, and tag metadata lives inside moov; raw samples live in mdat.

ftyp  brand declaration (first box in file)
moov  movie container
├─ mvhd  timescale + duration  (length = duration / timescale)
├─ trak  audio track
│   └─ mdiaminfstbl  sample tables
│        ├─ stsd  codec  ("mp4a" = AAC, "alac" = ALAC)
│        ├─ stts  time-to-sample table
│        ├─ stsc  sample-to-chunk mapping
│        ├─ stsz  per-sample byte sizes
│        └─ stco  chunk offsets into mdat
└─ udtametailst  iTunes tags (title, artist, artwork, BPM ...)
mdat  raw encoded audio samples