@hyperframes/producer 0.4.31 → 0.4.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -47,22 +47,72 @@ await startServer({ port: 8080 });
47
47
 
48
48
  `RenderConfig` controls the render pipeline:
49
49
 
50
- | Option | Default | Description |
51
- | ------------ | ------------ | -------------------------------------------------- |
52
- | `inputPath` | — | Path to the HTML composition |
53
- | `outputPath` | — | Output video file path |
54
- | `width` | 1920 | Frame width in pixels |
55
- | `height` | 1080 | Frame height in pixels |
56
- | `fps` | 30 | Frames per second (24, 30, or 60) |
57
- | `quality` | `"standard"` | Encoder preset (`"draft"`, `"standard"`, `"high"`) |
50
+ | Option | Default | Description |
51
+ | ------------ | ------------ | ------------------------------------------------------------------------------------------------------------------------------------ |
52
+ | `inputPath` | — | Path to the HTML composition |
53
+ | `outputPath` | — | Output video file path (or directory, for `format: "png-sequence"`) |
54
+ | `width` | 1920 | Frame width in pixels |
55
+ | `height` | 1080 | Frame height in pixels |
56
+ | `fps` | 30 | Frames per second (24, 30, or 60) |
57
+ | `quality` | `"standard"` | Encoder preset (`"draft"`, `"standard"`, `"high"`) |
58
+ | `format` | `"mp4"` | Output container — `"mp4"`, `"webm"`, `"mov"`, or `"png-sequence"`. See [Transparent Video Output](#transparent-video-output) below. |
59
+
60
+ ## Transparent Video Output
61
+
62
+ The producer can render HTML compositions to formats that carry a **true alpha channel** — not chroma key. The same composition that renders an opaque MP4 renders a layerable overlay when you set `format`.
63
+
64
+ | `format` | Codec / pixel format | Alpha | Audio | Use case |
65
+ | ----------------- | --------------------------------- | ----------------------- | ------------------- | --------------------------------------------------------------------------------------- |
66
+ | `"mp4"` (default) | H.264 (yuv420p) or H.265 + HDR10 | No | AAC | Streaming, social, default deliverable |
67
+ | `"webm"` | VP9 + yuva420p | **True alpha** | Opus | Web playback as overlay (`<video>` over background); supported in Chrome, Edge, Firefox |
68
+ | `"mov"` | ProRes 4444 + yuva444p10le | **True alpha + 10-bit** | AAC | Editor ingest (Premiere, Final Cut Pro, DaVinci Resolve) |
69
+ | `"png-sequence"` | Numbered RGBA PNGs in a directory | **Lossless alpha** | Sidecar `audio.aac` | After Effects / Nuke / Fusion, or pipelines that post-process frames before encoding |
70
+
71
+ ### Example
72
+
73
+ ```typescript
74
+ import { createRenderJob, executeRenderJob } from "@hyperframes/producer";
75
+
76
+ const job = createRenderJob({
77
+ inputPath: "./my-composition.html",
78
+ outputPath: "./output.webm", // or a directory for "png-sequence"
79
+ width: 1080,
80
+ height: 1920,
81
+ fps: 30,
82
+ format: "webm", // "mp4" | "webm" | "mov" | "png-sequence"
83
+ });
84
+
85
+ await executeRenderJob(job);
86
+ ```
87
+
88
+ ### What "transparent background" means here
89
+
90
+ The producer captures Chrome screenshots with the page background forced transparent (`html, body, [data-composition-id] { background: transparent !important }`) and the CDP default background override set to RGBA 0,0,0,0. The captured PNGs carry a real alpha channel and that channel is preserved end-to-end:
91
+
92
+ - VP9 (`webm`) is encoded with `-pix_fmt yuva420p`, `-auto-alt-ref 0`, and `alpha_mode=1` metadata.
93
+ - ProRes 4444 (`mov`) is encoded with `-pix_fmt yuva444p10le`.
94
+ - PNG sequences are written without re-encoding (zero-padded `frame_NNNNNN.png`).
95
+
96
+ This is not chroma keying. There is no green/blue background to remove and no "key" tolerance to tune — pixels that were transparent in the browser are transparent in the output.
97
+
98
+ ### Caveats
99
+
100
+ - **Linux + alpha forces screenshot capture.** Chrome's BeginFrame compositor (the default deterministic capture path on Linux headless-shell) does not preserve alpha; the orchestrator falls back to `Page.captureScreenshot`, which is slower per frame. macOS and Windows already use screenshot mode by default, so they are unaffected.
101
+ - **HDR + alpha is not supported.** Setting `hdr: true` together with an alpha-capable format logs a warning and falls back to SDR. Use `format: "mp4"` for HDR10 output.
102
+ - **`png-sequence` does not produce a single muxed file.** When the composition contains audio elements, an `audio.aac` sidecar is written alongside the PNGs in `outputPath`.
103
+ - **Safari + WebM alpha is incomplete.** For broad browser playback of an alpha video, ship `format: "mov"` to your editor and re-encode for the codec your distribution target supports.
104
+
105
+ ### Authoring transparent compositions
106
+
107
+ Don't paint a fullscreen background in your HTML. The default body background is overridden to transparent automatically — any `body { background: ... }`, `#root { background: ... }`, or `[data-composition-id] { background: ... }` rule is force-overridden during alpha rendering. Backgrounds on inner elements (cards, scenes, components) are kept.
58
108
 
59
109
  ## How it works
60
110
 
61
111
  1. **Serve** — spins up a local file server for the HTML composition
62
- 2. **Capture** — opens the page in headless Chrome, seeks frame-by-frame via `HeadlessExperimental.beginFrame`, captures screenshots
63
- 3. **Encode** — pipes frames through FFmpeg (with GPU encoder detection and chunked concat)
64
- 4. **Mix** — extracts `<audio>` elements and mixes them into the final video
65
- 5. **Finalize** — applies faststart for streaming-friendly MP4
112
+ 2. **Capture** — opens the page in headless Chrome, seeks frame-by-frame via `HeadlessExperimental.beginFrame` (or `Page.captureScreenshot` for transparent / non-Linux renders), captures screenshots
113
+ 3. **Encode** — pipes frames through FFmpeg (with GPU encoder detection and chunked concat). Skipped for `format: "png-sequence"`.
114
+ 4. **Mix** — extracts `<audio>` elements and mixes them into the final video. For `png-sequence`, audio is written as an `audio.aac` sidecar.
115
+ 5. **Finalize** — applies faststart for streaming-friendly MP4 (no-op for WebM, MOV, and `png-sequence`)
66
116
 
67
117
  ## Documentation
68
118
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": "0.1.0",
3
3
  "buildId": "dev",
4
- "sha256": "02ce520fe0364b7b393d65fa561bdeec3e5576646a4d01d97f8fad0f94433294",
4
+ "sha256": "088a29111ad766eb7230320826bda314a8cc8b87a7e667cac1ba4f479112a473",
5
5
  "artifacts": {
6
6
  "iife": "hyperframe.runtime.iife.js",
7
7
  "esm": "hyperframe.runtime.mjs"