🎥 Make videos programmatically with React
import type {RiffStructure, StrhBox} from './riff-box';
import {getStrhBox, getStrlBoxes} from './traversal';
export const getStrhForIndex = (
structure: RiffStructure,
trackId: number,
): StrhBox => {
const boxes = getStrlBoxes(structure);
const box = boxes[trackId];
if (!box) {
throw new Error('Expected box');
}
const strh = getStrhBox(box.children);
if (!strh) {
throw new Error('strh');
}
return strh;
};