pup-recorder 0.4.7 → 0.4.9
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 +57 -38
- package/assets/logo.png +0 -0
- package/build.ts +2 -1
- package/dist/app.cjs +5 -5
- package/dist/chunk-SMSS3H5W.js +4 -0
- package/dist/cli.js +2 -2
- package/dist/index.js +1 -1
- package/dist/runtime/render_preload.cjs +2 -0
- package/dist/runtime/shoot_preload.cjs +3 -0
- package/package.json +10 -10
- package/dist/chunk-LQ5XNASZ.js +0 -4
- package/dist/runtime/iframe_preload.cjs +0 -3
package/README.md
CHANGED
|
@@ -1,55 +1,74 @@
|
|
|
1
|
-
|
|
1
|
+

|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Render a web page to video. Loads a URL, local file, or `data:` document in headless Electron and captures it to `.mp4` / `.webm`, with hardware HEVC-alpha encoding, optional audio, and a deterministic mode for reproducible output.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Features
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- Headless offscreen rendering — no display server.
|
|
8
|
+
- Two modes: real-time recording, or deterministic frame-by-frame (same input, same bytes).
|
|
9
|
+
- Hardware HEVC-alpha encode via NVENC or VideoToolbox, software fallback.
|
|
10
|
+
- Alpha preserved end to end.
|
|
11
|
+
- Optional audio, AAC.
|
|
8
12
|
|
|
9
|
-
|
|
10
|
-
[--disable-gpu] [--disable-hw-codec] [--window-tolerant]
|
|
11
|
-
[--use-inner-proxy]
|
|
13
|
+
## Install
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
-W, --width <number> default: 1920
|
|
17
|
-
-H, --height <number> default: 1080
|
|
18
|
-
-f, --fps <number> default: 30
|
|
19
|
-
-t, --duration <number> default: 5 (seconds)
|
|
20
|
-
-o, --out-file <path> default: output.mp4
|
|
21
|
-
-a, --with-audio
|
|
22
|
-
-d, --deterministic frame-by-frame via CDP virtual time
|
|
23
|
-
--use-inner-proxy Bilibili inner proxy
|
|
24
|
-
--disable-gpu force SwiftShader software rendering
|
|
25
|
-
--disable-hw-codec software x265 instead of NVENC/VideoToolbox
|
|
26
|
-
--window-tolerant accept dom-ready when did-stop-loading hangs
|
|
27
|
-
|
|
28
|
-
## ENVIRONMENT
|
|
15
|
+
```sh
|
|
16
|
+
bun add pup-recorder
|
|
17
|
+
```
|
|
29
18
|
|
|
30
|
-
|
|
31
|
-
PUP_USE_INNER_PROXY 1=on
|
|
32
|
-
PUP_DISABLE_GPU 1=on
|
|
33
|
-
PUP_DISABLE_HW_CODEC 1=on
|
|
34
|
-
PUP_DETERMINISTIC 1=on
|
|
35
|
-
PUP_WINDOW_TOLERANT 1=on
|
|
19
|
+
Bundles Electron and a prebuilt `node-av` (FFmpeg) — no system FFmpeg or Chrome.
|
|
36
20
|
|
|
37
|
-
|
|
21
|
+
Runs on macOS, Linux, and Windows (x64 + arm64). Hardware encode uses VideoToolbox on macOS and NVENC on Linux/Windows with an NVIDIA GPU; a software encoder covers everything else.
|
|
38
22
|
|
|
39
23
|
## API
|
|
40
24
|
|
|
41
25
|
```ts
|
|
42
26
|
import { pup } from "pup-recorder";
|
|
43
27
|
|
|
44
|
-
const result = await pup(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
28
|
+
const result = await pup("https://example.com", {
|
|
29
|
+
fps: 30,
|
|
30
|
+
duration: 10,
|
|
31
|
+
deterministic: true,
|
|
32
|
+
outFiles: ["out/demo.mp4", "out/demo.webm"],
|
|
33
|
+
onProgress: (pct) => console.log(pct),
|
|
34
|
+
signal: AbortSignal.timeout(120_000),
|
|
49
35
|
});
|
|
50
|
-
|
|
36
|
+
|
|
37
|
+
result.outFiles; // video paths
|
|
38
|
+
result.written; // frames encoded
|
|
39
|
+
result.blank; // blank-frame ratio
|
|
40
|
+
result.screenshots; // PNG paths
|
|
51
41
|
```
|
|
52
42
|
|
|
53
|
-
|
|
43
|
+
All options default; pass only overrides. `signal` cancels a run; `onProgress` streams 0–100.
|
|
44
|
+
|
|
45
|
+
## CLI
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
pup https://example.com -o out/demo.mp4 # real-time
|
|
49
|
+
pup https://example.com -t 10 -d -o out/demo.mp4 # deterministic, 10s
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`<source>` is an `http(s)://`, `file://`, `data:` URI, or path. Outputs are comma-separated; the extension picks the encoder (`.mp4` → HEVC+AAC, `.webm` → VP9). Key flags: `-W`/`-H` size, `-f` fps, `-t` duration, `-d` deterministic, `-a` audio, `-S` screenshot marks. Full list: `pup --help`.
|
|
53
|
+
|
|
54
|
+
## How it works
|
|
55
|
+
|
|
56
|
+
pup-recorder runs as two processes: a parent owning the CLI/API and lifecycle, and an Electron subprocess doing offscreen render + encode, over IPC.
|
|
57
|
+
|
|
58
|
+
Electron loads the page into a headless offscreen `BrowserWindow`; each frame arrives as a BGRA bitmap and feeds the encoder: BGRA → HEVC-with-alpha (NVENC / VideoToolbox, or software x265) → `.mp4`; VP9 for `.webm`.
|
|
59
|
+
|
|
60
|
+
The two modes differ in *when* a frame is captured.
|
|
61
|
+
|
|
62
|
+
**Real-time (default).** The page runs on the real clock; `paint` events are muxed at wall-clock speed. For content whose timing you don't control (`<video>`, live WebGL). Drops frames if the machine can't keep up.
|
|
63
|
+
|
|
64
|
+
**Deterministic (`-d`).** Fakes time and advances it one frame at a time. Hooks `requestAnimationFrame`, `setTimeout`/`setInterval`, `Date`, `performance.now`, `getAnimations`, and steps the compositor clock by `1/fps` (`advanceVirtualTime`). Frame N is computed at exactly `N/fps` regardless of CPU time — reproducible, no dropped frames, cache-keyable by input hash.
|
|
65
|
+
|
|
66
|
+
**Frame sync.** A 1-pixel row at the bottom of each frame encodes the intended timestamp; the capturer decodes it off the bitmap and rejects any frame that doesn't match, defeating compositor coalescing and off-by-one capture.
|
|
67
|
+
|
|
68
|
+
## Production
|
|
69
|
+
|
|
70
|
+
pup-recorder is the core rendering engine of [花生AI](https://www.huasheng.cn/), driving ~1.7M video exports a day at five-nines (99.999%) reliability. Its direction is driven solely by production needs [at bilibili](https://jobs.bilibili.com/), reasoned from first principles — not by backward compatibility. Expect breaking changes; pin a version.
|
|
71
|
+
|
|
72
|
+
## License
|
|
54
73
|
|
|
55
|
-
|
|
74
|
+
MIT © 2026 Autokaka
|
package/assets/logo.png
ADDED
|
Binary file
|