Skip to content

Function: createIsoBoxReadableStream() ​

ts
function createIsoBoxReadableStream(boxes, config): ReadableStream<Uint8Array<ArrayBufferLike>>;

Defined in: libs/iso-bmff/src/createIsoBoxReadableStream.ts:18

Creates a ReadableStream of ISO BMFF boxes as Uint8Arrays.

Parameters ​

boxes ​

Iterable<IsoBoxStreamable>

The boxes to stream.

config ​

IsoBoxWriteViewConfig

The configuration for the stream.

Returns ​

ReadableStream<Uint8Array<ArrayBufferLike>>

A new IsoBoxReadableStream.

Example ​

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

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

const stream = createIsoBoxReadableStream(boxes, {
	writers: {
		ftyp: writeFtyp,
	},
})

const copy = join(tmpdir(), 'captions-copy.mp4')
await stream.pipeTo(Writable.toWeb(createWriteStream(copy)))

equal(Buffer.compare(isoFile, await readFile(copy)), 0)

A Streaming Video Technology Alliance project.