Skip to content

Function: writeStsd() ​

ts
function writeStsd(cursor, box): void;

Defined in: writers/writeStsd.ts:24

Write the stsd box (SampleDescriptionBox).

The writer writes the sample entries with the writers of the cursor.

Parameters ​

cursor ​

IsoBoxWriteCursor

The write cursor

box ​

SampleDescriptionBox<IsoInt64>

The SampleDescriptionBox fields to write

Returns ​

void

Throws ​

RangeError if a value of the box does not fit its field.

Example ​

ts
const box = {
	type: 'stsd' as const,
	version: 0,
	flags: 0,
	entryCount: 1,
	boxes: [
		{
			type: 'mp4a' as const,
			channelCount: 2,
			dataReferenceIndex: 1,
			preDefined: 65534,
			sampleRate: 48000,
			sampleSize: 16,
			boxes: [
				{
					type: 'esds',
					bytes: new Uint8Array([
						0, 0, 0, 50, 101, 115, 100, 115, 0, 0, 0, 0, 3, 128, 128, 34, 0, 0, 0, 4, 128, 128,
						22, 64, 21, 0, 32, 0, 0, 1, 244, 0, 0, 1, 244, 0, 5, 128, 128, 5, 17, 144, 0, 0, 0,
						6, 128, 128, 1, 2,
					]),
				},
			],
			// size: 86
		},
	],
}

const writer = writeIsoBox(box, {
	writers: {
		mp4a: writeMp4a,
		stsd: writeStsd,
	},
})
const buffer = new Uint8Array(writer.buffer)

A Streaming Video Technology Alliance project.