Function: resolveTrunSamples()
Call Signature
function resolveTrunSamples(
trun,
tfhd,
trex
): Required<ResolvedTrackRunSample>[];Defined in: utils/resolveTrunSamples.ts:70
Resolves the fields of each sample of a trun box from the defaults of the tfhd box and the trex box.
ISO/IEC 14496-12:2015 - 8.8.8.1
A sample field of the trun box has priority. A missing field takes the default of the tfhd box, then the default of the trex box. firstSampleFlags of the trun box replaces the default flags of the first sample only. A missing composition time offset is 0.
The trex box is the one of the track of the fragment: tfhd.trackId === trex.trackId. The function does not check the track.
The function creates one object for each sample, also for a box with sampleCount and no samples. The size of that box sets no limit on sampleCount. For data from the network, check sampleCount before the call.
The function reads only the three default fields of the tfhd box and the trex box. Each parameter also accepts an object with only those fields.
Parameters
trun
The trun box.
tfhd
| TrackRunSampleDefaults & object | null | undefined
The tfhd box of the same traf box, or its sample defaults, or null. An object with a type field must have the type 'tfhd'.
trex
Required<TrackRunSampleDefaults> & object
The trex box of the track, from the moov box, or its three sample defaults. An object with a type field must have the type 'trex'.
Returns
Required<ResolvedTrackRunSample>[]
One object for each sample of the trun box, in the order of the box. Every field is a number.
Example
const trex = findBox('test_frag.mp4', 'trex', { readers: { trex: readTrex } })
const tfhd = findBox('test_frag.mp4', 'tfhd', { readers: { tfhd: readTfhd } })
const trun = findBox('test_frag.mp4', 'trun', { readers: { trun: readTrun } })
const samples = resolveTrunSamples(trun, tfhd, trex)
const duration = samples.reduce((sum, sample) => sum + sample.sampleDuration, 0)Call Signature
function resolveTrunSamples(
trun,
tfhd?,
trex?
): ResolvedTrackRunSample[];Defined in: utils/resolveTrunSamples.ts:93
Resolves the fields of each sample of a trun box from the defaults of the tfhd box, with no trex box.
ISO/IEC 14496-12:2015 - 8.8.8.1
A sample field of the trun box has priority. A missing field takes the default of the tfhd box. A field with no value in a box is undefined. A missing composition time offset is 0.
The function creates one object for each sample, also for a box with sampleCount and no samples. The size of that box sets no limit on sampleCount. For data from the network, check sampleCount before the call.
Parameters
trun
The trun box.
tfhd?
| TrackRunSampleDefaults & object | null
The tfhd box of the same traf box, or its sample defaults. The parameter is optional and accepts null. An object with a type field must have the type 'tfhd'.
trex?
| TrackRunSampleDefaults & object | null
The trex box of the track, or its sample defaults. The parameter is optional and accepts null. An object with a type field must have the type 'trex'.
Returns
One object for each sample of the trun box, in the order of the box.