# Video knobs — the core (lane `lane/knobs-core`, K1) Asked by the operator on 2026-10-22 on the Huck seizure video: count seizures, bring the stamps back for the clip that steps a count and set where it lands per clip, fix the sound drifting toward 16 minutes, make quality variants to share elsewhere, and "add any knobs you can think of … deep human involvement as well as AI control". The plan is `video-knobs-plan.md` (the orchestrator's); this lane is its "desync", "Shared shapes" and "K1 core". K2 (`lane/knobs-ui`) builds the writers, routes, UI and CLI against the same shapes. ## The desync Measured on `polemic-huck` (26 clips, xfade 0.5 s, two crossfade batches): `first … ten-k` sound 68 ms early, `rescue … blend` 469 ms early. Causes: - **rescue (469 ms).** The cut starts at source 2567.04; the editor's window file (`2563.74-2594.40.mp4`) has no media before 3.79 s of its own clock (audio 3.7905, video 3.8333), so `fetchStart` moves to 2567.53 and the segment's cut starts 0.49 s before the media. The segment encode keeps timestamps: its picture holds the first frame from 0, its sound starts at 0.4687 s. In sync by timestamps — but `xfadeGraph`'s pin (`apad`, `atrim`, `asetpts=PTS-STARTPTS`) and `acrossfade` count samples, so the sound moved 469 ms early, and every later clip in the batch with it. - **first … ten-k (68 ms).** `fed`'s source window (`6112.50-6159.50.mp4`) has two holes in its audio timestamps at 42.69 s (51 ms + 17 ms, an HLS seam), carried into `fed.mp4` at 38.21 s. Decoded, fed's sound is 67.7 ms short of its timeline; the pinned graph pads that at fed's END, so everything after the hole — the rest of fed, then every later clip in batch 1 — plays 68 ms early. Batch 1's sound is 67.7 ms shorter than its picture (612.366 vs 612.433), batch 2's 469 ms; the join pass re-pins per batch, which is why each batch reset it. Fix: `AUDIO_ON_CLOCK` (`clip-audio.mjs`) = `aresample=async=1:min_hard_comp=0.01:first_pts=0` — silence where a sound starts late or a hole opens, samples dropped where two overlap, anything over 10 ms; a sound with neither passes sample for sample (checked: identical PCM). Applied: - at the segment encode (every non-montage clip's sound), so new segments are continuous from 0; the build notes a cut that starts before its source's media; - in `xfadeGraph`'s pin (one pass, each batch, the join pass); - in `hardCutFilterArgs` (the concat filter) and `previewFromSegmentsArgs`' concat. Proof: the Huck cut's SOUND re-assembled from its real segments with the fixed graph, batched as the build batches it (audio only, no render), measured with `lag.py` — every clip 0 ms: | clips | before | after | |---|---|---| | arrive, fed | 0 | 0 | | first … ten-k (11) | −68 / −67 ms | 0 | | gold, post-results, offset | 0 | 0 | | rescue … blend (10) | −469 / −468 ms | 0 | `sync-report.mjs` reads the current final exactly as `lag.py` did (0, −68, −469). `av-clock.test.mjs`: a segment whose audio starts 0.5 s late and one with a 60 ms hole, through one crossfade pass, a batched pass and the hard cut: every burst within a frame; with the align swapped for `anull` it fails (the late one 400+ ms early). ## The sync report After every build and `--chrome-only`: `//sync.json` `{ at, fps, items: [{ id, start, lagMs, peak }] }`, clips only; the build log names each clip more than a frame off. lag.py's method in node: mono 4 kHz, the segment's sound over a window past its joins (≤ 6 s from 3 s in) found in the final within ±2.5 s, coarse at 1 kHz then fine (~6 s for the 26-clip cut). `REPORT_VIDEO_SYNC=0` skips it; it never fails a build. ## The knobs All optional; absent, the schedule, the pages and the segments are the bytes they were (the existing byte-identity tests pass unchanged). | Key | Range · default | What | |---|---|---| | `claim.at` | a source second inside the clip's `start`–`end` · the usual timing | the stamp lands and the tally steps there, mapped through the segment's real source start (its cut record: snapped, room included; estimate/preview: the play window's start). The schedule's stamped segment carries `sourceFrom`. Read from the entry that stamps (the last carrying the id). | | `claim.hold` | 0.5–10 s · `stamp.seconds` | how long the stamp stays from its start (without `at`: comes in `hold` before the segment's out) | | `claim.stamp` | bool · true | false: counted, not drawn (`drawnStamps`; `stampsDrawn` false when none is drawn) | | `claim.count` | whole 1–99 · 1 | the tally steps by n (`tallySteps` `step`, `tallyFinals`; each count still its own number element) | | `claim.label` | ≤ 20 chars · verdict's `stampLabel`, else `label` | the stamp's words | | `factcheck.stamp.scale` | 0.5–2 · 1 | the stamp region's size (`stampGeometry`), inside the footage box | | `factcheck.stamp.motion` | slam/pop/fade/none · slam | the entrance, ending at `landed`; slam and pop flash; none leaves at once | | `factcheck.stamp.opacity` | 0.3–1 · 1 | the whole stamp region's (written only when not 1) | | `factcheck.verdicts..stampLabel` | ≤ 24 chars · `label` | validated in factcheck.mjs (common's override rule checks the rest) | | clip `audio.offset` | −2000–2000 ms · 0 | + = sound later; read from the source again at the shifted window (a last input; `-itsoffset` past the head) | | clip `audio.gain` | −20–20 dB · 0 | after levelling and room | | clip `audio.fadeIn`, `fadeOut` | 0–5 s · 0 | at the segment's edges | | `deck.markers[].align` | auto/left/right/center · auto | the label against its flag; a neighbour reading away lets a label reach up to it | | `deck.markerLayout` | stagger/truncate · stagger | crowded labels in two rows (every split tried; most labels fitting wins); band +22 px (`MARKER_ROW`); row 1's sticks reach up, row 0 keeps 8 px clear of them; a still-long label ellipsized | | `render.variants` | ≤ 12 · master, 1080p crf 22, 720p crf 23, fit24 ≤ 24 MiB | `variants.mjs`: crf variants at their height (sound and chapters copied); maxMiB two-pass at the largest of 1080/720/480 keeping 100 kb/s per 480p of pixels, AAC 48 mono under 300 kb/s total (else 96 stereo), retried 6 % lower while over (four tries) | The crowded-marker case (9 grey chapter flags + 2 red, the last three within 200 px of the track's end): one row fits 7 of 11, two rows 9 of 11. Three ~200 px labels on 140 px of track cannot all fit two rows; the rest are ellipsized. The Huck timeline take's two markers fit one row and lay as before. ## Exports for K2 - `validateClipAudio(audio, where?) → string[]` — `umtool-report-to-video/clip-audio` (also `validateClipAudioEntries`, `CLIP_AUDIO_LIMITS`, `clipAudioOf`). - `encodeVariants(outDir, { slug, variants, only, source, onLog })`, `validateVariants`, `variantsOf`, `DEFAULT_VARIANTS`, `VARIANTS_FILE` — `umtool-report-to-video/variants`. - `SYNC_FILE`, `writeSyncReport`, `SYNC_WEAK_PEAK` — `umtool-report-to-video/sync-report`. - `normalizeClaim` accepts and returns the knobs; `CLAIM_KEYS`, `CLAIM_LIMITS`, `STAMP_MOTIONS`, `FACTCHECK_LIMITS.scale/opacity` — factcheck. - `MARKER_ALIGNS`, `MARKER_LAYOUTS`, `MARKER_ROW`, `markerLabelWidth`, `markerRowsOf`, `deckLayout(render, { tally, schedule })` — deck. ## Left to K2 / open - `app/api/report/chrome/preview/route.ts` returns `deckLayout(render, { tally })`: pass `schedule` too, or a staggered band's geometry differs from the page's. - `lib/report/manifest.mjs`' claim types (`{ id, verdict }`) and `normalizeClaimsDraft` carry the knobs only as far as `normalizeClaim` does; the writers are K2's. - `lib/report/onscreen.mjs` `previewSchedule` places `claim.at` from the built segment's `sourceFrom`, else the play window's start (a claim given `at` after the build previews up to a snap's distance off until the next build). - A montage clip's `audio` is not applied (its graph cuts its own sound); the build says so. - The real Huck cut has not been re-rendered here (the orchestrator's rollout); the proof above is the sound re-assembled from its real segments. ## Files `umtool/report-to-video/`: `clip-audio.mjs` (new), `sync-report.mjs` (new), `variants.mjs` (new), `build-video.mjs`, `factcheck.mjs`, `chrome-stamp.mjs`, `chrome-deck.mjs`, `deck.mjs`, `compose-chrome.mjs`, `lint.mjs`, `package.json` (exports `./clip-audio`, `./sync-report`, `./variants`; bin `report-variants`); tests `av-clock`, `sync-report`, `claim-knobs`, `clip-audio`, `deck-markers-layout`, `variants` (new) and the graph strings in `cut-edits`, `deck-overlay`, `deck-room`, `factcheck`. `umtool/lib/report/onscreen.mjs` (the preview's source clock for `claim.at`). Docs: `umtool/report-to-video/README.md`, `umtool/docs/report-video.md`, `editor/CHANGELOG.md`.