UNPKG

@omnimedia/omnitool

Version:

open source video processing tools

26 lines 1.1 kB
import { CursorVisualSampler } from "./cursor.js"; import { fixedStep } from "../../parts/schedulers.js"; import { computeItemDuration } from "../../parts/handy.js"; export function produceVideo({ timeline, fps, driver, resolveMedia, }) { const stream = new TransformStream(); const writer = stream.writable.getWriter(); const sampler = new CursorVisualSampler(driver, resolveMedia, timeline); const dt = 1 / fps; const duration = computeItemDuration(timeline.rootId, timeline); async function produce() { await fixedStep({ fps, duration }, async (timecode, i) => { const layers = await sampler.next(timecode); const composed = await driver.composite(layers); const frame = new VideoFrame(composed, { timestamp: Math.round(i * dt * 1_000_000), duration: Math.round(dt * 1_000_000) }); await writer.write(frame); composed.close(); }); await writer.close(); } produce(); return stream.readable; } //# sourceMappingURL=produce-video.js.map