Skip to content

Function: traverseIsoBoxes() ​

ts
function traverseIsoBoxes<T>(boxes, config?): Generator<T>;

Defined in: traverseIsoBoxes.ts:16

Traverse ISO boxes

Type Parameters ​

T ​

T

Parameters ​

boxes ​

Iterable<T>

The boxes to traverse

config? ​

TraverseIsoBoxesConfig

Configuration options for traversal

Returns ​

Generator<T>

A generator of boxes

Example ​

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

// Depth-first: each box, then its children.
// A box with no reader is a raw box. Every box has its code in `type`.
const types = Array.from(traverseIsoBoxes(boxes), box => box.type)

// Breadth-first, with the root boxes and their children only.
const levels = Array.from(
	traverseIsoBoxes(boxes, { depthFirst: false, maxDepth: 1 }),
	box => box.type,
)

A Streaming Video Technology Alliance project.