mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-14 13:27:13 +00:00
9 optimizations targeting the frame capture hot path (86% of total render time): 1. Enable streaming encode by default — overlaps capture with FFmpeg encoding, eliminating the encode stage as a separate step. Saves ~10% wall time. 2. Multi-page shared browser — screenshot-mode workers share a single Chrome process instead of launching N separate browsers. Eliminates N-1 Chrome startup costs (~2-3s each) and shares GPU/cache across pages. 3. Lower streaming JPEG quality (55 vs 80/95) — intermediate frames piped to FFmpeg are re-encoded, so quality loss is invisible in the final output. Smaller buffers transfer faster over CDP, cutting per-frame capture time. 4. Hardware GPU acceleration — replace forced SwiftShader (software renderer) with native GPU (Metal on macOS, Vulkan on Linux). CSS effects like box-shadow, blur, and transforms render 10-100x faster. Falls back to SwiftShader automatically in Docker/CI where no GPU exists. 5. Optimized seek evaluation — string eval replaces function serialization in the per-frame page.evaluate() call, skipping Puppeteer's serialize + Runtime.callFunctionOn overhead. Removes redundant __hf.seek guard that was already validated during session initialization. 6. FFmpeg multi-threading — adds -threads 0 across all encoding paths (streaming, chunk, extraction) to let FFmpeg auto-parallelize. 7. Parallel audio processing — audio extraction now runs concurrently with frame capture instead of blocking it. Audio uses separate FFmpeg processes that don't compete with Chrome for CPU. 8. Hardware-accelerated video extraction — adds -hwaccel auto for H.264 sources and reduces PNG compression from level 6 to 1 (temp files). 9. Tuned parallelism defaults — more aggressive worker allocation (8 max, 2 cores/worker, 24 min frames/worker) suited to modern hardware. All 494 engine tests pass. No regressions.