A fragmented file puts the sample information in repeated moof boxes, each
followed by mdat, instead of in one moov. That is how DASH and CMAF
segments and live recordings work. These layouts come from memory of ISO/IEC 14496-12, which
could not be read.
In moov: mvex
| Box | Fields |
|---|---|
mehd | fragment_duration (4 or 8): the overall duration. |
trex | track_ID (4), default_sample_description_index (4), default_sample_duration (4), default_sample_size (4), default_sample_flags (4). |
leva | Level assignment. |
trep | Track extension properties. |
In moof
| Box | Fields |
|---|---|
mfhd | sequence_number (4). |
traf | Container for one track’s fragment: tfhd, tfdt, trun, and optionally sbgp, sgpd, subs, saiz, saio, senc. |
tfdt | baseMediaDecodeTime (4 in version 0, 8 in version 1). |
tfhd: track fragment header
A track_ID (4), then these optional fields in order, each present if its flag is set.
| Flag | Field | Size |
|---|---|---|
000001 | base_data_offset | 8 |
000002 | sample_description_index | 4 |
000008 | default_sample_duration | 4 |
000010 | default_sample_size | 4 |
000020 | default_sample_flags | 4 |
010000 | duration-is-empty: no samples in this fragment | none |
020000 | default-base-is-moof: offsets are from the start of the moof | none |
trun: track fragment run
A sample_count (4), then optionally data_offset (4, signed, flag 000001)
and first_sample_flags (4, flag 000004). Then for each sample, whichever of
these are flagged:
| Flag | Field | Size |
|---|---|---|
000100 | sample_duration | 4 |
000200 | sample_size | 4 |
000400 | sample_flags | 4 |
000800 | sample_composition_time_offset | 4, signed in version 1 |
Sample flags
| Bits | Name |
|---|---|
| 31-28 | reserved |
| 27-26 | is_leading |
| 25-24 | sample_depends_on |
| 23-22 | sample_is_depended_on |
| 21-20 | sample_has_redundancy |
| 19-17 | sample_padding_value |
| 16 | sample_is_non_sync_sample |
| 15-0 | sample_degradation_priority |
Segment boxes
| Box | Fields |
|---|---|
styp | As ftyp. |
sidx | reference_ID (4), timescale (4), earliest_presentation_time and first_offset (each 4 or 8), reserved (2), reference_count (2); each reference: reference_type (1 bit), referenced_size (31 bits), subsegment_duration (4), starts_with_SAP (1 bit), SAP_type (3 bits), SAP_delta_time (28 bits). |
ssix | Sub-segment index. |
prft | Producer reference time. |
emsg | Event message. Version 0: scheme_id_uri, value, timescale, presentation_time_delta, event_duration, id, message_data. Version 1: timescale, presentation_time (8), event_duration, id, scheme_id_uri, value, message_data. |
Random access: mfra
| Box | Fields |
|---|---|
tfra | track_ID (4), reserved (26 bits), length_size_of_traf_num, length_size_of_trun_num and length_size_of_sample_num (2 bits each), number_of_entry (4); entries of time and moof_offset (each 4 or 8), then traf_number, trun_number and sample_number at the given sizes. |
mfro | size (4), the total size of the mfra box, so a reader can find it from the end of the file. |