The media atom, mdia, inside each trak, says what kind of media
the track holds, its time scale and language, and where its samples are. Do not confuse it
with mdat, which holds the samples themselves. Offsets count from the start of
each atom.
mdia
| Child | Meaning |
|---|---|
mdhd | Media header. Required. |
elng | Extended language tag; follows mdhd. |
hdlr | Handler reference: the kind of media. Must come before minf. |
minf | Media information, whose contents depend on the handler. |
udta | User data. |
mdhd
| Offset | Size | Type | Name | Meaning |
|---|---|---|---|---|
| 8 | 1 | uint8 | version | 0. |
| 9 | 3 | bits | flags | 0. |
| 12 | 4 | uint32 | creation time | Seconds since 1 January 1904, preferably UTC. |
| 16 | 4 | uint32 | modification time | Same format. |
| 20 | 4 | uint32 | time scale | Time units per second for this media; for sound usually the sample rate. |
| 24 | 4 | uint32 | duration | Length of the media in its own time scale. |
| 28 | 2 | uint16 | language | Macintosh language code or packed ISO 639-2/T code; see Language codes. With elng, the closest plain code (such as eng for en-AU), or und. |
| 30 | 2 | int16 | quality | Playback quality: how suitable the media is for a given environment. |
The atom is 32 bytes. An ISO-style version 1 has 64-bit times and duration.
elng
| Offset | Size | Name | Meaning |
|---|---|---|---|
| 8 | 1 | version | 0. |
| 9 | 3 | flags | 0. |
| 12 | varies | language tag string | Null-terminated ASCII BCP 47 (RFC 4646) tag such as en-US, fr-CA or zh-Hant. |
At most one per media. It overrides the mdhd language when the two
disagree. Tags are not validated, so a reader should treat a bad tag as no tag.
hdlr
| Offset | Size | Name | Meaning |
|---|---|---|---|
| 8 | 1 | version | 0. |
| 9 | 3 | flags | 0. |
| 12 | 4 | component type | mhlr media handler or dhlr data handler. Files that follow ISO often write 0 here. |
| 16 | 4 | component subtype | For a media handler, the media type (table below). For a data handler, the data reference type, such as alis. |
| 20 | 4 | component manufacturer | Reserved, 0. |
| 24 | 4 | component flags | Reserved, 0. |
| 28 | 4 | component flags mask | Reserved, 0. |
| 32 | varies | component name | A counted (Pascal) string naming the handler that made the media; may be empty. ISO-style files write a null-terminated string instead. |
Apple says the data handler use is historical: the hdlr inside
mdia describes the media.
| Media type | Media | minf header |
|---|---|---|
vide | Video | vmhd |
soun | Sound | smhd |
meta | Timed metadata | gmhd |
tmcd | Timecode | gmhd with tcmi |
text | Text | gmhd with text |
clcp | Closed captions | gmhd |
sbtl | Subtitles (Apple’s subtitle media). Apple’s hdlr page also names subt, the ISO subtitle type. | gmhd |
musi | Music | gmhd |
MPEG | MPEG-1 muxed stream | gmhd |
sprt | Sprite (deprecated) | gmhd |
twen | Tween (deprecated) | gmhd |
qd3d | QuickDraw 3D (deprecated) | gmhd |
hint | Hint track for streaming | gmhd |
strm | Streaming | gmhd |
Apple states the base header for timed metadata, text, MPEG, timecode, music, hint and 3D media. For closed captions, subtitles, sprites, tweens and streaming the table follows the same rule, which Apple does not spell out. Movie media (an embedded movie, since QuickTime 4.1) and QuickTime VR also exist; Apple’s pages do not state their media type codes.
minf
A container whose first child is the header for its media kind, then a handler reference,
data information and sample table. The hdlr inside minf is the
data handler; stbl is described on Sample
tables.
| Media | Children |
|---|---|
| Video | vmhd (required), hdlr (required), dinf, stbl |
| Sound | smhd (required), hdlr (required), dinf, stbl |
| Base (all others) | gmhd (required), and normally hdlr, dinf, stbl |
vmhd
| Offset | Size | Name | Meaning |
|---|---|---|---|
| 8 | 1 | version | 0. |
| 9 | 3 | flags | 0x0001 “no lean ahead”: set in every file except those meant for QuickTime 1.0. |
| 12 | 2 | graphics mode | How the track is drawn over what is behind it; see Graphics modes. |
| 14 | 6 | opcolor | Red, green, blue (uint16 each) used by modes that need a colour. |
smhd
| Offset | Size | Name | Meaning |
|---|---|---|---|
| 8 | 1 | version | 0. |
| 9 | 3 | flags | 0. |
| 12 | 2 | balance | 8.8 fixed, −1.0 left to +1.0 right, normally 0; see Balance. |
| 14 | 2 | reserved | 0. |
gmhd and gmin
The base media information header, gmhd, is a container holding the
required base media info atom gmin, and for text media a text media
information atom text (an identity matrix, 36 bytes), or for timecode media
the timecode media information atom tcmi (see
Timecode).
| Offset | Size | Name | Meaning |
|---|---|---|---|
| 8 | 1 | version | 0. |
| 9 | 3 | flags | 0. |
| 12 | 2 | graphics mode | As in vmhd. |
| 14 | 6 | opcolor | Red, green, blue. |
| 20 | 2 | balance | As in smhd. |
| 22 | 2 | reserved | 0. |
dinf and dref
dinf holds one data reference atom, dref, listing where the
samples are. Each sample description picks one entry by its 1-based data reference
index.
| Offset | Size | Name | Meaning |
|---|---|---|---|
| 8 | 1 | version | 0. |
| 9 | 3 | flags | 0. |
| 12 | 4 | number of entries | Data references that follow. |
| 16 | varies | data references | Each formatted like an atom, below. |
| Offset | Size | Name | Meaning |
|---|---|---|---|
| 0 | 4 | size | Bytes in this data reference. |
| 4 | 4 | type | Data reference type, below. |
| 8 | 1 | version | 0. |
| 9 | 3 | flags | 0x0001 self reference: the data is in the same file as the movie atom (on multi-fork file systems, even in another fork). Then there is no data. |
| 12 | varies | data | The reference itself. |
| Type | Data |
|---|---|
alis | A Macintosh alias record, including the target’s full path. The usual type, with the self-reference flag set and no data. |
rsrc | A Macintosh alias followed by a resource type (uint32) and ID (int16). Deprecated. |
url | A null-terminated URL, possibly followed by more data. |