Skip to content

Function: readAudioSampleEntry() ​

ts
function readAudioSampleEntry<T, V>(cursor, type): AudioSampleEntry<T, V>;

Defined in: readers/readAudioSampleEntry.ts:27

Read an audio sample entry box (AudioSampleEntry) of the given type.

ISO/IEC 14496-12:2015 - 12.2.3

The readers map takes the function under a key of IsoBoxMap, such as ac-3 or ec-3. For a box type that the package does not name, add the box type to IsoCustomBoxMap first.

Type Parameters ​

T ​

T extends string

V ​

V extends IsoInt64

Parameters ​

cursor ​

IsoBoxReadCursor<V>

The read cursor at the first byte after the box header

type ​

T

The type of AudioSampleEntry to read

Returns ​

AudioSampleEntry<T, V>

A parsed AudioSampleEntry

Example ​

ts
const isoFile = await readFile(new URL('../fixtures/SRMP_AC4.mp4', import.meta.url))
const boxes = readIsoBoxes(isoFile, {
	readers: {
		stsd: readStsd,
		'ac-4': readAudioSampleEntry,
	},
})

const stsd = findIsoBox(boxes, box => isIsoBoxType('stsd', box))

// `stsd.boxes` can hold any sample entry, so give the entry its type.
const entry = stsd?.boxes[0] as AudioSampleEntry<'ac-4'> | undefined

A Streaming Video Technology Alliance project.