Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit c53d6eadbc7eb32d2db102e46d5d95157dd8417c
parent 2a32bd0a66321a05af66cff618bbcb04dee8dac8
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Fri, 30 Oct 2026 15:16:03 -0400

umtool fx writer: a clip's fx through patchClipEntry (whole, per field, cleared), umtool set fx.*, the window route; fx.zoom.hold

A clip's `fx` had no writer: patchClipEntry now takes `fx` (whole; null or
"" clears) and `fx.<field>` (zoom, receipts, punch, quote, punchIn,
speakers; null removes one), checked after the patch by fx.mjs
validateFxEntries in its own words (only problems the write adds). A
screenshot is a file in the project as the build reads it; a bare name
found only under shots/ is written as shots/<name>. A take's walk passes
the project dir too. `umtool set <p> <clip> fx.zoom='{…}'`, `fx=` clears;
PUT /api/report/window takes fx and fx.<field>.

fx.zoom.hold (0.5-10 s): the zoom leaves that long after its push lands;
absent it stays to its clip's end as before. Docs: knobs.md "A clip" rows
(the zoom's timing in and out), the Effects module rows, cli.md.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mumtool/app/api/report/window/route.ts | 10++++++++++
Mumtool/docs/cli.md | 2+-
Mumtool/docs/knobs.md | 4++++
Aumtool/lib/report/clip-fx.test.mjs | 132+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/lib/report/knobsCli.mjs | 20+++++++++++++++++++-
Mumtool/lib/report/manifest.mjs | 121++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
Mumtool/lib/report/takeEdit.mjs | 2+-
Mumtool/report-to-video/fx.mjs | 21+++++++++++++++++----
Mumtool/report-to-video/modules/fx.mjs | 2++
9 files changed, 303 insertions(+), 11 deletions(-)

diff --git a/umtool/app/api/report/window/route.ts b/umtool/app/api/report/window/route.ts @@ -68,6 +68,16 @@ export async function PUT(request: Request) { // What the deck says over this clip: { title?, subtitle? }, or null to // clear it. Normalised and checked by the writer, like the date. "onscreen", + // The clip's effects (report-to-video fx.mjs): `fx` whole, or one field + // (`fx.zoom`, …); null clears. Checked by the writer in the build's + // words, a screenshot against the project's files. + "fx", + "fx.punch", + "fx.quote", + "fx.punchIn", + "fx.speakers", + "fx.receipts", + "fx.zoom", ]) { if (body[k] !== undefined) patch[k] = body[k]; } diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md @@ -26,7 +26,7 @@ Inbox cannot disagree about what is wrong with one. | `window <project> <clip> --take <take> …` | a **take's** clip (walk a take): the same fields, written into the take's patch (`takes/<take>/take.json`) with an undo point first; the project's manifest is untouched ([clip-bench.md](clip-bench.md#walking-a-take)) | | `walk <project> [--take <take>] [--all] [--json]` | the clip bench's **walk**: every clip in walk order with its window, verdict and whether a fetched file holds it, and (→) the ones the walk visits — fetched and needing a verdict; `--all` every fetched one; `--take` walks a take (a draft too); the bench's address to start at | | `link <project> <site>/<report>` · `link <project> --clear` | the manifest names the article it is the video of (settles `link-ambiguous`) | -| `set <project> <clip> key=value …` | a clip's **knobs**: `claim.at` `claim.hold` `claim.stamp` `claim.count` `claim.label` (the first mark's, or `--mark <id>`'s), its **marks** `mark.add=<verdict>[@<sec>]` `mark.remove=<id>` `mark.verdict=<verdict>` `marks=<json>`, `audio.offset` `audio.gain` `audio.fadeIn` `audio.fadeOut`, its picture's **blur** `blur.on=true` `blur.caption=…` `blur.strength` `blur.from` `blur.to` (`blur.on=` clears it; [knobs.md](knobs.md#a-clips-picture-blurred)); `key=` clears one ([knobs.md](knobs.md#marks)) | +| `set <project> <clip> key=value …` | a clip's **knobs**: `claim.at` `claim.hold` `claim.stamp` `claim.count` `claim.label` (the first mark's, or `--mark <id>`'s), its **marks** `mark.add=<verdict>[@<sec>]` `mark.remove=<id>` `mark.verdict=<verdict>` `marks=<json>`, `audio.offset` `audio.gain` `audio.fadeIn` `audio.fadeOut`, its picture's **blur** `blur.on=true` `blur.caption=…` `blur.strength` `blur.from` `blur.to` (`blur.on=` clears it; [knobs.md](knobs.md#a-clips-picture-blurred)), its **effects** `fx.zoom=<json>` `fx.receipts=<json>` `fx.punch=…` `fx.quote` `fx.punchIn=<json>` `fx.speakers=<json>` (`fx=<json>` all of them, `fx=` clears them; a shot is a file in the project; [knobs.md](knobs.md#effects)); `key=` clears one ([knobs.md](knobs.md#marks)) | | `look <project> key=value …` | the cut's **knobs**: `factcheck.stamp.*`, `factcheck.verdicts.<V>.stampLabel\|label\|color`, `deck.markers=<json>`, `deck.markerLayout`, `variants=<json>`, and the look's keys ([knobs.md](knobs.md)) | | `variants <project> [--take <t>] [--list] [--json]` | **Make variants**: the encode ladder of the build (or of a take's); `--list` what was made and the build's sync report, each clip's lag (past a frame flagged) ([knobs.md](knobs.md)) | | `build <project> [--preset preview\|fast\|final] [--only ID]` | **prints** the chain | diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -31,6 +31,8 @@ that generates it ([notes.md](notes.md)). | `blur.strength` — the blur's radius, % of the picture's height as it plays (2–15; default 5) | Blur, **strength** | `blur.strength=8` | same | | `blur.from`, `blur.to` — source seconds inside the clip's window: blur only that span (either alone runs to the clip's edge; default the whole clip) | Blur, **From playhead** / **To playhead**, **Whole clip** | `blur.from=231.5 blur.to=262` | same | | `layout` — `finale`: the deck's finale layout for this clip (`render.chrome.deck.finale`); `clip` is the default | — | `umtool set <p> <clip> layout=finale` | — | +| `fx.zoom` — `{shot, focus, at?, hold?}`: a screenshot (a file in the project; a bare name under its `shots/` is written as `shots/<name>`) that comes up over the footage and pushes in on `focus` (`[left, top, right, bottom]`, fractions of the shot) — drawn once `render.chrome.fx.zoom` is on ([Effects](#effects)). **How long it stays**: up 0.2 s into the clip's clean span (rising in over 0.38 s), its focus box drawn 0.55 s later, the push at `at` (seconds into the clip; default as soon as the box has drawn) over 1 s, then a slow drift on the detail; it leaves with a 0.3 s fade 0.3 s before the clip's clean span ends — or, with `hold` (0.5–10 s), that long after the push lands (never past the clip's own leave) | — | `umtool set <p> <clip> fx.zoom='{"shot":"shots/x.png","focus":[0.1,0.2,0.9,0.4],"at":5.9,"hold":4}'` (`fx.zoom=` clears it) | `PUT /api/report/window {project, clip, "fx.zoom": {…} \| null}` | +| `fx.receipts`, `fx.punch`, `fx.quote`, `fx.punchIn`, `fx.speakers` — the clip's other effect fields (`[{shot, mark?}]` 1–4; the words to punch; `false`: no line; 1–8 source seconds inside the clip; `[{at, who: 0\|1}]`), each inert until its effect is on; `fx` is all of them at once. Checked by the build's own `validateFxEntries` | — | `fx.punch="the words"` `fx.punchIn='[231.4]'` · `fx='{…}'` sets them all, `fx=` clears every one | `PUT /api/report/window {project, clip, fx}` (or one `"fx.<field>"`) | `key=` (nothing after the `=`) clears a knob; in umtool, **Clear** beside a field (Audio: **Clear all**). A claim's knobs are read from the clip that **stamps** it — the last clip carrying the claim id; the box on any other @@ -581,6 +583,8 @@ Overlays on the picture -- receipts, a zoom, the scrubber, a kinetic quote, punc |---|---|---| | `render.chrome.fx.<effect>` | scrubber · receipts · zoom · kineticQuote · redact · odometer · punchIn · thenNow · whip · glitch | a take: `umtool take <p> --effect <name>` | | `render.chrome.fx.glitch.on`, `.clips` | `year` (a tear at each cut between years) · `every` (each cut between clips) · `clips` (only the cut INTO each clip `clips` names: 1–60 ids, each with a clip right before it) · default `year`; `clips` only with `on: "clips"`. `.seconds` 0.2–1.5 · 0.5, `.stamp` (the `PLAY ▶` date) · `true`, `.year` (the new year big over the tear; `false` with `stamp: false` is a bare tear, no text) · `true` | manifest | +| a clip's `fx` — what an effect draws on it, inert until that effect is on: `zoom` `{shot, focus, at?, hold?}`, `receipts` `[{shot, mark?}]` (1–4), `punch` (the words), `quote` (false: no line), `punchIn` `[source s…]` (1–8, inside the clip), `speakers` `[{at, who: 0|1}]`. A `shot` is a file in the project (a bare name under its `shots/` is written as `shots/<name>`); `focus`/`mark` are `[left, top, right, bottom]` fractions of it | `fx.<field>=<json>` sets one and keeps the rest · `fx=<json>` all · `fx=` none; checked by the build's own `validateFxEntries` | `umtool set <p> <clip> fx.zoom='{"shot":"shots/x.png","focus":[0.1,0.2,0.9,0.4],"at":5.9}'` · `PUT /api/report/window {project, clip, fx}` (or `"fx.zoom"`, …) | +| the zoom's timing (`fx.zoom.at`, `.hold`) | up 0.2 s into the clip's clean span (the card rises in over 0.38 s, `back.out`); its focus box draws 0.55 s later (0.45 s); it pushes in on the box at `at` — seconds into the clip, default as soon as the box has drawn — over 1 s (`power2.inOut`), then drifts slowly on the detail. It leaves with a 0.3 s fade 0.3 s before the clip's clean span ends, or with `hold` (0.5–10 s) that long after the push lands (never past the clip's own leave) | `fx.zoom='{…,"hold":4}'` | ### Thread rail diff --git a/umtool/lib/report/clip-fx.test.mjs b/umtool/lib/report/clip-fx.test.mjs @@ -0,0 +1,132 @@ +// A clip's `fx` through the one writer (updateClip / patchClipEntry): whole, +// per field, cleared; refused in validateFxEntries's words; a screenshot is a +// file in the project (or under its shots/); a take's walk writes it too; and +// `umtool set fx.*` is the same writer from a terminal. +// +// Run with: pnpm test:scripts +import assert from "node:assert/strict"; +import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import path from "node:path"; +import test from "node:test"; + +import { fxSchedule, validateFxEntries, FX_MOTION } from "umtool-report-to-video/fx"; + +const ROOT = await mkdtemp(path.join(tmpdir(), "umtool-clip-fx-")); +process.env.REPORTS_DIR = ROOT; +const { MANIFEST_NAME, manifestToken, patchClipEntry, updateClip } = await import("./manifest.mjs"); +const { setCommand } = await import("./knobsCli.mjs"); + +const base = () => ({ + slug: "t", + provenance: { siteOrigin: "https://example.test", channelSlug: "chan" }, + render: { width: 1920, height: 1080, fps: 30, transition: 0.5 }, + timeline: [ + { type: "card", id: "k1", heading: "Opening" }, + { type: "clip", id: "c01", video: "v1", start: 10, end: 20 }, + { type: "clip", id: "c02", video: "v2", start: 30, end: 41, fx: { punch: "kept" } }, + ], +}); + +async function project(name, manifest = base()) { + const dir = path.join(ROOT, name); + await mkdir(path.join(dir, "shots"), { recursive: true }); + await writeFile(path.join(dir, MANIFEST_NAME), JSON.stringify(manifest, null, 2) + "\n"); + await writeFile(path.join(dir, "shots", "doc.png"), "png"); + await writeFile(path.join(dir, "top.png"), "png"); + return dir; +} +const readRaw = (dir) => readFile(path.join(dir, MANIFEST_NAME), "utf8"); +const read = async (dir) => JSON.parse(await readRaw(dir)); +const clip = (m, id) => m.timeline.find((e) => e.id === id); + +test.after(() => rm(ROOT, { recursive: true, force: true })); + +test("updateClip fx.zoom: written, rounded, its shot checked in the project; a bare name found under shots/", async () => { + const dir = await project("zoom"); + const res = await updateClip(dir, "c01", { "fx.zoom": { shot: "shots/doc.png", focus: [0.1, 0.20001, 0.9, 0.4], at: 5.904, hold: 4 } }, { token: await manifestToken(dir) }); + assert.deepEqual(res.entry.fx, { zoom: { shot: "shots/doc.png", focus: [0.1, 0.2, 0.9, 0.4], at: 5.9, hold: 4 } }); + assert.deepEqual(clip(await read(dir), "c01").fx, res.entry.fx); + // A bare name only under shots/ is written as that path; one beside the manifest as itself. + await updateClip(dir, "c01", { "fx.zoom": { shot: "doc.png", focus: [0, 0, 1, 1] } }); + assert.equal(clip(await read(dir), "c01").fx.zoom.shot, "shots/doc.png"); + await updateClip(dir, "c01", { "fx.zoom": { shot: "top.png", focus: [0, 0, 1, 1] } }); + assert.equal(clip(await read(dir), "c01").fx.zoom.shot, "top.png"); + // The manifest still validates as the build reads it. + assert.deepEqual(validateFxEntries(await read(dir)), []); +}); + +test("updateClip fx: a missing or escaping shot, or a shape the build refuses, is refused in its words and nothing is written", async () => { + const dir = await project("refuse"); + const before = await readRaw(dir); + await assert.rejects(updateClip(dir, "c01", { "fx.zoom": { shot: "shots/nope.png", focus: [0, 0, 1, 1] } }), /fx\.zoom\.shot shots\/nope\.png is not a file in the project/); + await assert.rejects(updateClip(dir, "c01", { "fx.zoom": { shot: "../x.png", focus: [0, 0, 1, 1] } }), /not outside it/); + await assert.rejects(updateClip(dir, "c01", { "fx.zoom": { shot: "shots/doc.png", focus: [0.5, 0, 0.4, 1] } }), /timeline entry c01: fx\.zoom\.focus must be \[left, top, right, bottom\]/); + await assert.rejects(updateClip(dir, "c01", { "fx.zoom": { shot: "shots/doc.png", focus: [0, 0, 1, 1], hold: 30 } }), /fx\.zoom\.hold must be from 0\.5 to 10 seconds/); + await assert.rejects(updateClip(dir, "c01", { "fx.zoom": { shot: "shots/doc.png", focus: [0, 0, 1, 1], spin: 1 } }), /fx\.zoom\.spin is not a zoom field/); + await assert.rejects(updateClip(dir, "c01", { "fx.punchIn": [5] }), /fx\.punchIn has a second outside the clip \(10–20\)/); + await assert.rejects(updateClip(dir, "c01", { "fx.quote": "yes" }), /fx\.quote must be true or false/); + await assert.rejects(updateClip(dir, "c01", { fx: [1] }), /^Error: fx must be \{/); + await assert.rejects(updateClip(dir, "c01", { "fx.receipts": [{ shot: "shots/nope.png" }] }), /fx\.receipts\[0\]\.shot shots\/nope\.png is not a file/); + assert.equal(await readRaw(dir), before); +}); + +test("updateClip fx: a field patch keeps the rest; null removes a field; fx whole replaces; fx null (or \"\") clears", async () => { + const dir = await project("fields"); + await updateClip(dir, "c02", { "fx.punchIn": [31.234], "fx.quote": false, "fx.receipts": [{ shot: "doc.png", mark: [0, 0.4, 1, 0.5] }] }); + assert.deepEqual(clip(await read(dir), "c02").fx, { + punch: "kept", punchIn: [31.23], quote: false, receipts: [{ shot: "shots/doc.png", mark: [0, 0.4, 1, 0.5] }], + }); + await updateClip(dir, "c02", { "fx.punch": null, "fx.quote": "" }); + assert.deepEqual(clip(await read(dir), "c02").fx, { punchIn: [31.23], receipts: [{ shot: "shots/doc.png", mark: [0, 0.4, 1, 0.5] }] }); + await updateClip(dir, "c02", { fx: { punch: " the words ", speakers: [{ at: 32, who: 1 }] } }); + assert.deepEqual(clip(await read(dir), "c02").fx, { punch: "the words", speakers: [{ at: 32, who: 1 }] }); + await updateClip(dir, "c02", { fx: null }); + assert.equal("fx" in clip(await read(dir), "c02"), false); + // The last field removed removes fx. + await updateClip(dir, "c02", { "fx.punch": "x" }); + await updateClip(dir, "c02", { "fx.punch": null }); + assert.equal("fx" in clip(await read(dir), "c02"), false); +}); + +test("patchClipEntry: a window save that strands a punch-in is refused; one under an fx already bad is not blamed for it", () => { + const m = base(); + clip(m, "c01").fx = { punchIn: [12] }; + assert.throws(() => patchClipEntry(m, "c01", { start: 13 }), /punchIn has a second outside the clip \(13–20\)/); + const bad = base(); + clip(bad, "c01").fx = { quote: "nope" }; + const { entry } = patchClipEntry(bad, "c01", { end: 19 }); + assert.equal(entry.end, 19); +}); + +test("fx.zoom.hold: absent, the zoom stays to its clip's end (as it was); set, it leaves that long after the push lands", () => { + const render = { width: 1920, height: 1080, fps: 30, chrome: { engine: "hyperframes", layout: "deck", fx: { zoom: {} } } }; + const segments = [{ id: "c01", start: 0, duration: 20 }]; + const sched = (zoom) => fxSchedule({ + segments, entries: [{ type: "clip", id: "c01", start: 0, end: 20, fx: { zoom } }], render, D: 0.5, total: 20, + sourceFrom: () => 0, hidden: () => false, + }).zoom.clips[0]; + const plain = sched({ shot: "s.png", focus: [0, 0, 1, 1], at: 3 }); + assert.equal(plain.out, 19.7); // the clip's clean span less 0.3 + const held = sched({ shot: "s.png", focus: [0, 0, 1, 1], at: 3, hold: 4 }); + assert.equal(held.push, plain.push); + assert.equal(held.out, Math.round((plain.push + FX_MOTION.push + 4 + 0.3) * 1000) / 1000); + // Never past the clip's own leave. + assert.equal(sched({ shot: "s.png", focus: [0, 0, 1, 1], at: 12, hold: 10 }).out, 19.7); +}); + +test("umtool set fx.*: the zoom as JSON, the punch as words, fx= clears every field; a bad one refused", async () => { + const dir = await project("cli"); + const lines = []; + const run = (...args) => setCommand(args, { root: ROOT, out: (s) => lines.push(s), err: (s) => lines.push(`ERR ${s}`) }); + assert.equal(await run("cli", "c01", 'fx.zoom={"shot":"shots/doc.png","focus":[0.1,0.2,0.9,0.4],"at":5.9}', "fx.punch=2020"), 0, lines.join("\n")); + assert.deepEqual(clip(await read(dir), "c01").fx, { zoom: { shot: "shots/doc.png", focus: [0.1, 0.2, 0.9, 0.4], at: 5.9 }, punch: "2020" }); + assert.match(lines.at(-1), /^c01: fx \{.*"zoom":\{"shot":"shots\/doc.png"/); + assert.equal(await run("cli", "c01", "fx.zoom.hold=4"), 2); + assert.match(lines.at(-1), /not a clip knob/); + assert.equal(await run("cli", "c01", 'fx.zoom={"shot":"shots/gone.png","focus":[0,0,1,1]}'), 1); + assert.match(lines.at(-1), /is not a file in the project/); + assert.equal(await run("cli", "c01", "fx="), 0); + assert.equal("fx" in clip(await read(dir), "c01"), false); + assert.match(lines.at(-1), /^c01: fx none/); +}); diff --git a/umtool/lib/report/knobsCli.mjs b/umtool/lib/report/knobsCli.mjs @@ -11,6 +11,8 @@ // audio.offset audio.gain audio.fadeIn audio.fadeOut // blur.on blur.caption blur.strength blur.from blur.to // (`blur.on=` clears the whole blur; report-to-video clip-blur.mjs) +// fx=<json> fx.zoom fx.receipts fx.punch fx.quote fx.punchIn fx.speakers +// (the clip's effects; `fx=` clears them all; report-to-video fx.mjs) // umtool look <project> key=value … factcheck.stamp.<k>, factcheck.verdicts.<V>.<k>, factcheck.tally.<k>, // deck.markers=<json>, deck.markerLayout=…, deck.claims=<json>, variants=<json>, // and the look's keys (transition=0.3, …) @@ -25,6 +27,7 @@ import { REPORTS_ROOT, resolveProject } from "../projects/core.mjs"; import { readManifest } from "../projects/report.mjs"; import { withEditNotes } from "./edit-guard.mjs"; import { + FX_ENTRY_FIELDS, LOOK_KEYS, manifestToken, updateClaimKnobs, @@ -45,7 +48,9 @@ export const BLUR_KNOBS = Object.freeze(["on", "caption", "strength", "from", "t const MARK_KEYS = ["marks", "mark.add", "mark.remove", "mark.verdict"]; /** The walk's verdict, set like a knob: verdict=confirmed|incorrect|wrong-speaker, reason=wrong-speaker, correction=… (`key=` clears). */ const REVIEW_KEYS = ["verdict", "reason", "correction"]; -const SET_KEYS = [...CLAIM_KNOBS.map((k) => `claim.${k}`), ...MARK_KEYS, ...AUDIO_KNOBS.map((k) => `audio.${k}`), ...BLUR_KNOBS.map((k) => `blur.${k}`), "layout", ...REVIEW_KEYS]; +/** The clip's effects (report-to-video fx.mjs): `fx=<json>` whole (`fx=` clears it), `fx.<field>=<json>` one field. */ +const FX_KEYS = ["fx", ...FX_ENTRY_FIELDS.map((k) => `fx.${k}`)]; +const SET_KEYS = [...CLAIM_KNOBS.map((k) => `claim.${k}`), ...MARK_KEYS, ...AUDIO_KNOBS.map((k) => `audio.${k}`), ...BLUR_KNOBS.map((k) => `blur.${k}`), "layout", ...REVIEW_KEYS, ...FX_KEYS]; export const SET_USAGE = [ "usage: umtool set <project> <clip> key=value … [--mark <id>] [--json]", @@ -69,6 +74,12 @@ export const SET_USAGE = [ " seconds inside the clip's window, to blur only that span. render.blur=off (umtool look, or a take's", " --set) renders every clip unblurred: the uncensored variant. layout=finale|clip (the deck's finale", " layout for this clip; clip is the default). `key=` clears it (the default).", + " The clip's effects (drawn once render.chrome.fx turns the effect on; docs/knobs.md \"Effects\"):", + " fx.zoom='{\"shot\":\"shots/x.png\",\"focus\":[0.1,0.2,0.9,0.4],\"at\":5.9,\"hold\":4}' (shot: a file in the project;", + " focus: left, top, right, bottom fractions of it; at: seconds into the clip it pushes in; hold 0.5–10 s on the", + " detail, absent: to the clip's end); fx.receipts='[{\"shot\":\"shots/a.png\",\"mark\":[0,0.4,1,0.5]}]' (1–4);", + " fx.punch=\"the words\"; fx.quote=false; fx.punchIn='[231.4]' (source seconds);", + " fx.speakers='[{\"at\":231,\"who\":1}]'; fx='{…}' sets them all, `fx=` clears every one, `fx.<field>=` that one.", ].join("\n"); export const LOOK_USAGE = [ @@ -168,6 +179,11 @@ export async function setCommand(args, { root = REPORTS_ROOT, out = (s) => conso entryPatch.layout = value; continue; } + if (FX_KEYS.includes(key)) { + // The punch is words whatever they parse as (`fx.punch=2020`). + entryPatch[key] = key === "fx.punch" && value !== null ? String(value) : value; + continue; + } if (REVIEW_KEYS.includes(key)) { entryPatch[key] = value === null || value === undefined ? "" : String(value); continue; @@ -207,6 +223,7 @@ export async function setCommand(args, { root = REPORTS_ROOT, out = (s) => conso if ("audio" in entryPatch) results.audio = result.entry.audio ?? null; if ("blur" in entryPatch) results.blur = result.entry.blur ?? null; if ("layout" in entryPatch) results.layout = result.entry.layout ?? "clip"; + if (FX_KEYS.some((k) => k in entryPatch)) results.fx = result.entry.fx ?? null; if (REVIEW_KEYS.some((k) => k in entryPatch)) { results.review = { verdict: result.entry.verdict ?? null, reason: result.entry.reason ?? null, correction: result.entry.correction ?? null }; } @@ -227,6 +244,7 @@ export async function setCommand(args, { root = REPORTS_ROOT, out = (s) => conso if ("audio" in results) out(`${clipId}: audio ${results.audio ? JSON.stringify(results.audio) : "as recorded"}`); if ("blur" in results) out(`${clipId}: blur ${results.blur ? JSON.stringify(results.blur) : "none (the picture as recorded)"}`); if ("layout" in results) out(`${clipId}: layout ${results.layout}`); + if ("fx" in results) out(`${clipId}: fx ${results.fx ? JSON.stringify(results.fx) : "none"}`); if (results.review) { const r = results.review; out(`${clipId}: ${r.verdict ?? "not reviewed"}${r.reason ? ` (${r.reason})` : ""}${r.correction ? ` — ${r.correction}` : ""}`); diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs @@ -20,6 +20,7 @@ // 4. GUARD ON THE FILE'S OWN MTIME. A PUT carrying a stale token is a 409, not // a silent overwrite -- somebody may have run `resolve-windows --write` in // between, and losing that is losing human judgement. +import { statSync } from "node:fs"; import { copyFile, readFile, rename, stat, writeFile } from "node:fs/promises"; import path from "node:path"; import { @@ -46,6 +47,7 @@ import { loadPreset, resolvePresetLayers } from "umtool-report-to-video/presets" import { storyClipErrors } from "umtool-report-to-video/modules/story-settings"; import { counterOrder } from "umtool-report-to-video/counter"; import { validateFinaleEntries } from "umtool-report-to-video/finale"; +import { validateFxEntries } from "umtool-report-to-video/fx"; import { validateClipAudio } from "umtool-report-to-video/clip-audio"; import { BLUR_CAPTION_DEFAULT, BLUR_STRENGTH, validateClipBlur, validateClipBlurEntries } from "umtool-report-to-video/clip-blur"; import { @@ -199,7 +201,7 @@ export async function updateClip(dir, clipId, patch, { token = null, edit = "tri // Re-read INSIDE the lock, every time. Nothing is held across requests. const raw = await readFile(manifestFile(dir), "utf8"); const manifest = JSON.parse(raw); - const { entry, before } = patchClipEntry(manifest, clipId, patch, { edit, now, raw }); + const { entry, before } = patchClipEntry(manifest, clipId, patch, { edit, now, raw, dir }); const nextToken = await writeManifestAtomic(dir, manifest); // A moved extent may need a new bench excerpt: queued, never waited for. if (entry.start !== before.start || entry.end !== before.end) benchPrepAfterWrite(dir, [clipId]); @@ -217,12 +219,13 @@ export async function updateClip(dir, clipId, patch, { token = null, edit = "tri * @param {Record<string, any>} manifest * @param {string} clipId * @param {Record<string, unknown>} patch - * @param {{ edit?: string, now?: string | null, raw?: string | null }} [opts] + * @param {{ edit?: string, now?: string | null, raw?: string | null, dir?: string | null }} [opts] * `raw`: the manifest's text before the patch, when the caller has it (the - * finale check compares against it); else it is taken here. + * finale check compares against it); else it is taken here. `dir`: the + * project's directory, where an `fx` screenshot written here must be. * @returns {{ entry: Record<string, any>, before: { start: number, end: number } }} */ -export function patchClipEntry(manifest, clipId, patch, { edit = "trim", now = null, raw = null } = {}) { +export function patchClipEntry(manifest, clipId, patch, { edit = "trim", now = null, raw = null, dir = null } = {}) { const original = patch.layout !== undefined ? (raw ?? JSON.stringify(manifest)) : null; const entry = (manifest.timeline ?? []).find((e) => e.id === clipId); if (!entry) throw new Error(`no timeline entry with id ${clipId}`); @@ -238,6 +241,13 @@ export function patchClipEntry(manifest, clipId, patch, { edit = "trim", now = n const before = { start: entry.start, end: entry.end }; const cutBefore = cutOf(entry); + // The effects' fields as they were, for a check that refuses only what a + // write ADDS: a window save, or an fx write, under an fx that already had + // a problem is not blamed for it. + const fxWrite = patch.fx !== undefined || FX_ENTRY_FIELDS.some((k) => patch[`fx.${k}`] !== undefined); + const fxWas = fxWrite || ((patch.start !== undefined || patch.end !== undefined) && entry.fx !== undefined) + ? new Set(entryFxErrors(structuredClone(entry))) + : null; for (const k of WINDOW_FIELDS) { if (patch[k] === undefined) continue; const v = Number(patch[k]); @@ -607,6 +617,38 @@ export function patchClipEntry(manifest, clipId, patch, { edit = "trim", now = n } } + // ---- the clip's effects (video knobs) ------------------------------------ + // + // `fx: { punch, quote, punchIn, speakers, receipts, zoom }` -- read by the + // effects page (report-to-video fx.mjs, whose validateFxEntries is the + // check) and inert until its effect is on (`render.chrome.fx`). `fx` whole + // replaces them all (null or "" removes `fx`); `fx.<field>` sets that one + // and keeps the rest (null or "" removes it); nothing left removes `fx`. A + // screenshot (`fx.zoom.shot`, `fx.receipts[].shot`) is a file in the + // project, as the build reads it (relative to the manifest); a bare name + // that is only under the project's `shots/` is written as `shots/<name>`. + if (fxWrite) { + let next = {}; + if (patch.fx !== undefined && patch.fx !== null && patch.fx !== "") { + if (!isObj(patch.fx)) throw new Error(`fx must be { ${FX_ENTRY_FIELDS.join(", ")} } (each optional), or null to clear it`); + next = { ...patch.fx }; + } else if (patch.fx === undefined && isObj(entry.fx)) next = { ...entry.fx }; + for (const k of FX_ENTRY_FIELDS) { + const v = patch[`fx.${k}`]; + if (v === undefined) continue; + if (v === null || v === "") delete next[k]; + else next[k] = v; + } + for (const k of Object.keys(next)) if (next[k] === null || next[k] === "") delete next[k]; + next = normalizeFx(next, dir, patch); + if (Object.keys(next).length) entry.fx = next; + else delete entry.fx; + } + if (fxWas) { + const bad = entryFxErrors(entry).filter((e) => !fxWas.has(e)); + if (bad.length) throw new Error(bad.join("; ")); + } + // ---- an assistant's clip, edited by a person (release 35 C2) ------------- // // A clip the clip finder proposed carries `assist`. The first human edit @@ -630,6 +672,77 @@ export function patchClipEntry(manifest, clipId, patch, { edit = "trim", now = n // --------------------------------------------------------------------------- const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v); + +/** A clip's effect fields (`fx.<field>`): fx.mjs validateFxEntries's list. */ +export const FX_ENTRY_FIELDS = Object.freeze(["punch", "quote", "punchIn", "speakers", "receipts", "zoom"]); + +/** validateFxEntries's sentences about ONE entry's own `fx` (not the cut's effects). */ +function entryFxErrors(entry) { + return validateFxEntries({ timeline: [entry], render: {} }); +} + +/** + * An `fx` as it is stored: the words trimmed, seconds to 2 dp, a box's + * fractions to 4, and each screenshot the patch names checked against the + * project's files (`dir`) -- the shape is validateFxEntries's to judge. + */ +function normalizeFx(fx, dir, patch) { + const r2 = (v) => (typeof v === "number" && Number.isFinite(v) ? round2(v) : v); + const r4 = (v) => (typeof v === "number" && Number.isFinite(v) ? Number(v.toFixed(4)) : v); + const box = (b) => (Array.isArray(b) ? b.map(r4) : b); + const out = { ...fx }; + if (typeof out.punch === "string") out.punch = out.punch.trim(); + if (Array.isArray(out.punchIn)) out.punchIn = out.punchIn.map(r2); + if (Array.isArray(out.speakers)) out.speakers = out.speakers.map((x) => (isObj(x) ? { ...x, at: r2(x.at) } : x)); + const named = (k) => (patch.fx !== undefined && patch.fx !== null && patch.fx !== "") || patch[`fx.${k}`] !== undefined; + if (isObj(out.zoom)) { + const z = { ...out.zoom }; + if (z.focus !== undefined) z.focus = box(z.focus); + if (z.at !== undefined) z.at = r2(z.at); + if (z.hold !== undefined) z.hold = r2(z.hold); + if (named("zoom")) z.shot = projectShot(z.shot, dir, "fx.zoom.shot"); + out.zoom = z; + } + if (Array.isArray(out.receipts)) { + out.receipts = out.receipts.map((c, i) => { + if (!isObj(c)) return c; + const r = { ...c }; + if (r.mark !== undefined) r.mark = box(r.mark); + if (named("receipts")) r.shot = projectShot(r.shot, dir, `fx.receipts[${i}].shot`); + return r; + }); + } + return out; +} + +/** + * A screenshot path as the build reads it -- relative to the manifest, so a + * file in the project -- or a refusal naming where it was looked. A bare + * name found only under the project's `shots/` is that path. Without `dir` + * (no project to look in) the path is left to the shape check. + */ +function projectShot(shot, dir, what) { + if (!dir || typeof shot !== "string" || !shot.trim() || /^[a-z]+:\/\//i.test(shot)) return shot; + const rel = shot.trim().replace(/\\/g, "/"); + const root = path.resolve(dir); + const inside = (p) => { + const r = path.relative(root, p); + return !!r && !r.startsWith("..") && !path.isAbsolute(r); + }; + const isFile = (p) => { + try { + return statSync(p).isFile(); + } catch { + return false; + } + }; + const file = path.resolve(root, rel); + if (!inside(file)) throw new Error(`${what} ${rel} must be a file in the project (a path relative to it), not outside it`); + if (isFile(file)) return rel; + if (!rel.includes("/") && isFile(path.join(root, "shots", rel))) return `shots/${rel}`; + throw new Error(`${what} ${rel} is not a file in the project (looked for ${rel}${rel.includes("/") ? "" : ` and shots/${rel}`} in ${root})`); +} + /** How many edits a clip keeps; the oldest go first. */ export const ASSIST_EDITS_MAX = 200; /** What updateClip restores from (a sentinel: the edges are read inside the lock). */ diff --git a/umtool/lib/report/takeEdit.mjs b/umtool/lib/report/takeEdit.mjs @@ -193,7 +193,7 @@ export async function updateTakeClip(projectDir, id, clipId, patch, { token = nu id, edit === "trim" ? "clip" : edit, token, - (m) => patchClipEntry(m, clipId, patch, { edit, now: now.toISOString() }), + (m) => patchClipEntry(m, clipId, patch, { edit, now: now.toISOString(), dir: projectDir }), { now }, ); } diff --git a/umtool/report-to-video/fx.mjs b/umtool/report-to-video/fx.mjs @@ -19,7 +19,12 @@ // timeline entry: "fx": { "punch": "…", "quote": false, "punchIn": [<source s>, …], // "speakers": [{ "at": <source s>, "who": 0 | 1 }], // "receipts": [{ "shot": "shots/a.png", "mark": [x0, y0, x1, y1] }], -// "zoom": { "shot": "shots/b.png", "focus": [x0, y0, x1, y1], "at": 1.2 } } +// "zoom": { "shot": "shots/b.png", "focus": [x0, y0, x1, y1], "at": 1.2, "hold": 4 } } +// (a zoom is up from 0.2 s into its clip's clean span -- the card rising in +// over 0.38 s, its focus box drawing at +0.55 s -- pushes in at `at` (seconds +// into the clip; default as soon as the box has drawn) over FX_MOTION.push, +// then drifts on the detail; it leaves (a 0.3 s fade) 0.3 s before the clip's +// clean span ends -- or, with `hold`, that many seconds after the push lands.) // // Every key is opt-in; `render.chrome.fx` absent (or null, or {}) draws nothing // and every schedule, graph and file is byte for byte what it was. An entry's @@ -41,6 +46,8 @@ export const FX_QUOTE_POSITIONS = Object.freeze(["bottom", "top"]); export const FX_RAIL_POSITIONS = Object.freeze(["top", "bottom"]); export const FX_SIDES = Object.freeze(["right", "left"]); export const FX_GLITCH_ON = Object.freeze(["year", "every", "clips"]); +/** A zoom's `hold` (seconds on the detail after the push lands): its bounds. Absent: until its clip's end. */ +export const FX_ZOOM_HOLD = Object.freeze({ min: 0.5, max: 10 }); /** The most clips a glitch on "clips" may name. */ export const FX_GLITCH_CLIPS_MAX = 60; export const FX_DATES = Object.freeze(["date", "year"]); @@ -323,13 +330,16 @@ export function validateFxEntries(manifest) { } if (e.fx.zoom !== undefined) { const z = e.fx.zoom; - if (!isObj(z)) errors.push(`${w}.zoom must be { shot, focus, at? }`); + if (!isObj(z)) errors.push(`${w}.zoom must be { shot, focus, at?, hold? }`); else { - for (const k of Object.keys(z)) if (!["shot", "focus", "at"].includes(k)) errors.push(`${w}.zoom.${k} is not a zoom field`); + for (const k of Object.keys(z)) if (!["shot", "focus", "at", "hold"].includes(k)) errors.push(`${w}.zoom.${k} is not a zoom field`); const se = shotError(z.shot, `${w}.zoom.shot`); if (se) errors.push(se); if (!rect01(z.focus)) errors.push(`${w}.zoom.focus must be [left, top, right, bottom], fractions of the shot`); if (z.at !== undefined && !numIn(z.at, 0, 600)) errors.push(`${w}.zoom.at must be seconds into the clip`); + if (z.hold !== undefined && !numIn(z.hold, FX_ZOOM_HOLD.min, FX_ZOOM_HOLD.max)) { + errors.push(`${w}.zoom.hold must be from ${FX_ZOOM_HOLD.min} to ${FX_ZOOM_HOLD.max} seconds (on the detail after the push), or absent for the whole clip`); + } } } } @@ -798,7 +808,10 @@ export function fxSchedule({ segments, entries, metas = [], render, D, total, wo if (outT - inn < 2) continue; const outline = inn + 0.55; const push = Math.min(outT - FX_MOTION.push - 0.3, Math.max(outline + FX_MOTION.outline + 0.2, Number.isFinite(z.at) ? c.start + z.at : 0)); - rows.push({ segment: c.id, in: r3(inn), out: r3(outT), shot: z.shot, focus: z.focus, outline: r3(outline), push: r3(push) }); + // `hold`: that long on the detail once the push lands, then it leaves + // (its 0.3 s fade ends `out`); never past the clip's own leave. + const out = Number.isFinite(z.hold) ? Math.min(outT, push + FX_MOTION.push + z.hold + 0.3) : outT; + rows.push({ segment: c.id, in: r3(inn), out: r3(out), shot: z.shot, focus: z.focus, outline: r3(outline), push: r3(push) }); } out.zoom = { width: zm.width, clips: rows }; } diff --git a/umtool/report-to-video/modules/fx.mjs b/umtool/report-to-video/modules/fx.mjs @@ -22,6 +22,8 @@ export default defineModule({ rows: [ ["`render.chrome.fx.<effect>`", "scrubber · receipts · zoom · kineticQuote · redact · odometer · punchIn · thenNow · whip · glitch", "a take: `umtool take <p> --effect <name>`"], ["`render.chrome.fx.glitch.on`, `.clips`", "`year` (a tear at each cut between years) · `every` (each cut between clips) · `clips` (only the cut INTO each clip `clips` names: 1–60 ids, each with a clip right before it) · default `year`; `clips` only with `on: \"clips\"`. `.seconds` 0.2–1.5 · 0.5, `.stamp` (the `PLAY ▶` date) · `true`, `.year` (the new year big over the tear; `false` with `stamp: false` is a bare tear, no text) · `true`", "manifest"], + ["a clip's `fx` — what an effect draws on it, inert until that effect is on: `zoom` `{shot, focus, at?, hold?}`, `receipts` `[{shot, mark?}]` (1–4), `punch` (the words), `quote` (false: no line), `punchIn` `[source s…]` (1–8, inside the clip), `speakers` `[{at, who: 0|1}]`. A `shot` is a file in the project (a bare name under its `shots/` is written as `shots/<name>`); `focus`/`mark` are `[left, top, right, bottom]` fractions of it", "`fx.<field>=<json>` sets one and keeps the rest · `fx=<json>` all · `fx=` none; checked by the build's own `validateFxEntries`", "`umtool set <p> <clip> fx.zoom='{\"shot\":\"shots/x.png\",\"focus\":[0.1,0.2,0.9,0.4],\"at\":5.9}'` · `PUT /api/report/window {project, clip, fx}` (or `\"fx.zoom\"`, …)"], + ["the zoom's timing (`fx.zoom.at`, `.hold`)", "up 0.2 s into the clip's clean span (the card rises in over 0.38 s, `back.out`); its focus box draws 0.55 s later (0.45 s); it pushes in on the box at `at` — seconds into the clip, default as soon as the box has drawn — over 1 s (`power2.inOut`), then drifts slowly on the detail. It leaves with a 0.3 s fade 0.3 s before the clip's clean span ends, or with `hold` (0.5–10 s) that long after the push lands (never past the clip's own leave)", "`fx.zoom='{…,\"hold\":4}'`"], ], }, region: "fx",