mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-16 22:58:02 +00:00
Re-measured the four rows flagged slower-than-baseline with matched conditions (3 reps, medians). Two were stale-baseline artifacts: style-7 macOS is actually 1.12x FASTER (19.9s vs 22.4s) and raf-ball macOS is exactly 1.00x. variables-prod Docker is within the noise band (6.8s vs 6.5s across runs spanning 6.4-10.7s). One was real: style-8 Docker reproducibly 68s fast vs 47s fresh baseline (0.69x). Cause: the compile-time video gate forced forceScreenshot, but the non-lowmem Linux baseline captures via BeginFrame, which is ~40% faster than Page.captureScreenshot on SwiftShader. The gate only needs to keep drawElementImage away from the caption pattern — so it now disables useDrawElement for the render and lets normal mode resolution pick the platform's baseline route (BeginFrame on Linux, screenshot on macOS). Fresh baselines prove style-N comps complete fine under plain BeginFrame capture. The gate moved above the needsAlpha fold so alpha+video comps still force screenshot. Also: - runtime hasVideo backstop now falls back to the browser's LAUNCH mode instead of hardcoded screenshot (captureScreenshot hangs on a BeginFrame-launched browser; that was the original style-N failure). - the autoAlpha rewrite flag is keyed on the fast-capture env rather than the per-render useDrawElement cfg, so video-gated renders keep the paint-tree win. style-8 Docker fast: 68.2s -> 46.6/47.6s (parity with 44.8-49.0s baseline), 54.1 dB. mac style-7: 54.4 dB unchanged. Alpha fast path still drawElement at rgba PSNR = inf. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@hyperframes/engine
Seekable web-page-to-video rendering engine built on Puppeteer and FFmpeg.
Framework-agnostic: works with GSAP, Lottie, Three.js, CSS animations, or any web content that implements the window.__hf seek protocol.
Install
npm install @hyperframes/engine
Requirements: Node.js >= 22, Chrome/Chromium (auto-downloaded by Puppeteer), FFmpeg
What it does
The engine opens your HTML composition in a headless Chrome instance, seeks frame-by-frame using Chrome's HeadlessExperimental.beginFrame API, captures screenshots, and encodes them into video with FFmpeg.
Key services
| Service | Description |
|---|---|
| browserManager | Launches and pools headless Chrome instances (chrome-headless-shell) |
| frameCapture | Manages capture sessions — seek, screenshot, buffer lifecycle |
| screenshotService | BeginFrame-based capture with CDP (Chrome DevTools Protocol) |
| chunkEncoder | FFmpeg encoding with chunked concat, GPU detection, faststart |
| streamingEncoder | Pipe frames to FFmpeg in real time (no intermediate PNGs on disk) |
| audioMixer | Parse <audio> elements and mix audio tracks via FFmpeg |
| videoFrameExtractor | Extract frames from <video> elements for compositing |
| parallelCoordinator | Split frame ranges across worker processes |
| fileServer | Serve local HTML files to the browser via Hono |
Usage
import {
acquireBrowser,
releaseBrowser,
createCaptureSession,
initializeSession,
captureFrame,
closeCaptureSession,
} from "@hyperframes/engine";
// 1. Launch browser
const browser = await acquireBrowser({ captureMode: "beginFrame" });
// 2. Open a capture session
const session = createCaptureSession({
browser: browser.browser,
url: "http://localhost:3000/my-composition.html",
width: 1920,
height: 1080,
fps: 30,
});
await initializeSession(session);
// 3. Capture frames
for (let i = 0; i < totalFrames; i++) {
await captureFrame(session, i, `/tmp/frames/frame-${i}.png`);
}
// 4. Clean up
await closeCaptureSession(session);
await releaseBrowser(browser);
Most users should use @hyperframes/producer or the hyperframes CLI instead of calling the engine directly.
Documentation
Full documentation: hyperframes.heygen.com/packages/engine
Related packages
@hyperframes/core— types, parsers, frame adapters@hyperframes/producer— high-level render pipeline built on this enginehyperframes— CLI