The stbl box maps time to sample, sample to chunk and chunk to file position.
Together they tell a reader where every sample is and when it plays. Layouts come from
memory of ISO/IEC 14496-12; offsets are from the end of the full box header.
stsd: sample descriptions
A 4-byte entry_count, then that many sample entries, each a box whose type
is a sample entry code. Each starts
with 6 reserved bytes and a 2-byte data_reference_index. A video or audio
entry then has the fields below, and child boxes such as avcC,
hvcC or esds hold the codec configuration.
| Size | Video sample entry | Size | Audio sample entry |
|---|---|---|---|
| 2 | pre_defined | 8 | reserved |
| 2 | reserved | 2 | channelcount |
| 12 | pre_defined | 2 | samplesize |
| 2 | width | 2 | pre_defined |
| 2 | height | 2 | reserved |
| 4 | horizresolution, 16.16, usually 72 | 4 | samplerate, 16.16 |
| 4 | vertresolution, 16.16 | ||
| 4 | reserved | ||
| 2 | frame_count, 1 | ||
| 32 | compressorname | ||
| 2 | depth, usually 24 | ||
| 2 | pre_defined, −1 |
Time tables
| Box | Fields | Meaning |
|---|---|---|
stts | entry_count (4); entries of sample_count (4), sample_delta (4) | Decoding time to sample. Runs of samples with the same duration. |
ctts | entry_count (4); entries of sample_count (4), sample_offset (4, signed in version 1) | Composition offset: presentation time = decoding time + offset. For B-frames. |
cslg | compositionToDTSShift, leastDecodeToDisplayDelta, greatestDecodeToDisplayDelta, compositionStartTime, compositionEndTime (each 4, or 8 in version 1) | Relates the composition and decoding timelines. |
stss | entry_count (4); sample_number (4) each | Sync samples (key frames). If absent, every sample is a sync sample. |
stsh | entry_count (4); shadowed_sample_number (4), sync_sample_number (4) | Shadow sync samples. |
stdp | One 2-byte priority per sample | Sample degradation priority. |
sdtp | One byte per sample | Bits: 7-6 is_leading, 5-4 sample_depends_on, 3-2 sample_is_depended_on, 1-0 sample_has_redundancy. |
Position tables
| Box | Fields | Meaning |
|---|---|---|
stsc | entry_count (4); first_chunk (4), samples_per_chunk (4), sample_description_index (4) | Sample to chunk. Each entry applies from first_chunk until the next entry. |
stsz | sample_size (4), sample_count (4); if sample_size is 0, entry_size (4) per sample | Sample sizes. A non-zero sample_size means all samples are that size. |
stz2 | reserved (3), field_size (1: 4, 8 or 16 bits), sample_count (4), sizes packed at that width | Compact sample sizes. |
stco | entry_count (4); chunk_offset (4) each | Chunk offsets in the file. |
co64 | entry_count (4); chunk_offset (8) each | 64-bit chunk offsets. |
padb | sample_count (4), then bits per sample | Sample padding bits. |
To find sample n: use stsc to find its chunk, stco for
the chunk’s offset, and add the sizes of the earlier samples in the chunk from
stsz.
Sample groups and auxiliary data
| Box | Fields |
|---|---|
sbgp | grouping_type (4), grouping_type_parameter (4, version 1), entry_count (4); sample_count (4), group_description_index (4) |
sgpd | grouping_type (4), default_length (4, version 1), default_sample_description_index (4, version 2), entry_count (4); description entries |
subs | Sub-sample information |
saiz, saio | Sample auxiliary information sizes and offsets |