mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +00:00
* fix(engine): headline a pending setup as a setup timeout, not zero duration When the runtime never reaches render-ready, __hf.duration reads 0 because the bridge masks it, so pollHfReady's timeout reported "Composition has zero duration" even for compositions with a declared data-duration whose window.__hf.buildReady promise was still pending. Headline that case as "Composition setup did not finish within <timeout>ms", skip the duration inference hint that cannot apply yet, and note that the render clock stays at 0 until the first frame. Keep its transient retry classification and give it its own CLI diagnostic code. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(engine): name animation frames in the setup-timeout hint Setup that awaits requestAnimationFrame hits the same render-clock rule as setup that waits on Date or performance.now: frames only fire on a seek, and the first seek waits for setup. Say so, and point at the waits that work. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(engine): stop suggesting scheduler.yield() for setup waits Chrome runs scheduler.yield() continuations ahead of ordinary tasks, so a setup loop that polls with it starves the setTimeout-driven work it waits on (Three's compileAsync polls with setTimeout(10)) and never finishes. Plain headless Chrome 152 hangs on a ten-line page that does exactly that. Point authors at setTimeout and say why yield-polling does not work. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(engine): point setup waits at the library's readiness promise HyperFrames guidance is no system timers, so the hint should not tell authors to wait with setTimeout. Point them at the library's own readiness promise (Three.js renderer.compileAsync) and keep the warning about scheduler.yield() polling loops. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(engine): keep the setup-timeout hint to what it can diagnose A scheduler.yield() polling loop starves the page, so the readiness poll never returns and the render reports a capture stall instead of this message. Drop that sentence; the hint covers animation-frame and clock waits only. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <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,
createCaptureSession,
initializeSession,
captureFrame,
closeCaptureSession,
} from "@hyperframes/engine";
// 1. Launch browser
const browserLease = await acquireBrowser({ captureMode: "beginFrame" });
// 2. Open a capture session
const session = createCaptureSession({
browser: browserLease.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 browserLease.release();
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