commit 28a4abf85d63e599e4f56b4d01f9eec3ea1ea495
parent 30075252e153cb99395b3023238ab9c82e79f43d
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Sat, 24 Oct 2026 03:07:12 -0400
Play the cut: the picture by WebCodecs where the browser has it
The engine's picture is WebCodecs by default where VideoDecoder exists:
each clip on screen and the next decoded from its cached window (the mp4's
moov read from the head and tail at once, then the samples a block at a
time from the keyframe before the second wanted), a few frames ahead into
a bounded queue, the frame due at the audio clock drawn into the footage
canvas (blur unchanged), and a crossfade a real dissolve -- two clips'
frames, the incoming at its progress; fadeblack dips through the ground.
Every VideoFrame is closed. A window it cannot read (fragmented, a codec
the browser refuses) or a clip whose frames run more than 0.25 s behind
the sound for 0.7 s plays on the <video> elements instead, and the
Approximate line says which path is playing ("picture: WebCodecs", "some
clips on <video>", "<video>"). ?picture=element|webcodecs forces one.
knobs.md, "Play the cut": the render's edges, the one clock, the picture.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
3 files changed, 37 insertions(+), 17 deletions(-)
diff --git a/umtool/components/projects/review/playEngine/engine.ts b/umtool/components/projects/review/playEngine/engine.ts
@@ -22,9 +22,9 @@ import { ElementPicture } from "./elementPicture";
// on the same clock. A clip whose sound is not decoded by the time it is due
// holds the clock (`waiting`) at its first second; nothing is skipped.
//
-// THE PICTURE FOLLOWS THE CLOCK: on two <video> elements slaved to it
-// (elementPicture.ts), a crossfade drawn as a dissolve of the two; by
-// WebCodecs (codecPicture.ts) when the URL asks for it, `?picture=webcodecs`.
+// THE PICTURE FOLLOWS THE CLOCK: by WebCodecs where the browser has it
+// (codecPicture.ts: the frame due at the clock, decoded ahead; a real
+// dissolve), else on two <video> elements slaved to it (elementPicture.ts).
// Either way it is drawn into the footage canvas by footageCanvas.ts, blurred
// as the build blurs it.
//
@@ -137,8 +137,7 @@ export class PlayEngine {
constructor(private o: Opts) {
this.bank = new AudioBank(o.audioOf);
- // WebCodecs is asked for by name here (`?picture=webcodecs`); the elements are the picture.
- this.codecs = o.picture === "webcodecs" && codecsAvailable() ? new CodecPicture() : null;
+ this.codecs = o.picture !== "element" && codecsAvailable() ? new CodecPicture() : null;
const loop = () => {
this.raf = requestAnimationFrame(loop);
this.tick();
diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md
@@ -212,8 +212,7 @@ browser. **Render this clip** is the pixel-true check of all of that but the joi
(`/projects/<p>/play?take=<id>`) — plays the WHOLE cut in this browser in its final look, for iterating without a
render: every entry in timeline order, each clip from its cached source window (the bench's media route, an
excerpt of a long recording), the live preview's chrome over it on ONE cut clock — the rail's pip, the tally, the
-stamps, the markers and the finale advance as in the render — and the next clip loaded behind the playing one so
-the cut is near-seamless. A take plays the project's manifest **as it is now** with the take's style patch and its
+stamps, the markers and the finale advance as in the render — at the render's own edges (below). A take plays the project's manifest **as it is now** with the take's style patch and its
own patch (a take's own `timeline` included), from `takes/<id>/take.json` or — not rendered yet — a recipe that
names it; its pages are composed under `takes/<id>/out/`, never over the project's. `render.blur: "off"` on the
take plays its blurred clips as recorded.
@@ -227,12 +226,34 @@ take plays its blurred clips as recorded.
| the assistant on a note (its reply lands on the note, its edits wait for **Apply all**), or on every open note at once | a note's **Send to the assistant**; **Send N open notes to the assistant** | — |
| every key | **?** | ? |
-What it does not do (the line under the picture says so): each crossfade is a **hard cut at its middle** (where
-the deck hands its title over); cards, teasers and images are **placeholders** with their heading for their
-seconds; the edges are not snapped to silence; the sound is the source's (no room, no Audio knobs); the clock is the
-estimate's (a carrying clip's posts hold included when the cut has a deck). A clip whose source window is not on
-disk is a named placeholder that plays on — fetch it from the Cut tab. **Reload the cut** reads an edit made
-elsewhere.
+**It plays the render's cut, edges first.** The build snaps every clip edge to the nearest silence within
+`render.snapWindow` (on the Huck cut, starts up to 1.0 s earlier and ends up to 1.0 s later than the manifest's), so
+Play asks where it will cut — `GET /api/report/cut-points?project=<p>[&take=<t>]`, the build's own source resolution,
+silencedetect and snap (`report-to-video/cut-points.mjs`, `snap.mjs`; room at the edges and `render.loudness` too),
+measured once per clip and cached under the umtool cache's `cut-points/` — and plays each clip from the render's
+first source second to its last, every later entry moved by what the clips before it gained or lost. The clip bench
+draws the same edges over its waveform as faint ghosts with their offset (**render: +0.52 s**), snapped live from
+the measured silences as an edge is dragged.
+
+**The sound is on one Web Audio clock.** Each clip's sound is decoded (ffmpeg's decode of the cached window, the
+bench's `/api/report/audio`; only the clips around the playhead are held) and scheduled back to back on one
+AudioContext, sample-exact at the render's edges: a crossfade is the build's two linear ramps over the overlap, the
+loudness gain, room's muted edges, the clip's own `audio` knobs and the mute mark are gain automation, and a speed
+time-stretches at the voice's pitch as the bench does. The clock of the whole view — the rail, the tally, the
+stamps, the finale, a note's anchor — is that context's time mapped through the plan; the chrome (composed on the
+estimate's clock) is seeked by the source second playing, so a stamp lands on its word. A clip whose sound is not
+decoded yet holds the clock at its first second (**loading…**), nothing skipped.
+
+**The picture follows the clock**: by WebCodecs where the browser has it — each clip decoded from its window a few
+frames ahead, the frame due at the audio clock drawn, a crossfade a real dissolve (a `fadeblack` join dips through
+the ground) — else on two `<video>` elements slaved to the clock (requestVideoFrameCallback, the speed nudged past a
+frame of drift, re-seeked past a quarter second). `?picture=element` forces the elements, to compare.
+
+What it still does not do (the line under the picture says so, with which sound and picture paths are playing):
+cards, teasers and images are **placeholders** with their heading for their seconds; a push, a wipe or a whip is
+drawn as a dissolve; the limiter after the loudness gain is not applied; a montage's phrase cuts are snapped as plain
+cuts. A clip whose source window is not on disk is a named placeholder that plays on (silent) — fetch it from the
+Cut tab. **Reload the cut** reads an edit made elsewhere, and the edges are measured again for what moved.
The notes are the project's `notes.json` ([notes.md](notes.md)): `umtool notes <p>` prints each with its cut second,
its clip and source, and — for a take — that its patch is the file to edit. **Send to the assistant** is the video
diff --git a/umtool/e2e/play-engine.spec.ts b/umtool/e2e/play-engine.spec.ts
@@ -15,8 +15,8 @@ import * as urls from "./urls";
// - the CLOCK is the sound's: one AudioContext, every clip a node started
// ahead of its time (so on the sample); suspend the context and the
// whole view stops with it
-// - the PICTURE follows the clock: <video> elements slaved to it (a
-// dissolve is two layers)
+// - the PICTURE follows the clock: WebCodecs where the browser has it (a
+// dissolve is two layers), <video> elements otherwise (?picture=element)
//
// Fixture: e2e/fixtures/play-cut-fixture.mjs's play-engine-fixture (the
// play-cut cut, which this spec WRITES). On vid1's window (silences
@@ -91,8 +91,8 @@ test("the clock is the sound's: one AudioContext, nodes started ahead of their t
await page.keyboard.press("k");
});
-test("the picture: the <video> elements follow the clock, a dissolve is two layers", async ({ page }) => {
- for (const [q, want] of [["?picture=element", "element"]] as const) {
+test("the picture: WebCodecs in this browser, a dissolve is two layers; the <video> path does the same", async ({ page }) => {
+ for (const [q, want] of [["", "webcodecs"], ["?picture=element", "element"]] as const) {
await page.goto(urls.playHref(PROJECT) + q);
await expect(root(page)).toHaveAttribute("data-play-edges", "render", { timeout: 30_000 });
await page.locator('[data-play-row="c02"]').press("Enter");