Skip to content

Function: writeIsoBoxes() ​

ts
function writeIsoBoxes(boxes, config): Uint8Array<ArrayBuffer>[];

Defined in: libs/iso-bmff/src/writeIsoBoxes.ts:19

Writes ISO boxes to an array of Uint8Array, one per box.

Parameters ​

boxes ​

Iterable<IsoBoxStreamable>

The boxes to write

config ​

IsoBoxWriteViewConfig

The configuration for the writer

Returns ​

Uint8Array<ArrayBuffer>[]

The written boxes. A box given as a view over a SharedArrayBuffer is copied, so each result is backed by an ArrayBuffer.

Example ​

ts
const isoFile = await readFile(new URL('./fixtures/captions.mp4', import.meta.url))

const boxes = readIsoBoxes(new Uint8Array(isoFile), {
	readers: {
		ftyp: readFtyp,
	},
})

const bytes = writeIsoBoxes(boxes, {
	writers: {
		ftyp: writeFtyp,
	},
})

deepEqual(isoFile, reduceUint8Arrays(bytes))

A Streaming Video Technology Alliance project.