Write HTML. Render video. Built for agents.
JavaScript aiai-agentsanimationclaude-codeffmpegframeworkgsaphtmlhtml-to-videomcpmotion-graphicspuppeteerrenderingtypescriptvideo-editor
test(producer): record the Phase 2a gate result and its real pass criteria
Vance Ingalls7000e3294250
diff --git a/packages/producer/tests/long-form/README.md b/packages/producer/tests/long-form/README.mdindex 94e5764318..917549698c 100644--- a/packages/producer/tests/long-form/README.md+++ b/packages/producer/tests/long-form/README.md@@ -31,7 +31,7 @@ Never run two of these concurrently on a dev Mac — the fleet limit is why the| ----- | --------------------------------------------------------- | ----------------------------------------------------------------------------------------------- || 0 | `render a-single --fps 30 -w 1` (stock env) | log `streaming-encode gate {"enabled":true,"reason":"single_worker",...}`; output 300.000 s || 1 | `render a-single --fps 30 -w 4` (stock env) | log `Parallel screenshot capture will stream to the encoder`; work dir < 2 GB; output 300.000 s |-| 2a | `HF_SEGMENTED_CAPTURE=true render a-single --fps 30 -w 1` | `segment_*.mp4` in work dir; output 300.000 s; PSNR ≥ 45 dB vs the Phase 0 output |+| 2a | `HF_SEGMENTED_CAPTURE=true HF_SEGMENT_FRAMES=1500 render a-single --fps 30 -w 1` | log `Segmented capture complete: 6 segment(s)`; output 300.000 s and exactly 9000 frames; no per-frame PSNR dip at a segment boundary (see below) || 2b | kill the 2a render at ~40 %, rerun with `--resume` | log `resuming: N segments complete`; output byte-identical to an uninterrupted run || 2c | 2a with `HF_SEGMENT_BROWSER_RECYCLE=1` | one `[Render] segment browser recycled` line per segment; output unchanged || 2d | 2a with `-w 4` | four `segment worker` lines; output 300.000 s |@@ -43,3 +43,34 @@ PSNR between two renders:```shffmpeg -i a.mp4 -i b.mp4 -lavfi "[0:v][1:v]psnr" -f null - 2>&1 | grep -o 'average:[0-9.inf]*'```++### Reading the segmented-capture PSNR++The average against a single-encoder reference is **not** the criterion, and the+spec's "≥ 45 dB" reads as a failure when nothing is wrong. Two independent CRF+encodes of identical frames differ anyway, and segmented capture additionally+forces a closed GOP with scene-cut detection off, which costs roughly another+dB. Measured 2026-09-17 on the 300 s fixture: average 44.4 dB, median 44.3,+minimum 42.97, frame count and duration both exact.++What actually detects a boundary defect is the per-frame series, so compare+that instead:++```sh+ffmpeg -i ref.mp4 -i phase2a.mp4 -lavfi "[0:v][1:v]psnr=stats_file=/tmp/psnr.log" -f null -+grep -oE 'n:[0-9]+ .*psnr_avg:[0-9.inf]+' /tmp/psnr.log | sort -t: -k5 -n | head+```++Healthy output has its **highest** PSNR at the boundary frames — they are+forced IDRs, so they encode more faithfully than their neighbours (measured+48–62 dB at n = 1501, 3001, 4501, 6001, 7501 with `HF_SEGMENT_FRAMES=1500`).+A dip at exactly those indices is the failure this gate is looking for.++### Known cost: segmented capture is slower++The segmented stage runs the plain `captureFrameToBuffer` loop, while the+single-encoder streaming stage uses the depth-2 worker-encode pipeline when the+session supports it. On the 300 s fixture that is 5 m 16 s segmented vs 2 m 43 s+streaming (both drawElement capture). Segmentation buys bounded scratch,+resumability and blast radius, not speed; threading the worker-encode loop+through the segmented stage is the follow-up that would close the gap.