mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +00:00
* fix(engine): read PRODUCER_RESTRICT_PAGE_NETWORK's usual spellings and restrict on an unknown value true, 1, yes and on turn the render network restriction on and false, 0, no and off leave it off, in any letter case and with surrounding whitespace. Unset or blank stays off for local renders. Any other value now restricts and logs a warning once, instead of leaving the render browser and ffmpeg URL inputs unrestricted. * fix(producer): on a render service the audio probe reads a composition URL from a downloaded copy With PRODUCER_RESTRICT_PAGE_NETWORK on, a video URL the composition names is fetched through the shared downloader (resolved-address check, pinned connection, per-hop redirect checks) before ffprobe reads it, and skipped if the download is refused. In a distributed audio step the copy lands in the mixer's work folder, so the mix reuses it instead of downloading again. Without the flag the probe reads the URL as before. * fix(engine): on a render service a URL that ffmpeg reads in place must be a self-contained container With PRODUCER_RESTRICT_PAGE_NETWORK on, every https input ffmpeg or ffprobe opens directly (such as a signed storage URL for a project's video or audio sidecar) also gets -format_whitelist with the same self-contained containers the Studio media helpers allow. A playlist, manifest or concat list stored under a media file name can no longer make ffmpeg open other network locations. Local renders are unchanged. * fix(producer): the render-service audio probe skips only refused URLs and downloads once A composition URL is skipped, with one warning, only when the download address rules refuse it. Timeouts, HTTP errors and a cancelled render fail the probe as before. Videos without sound, muted or hidden are not downloaded. The in-process extract stage passes the render's abort signal and the mixer's work folder, so the mix reuses the copy. * fix(producer): unit tests load the orchestrator again; raise the engine size budget audioWorkDir moves to render/shared.ts, so tests that replace the audio stage module still load the orchestrator. The format-whitelist test probe ends its options with -- as the ffprobe argv contract requires. The engine packed size budget rises to 500000 bytes.
@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