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).
Every MP4 is a flat sequence of top-level boxes; moov holds the entire metadata tree.
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.
Payload is zeroed or arbitrary. Sized to let moov be rewritten in place without moving stco sample offsets into mdat.
8 bytes before every box. Example: 00 00 00 18 66 74 79 70 = size 24, type "ftyp".
16-byte payload after the 8-byte header (total box = 24 bytes). major_brand "M4A ", minor_version 0, compatible_brands "M4A " + "mp42".
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
│ └─ mdia › minf › stbl 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
└─ udta › meta › ilst iTunes tags (title, artist, artwork, BPM ...)
mdat raw encoded audio samples