// video-encode-lib.ts — DDR-148 in-page MP4/WebM/GIF encoder. // // Runs INSIDE the capture Chromium (bundled to a self-contained module by // _browser-bundles.getEncodeLibBundle, injected via page.addScriptTag). WebCodecs // is guaranteed there — the user's shell browser / WKWebView never encodes. // // The Node shim (bin/_video-playwright.mjs) screenshots each frame, hands the // PNG in as base64, and this lib decodes → draws to an offscreen canvas → // encodes: mediabunny (Output + CanvasSource, H.264/avc in MP4, VP9/VP8 in WebM // as the fallback), or gifenc (quantize → applyPalette). Video codec is chosen // by mediabunny's own capability probe, so a browser without an H.264 encoder // degrades to WebM instead of failing. Audio mixing is added in a follow-up // slice (the comp's