commit fd2d199705aefd5ebcedba73d36fc82d0fdd2c9a
parent 0e4d2ba843970f1d610ff91bc1e05bec22d29427
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 19 Oct 2026 00:25:01 -0400
report-to-video: reaction-highlight effects — two-voice kinetic captions (side and colour per speaker, from fx.speakers or the captions' >> / dash turns), a punch-in on marked seconds and captioned laughs (a crop of the box at the join), whip cuts (slideleft + streaks); the Reaction preset
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
9 files changed, 548 insertions(+), 39 deletions(-)
diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md
@@ -401,10 +401,14 @@ pages apart is how somebody edits the wrong one.
### Effects (`render.chrome.fx`, release 35)
-Eight overlay effects drawn over the footage box of a deck cut — a kinetic
-quote, a redaction reveal, an odometer, a timeline scrubber, a VHS glitch at a
-cut between years, a THEN/NOW wipe, receipts (screenshots fanned in with a
-marker on the cited line) and a zoom to detail. Every key, its defaults and
+Ten effects for a deck cut, drawn over its footage box — a kinetic quote (two
+speakers on their own sides and colours), a redaction reveal, an odometer, a
+timeline scrubber, a VHS glitch at a cut between years, a THEN/NOW wipe, a whip
+cut, a punch-in on a laugh, receipts (screenshots fanned in with a marker on
+the cited line) and a zoom to detail. **Reaction highlights** (a host reacting
+to a video) have their own preset: the two-voice captions, punch-ins on the
+laughs the captions write and on seconds a person marks (`fx.punchIn`), whip
+cuts and a running count. Every key, its defaults and
what it draws are the pipeline's README
([`render.chrome.fx`](../report-to-video/README.md#renderchromefx--the-effects-release-35));
umtool's part is auditioning them as takes:
diff --git a/umtool/e2e/takes.spec.ts b/umtool/e2e/takes.spec.ts
@@ -156,6 +156,23 @@ const MAKE_DIR = path.join(HERE, "..", ".e2e-song", "reports", "takes-make-fixtu
const MAKE_PAGE = urls.takesHref("reports/takes-make-fixture");
const readText = (rel: string) => readFileSync(path.join(MAKE_DIR, rel), "utf8");
+test("New take's Effect list fills the patch with an effect's preset, and None empties it (release 35)", async ({ page }) => {
+ await page.goto(MAKE_PAGE);
+ await page.locator("[data-action='new-take-open']").click();
+ const effect = page.locator("[data-take-effect]");
+ await expect(effect).toBeEnabled();
+ await expect(effect.locator("option[value='glitch']")).toHaveCount(1);
+ await expect(effect.locator("option[value='everything']")).toHaveCount(1);
+ await effect.selectOption("glitch");
+ await expect(page.locator("[data-take-label]")).toHaveValue("VHS glitch");
+ const patch = JSON.parse(await page.locator("[data-take-patch]").inputValue());
+ expect(patch.render.chrome.fx).toEqual({ glitch: {} });
+ expect(patch.render.chrome.layout).toBe("deck");
+ await expect(page.locator("[data-action='make-take']")).toBeEnabled();
+ await effect.selectOption("");
+ await expect(page.locator("[data-take-patch]")).toHaveValue("");
+});
+
test("the take maker: New take with a style, the take appears, Use this take makes it the project's manifest", async ({ page, request }) => {
test.setTimeout(240_000);
await page.goto(MAKE_PAGE);
diff --git a/umtool/report-to-video/README.md b/umtool/report-to-video/README.md
@@ -736,7 +736,7 @@ forced over a draft of it, which it then replaces.
### `render.chrome.fx` — the effects (release 35)
-Eight overlay effects for a deck cut, each opt-in under `render.chrome.fx`
+Ten effects for a deck cut, each opt-in under `render.chrome.fx`
and drawn by ONE HyperFrames page for the whole cut over exactly the footage
box (`fxGeometry`): overlays on the evidence, never cards. Absent (or `null`,
or `{}`, or every effect `null`) nothing here runs and every schedule, graph
@@ -745,17 +745,22 @@ defaults.
```jsonc
"render": { "transition": 0.4, "chrome": { …, "fx": {
- "kineticQuote": { "position": "bottom", "size": 54, "maxWords": 12, "clips": ["c01", "c03"] },
+ "kineticQuote": { "position": "bottom", "size": 54, "maxWords": 12, "clips": ["c01", "c03"],
+ "speakers": "auto", "voices": [{ "label": "Host" }, { "label": "Video", "color": "#22ab83" }] },
"redact": { "position": "bottom", "size": 44, "maxWords": 14, "clips": ["c02"] },
"odometer": { "position": "top-right", "label": "times", "at": "phrase" },
"scrubber": { "position": "top", "thumbs": true },
"glitch": { "on": "year", "seconds": 0.5, "stamp": true },
"thenNow": { "pairs": [{ "then": "c03", "now": "c04" }], "seconds": 0.6, "dates": "date" },
"receipts": { "position": "right", "width": 0.36 },
- "zoom": { "width": 0.56 }
+ "zoom": { "width": 0.56 },
+ "punchIn": { "scale": 1.2, "hold": 1.4, "anchor": "upper", "auto": true },
+ "whip": { "on": "every" }
} } }
{ "type": "clip", "id": "c02", …, "fx": {
"punch": "slow news week", // the words to punch (else montage.match)
+ "punchIn": [1834.2], // source seconds the picture snaps in on
+ "speakers": [{ "at": 1830.0, "who": 1 }, { "at": 1833.1, "who": 0 }], // which of two voices, from each second
"quote": false, // this clip draws no line
"receipts": [{ "shot": "shots/a.png", "mark": [0.02, 0.35, 0.86, 0.41] }], // 1–4 screenshots
"zoom": { "shot": "shots/b.png", "focus": [0.02, 0.40, 0.93, 0.52], "at": 1.5 } } }
@@ -764,16 +769,19 @@ defaults.
| effect | what it draws |
|---|---|
| `kineticQuote` | The clip's line, word by word as it is said, on a band of the ground at the box's foot (or head). The punch phrase (`fx.punch`, else `montage.match`) pops in at 1.8× in the accent with an underline sweeping under it. Pages of at most `maxWords`, broken after a clause once half full. |
+| (two voices) | With `speakers: "auto"` (the default) a kinetic line that has two speakers gives each its own pages, side and colour — the first voice on the left in `fg`, the second on the right in THEN's blue, or `voices[i].color` — with `voices[i].label` over its words when the manifest names one. Who speaks is the clip's `fx.speakers` (source seconds, each holding until the next), else the captions' own turn marks (`>>`, a dash before the words), each turn handing over to the other voice; when the captions mark turns the build reads the words from them rather than whisper.cpp's (which carry none). It says WHICH of two voices, never whose: no label is drawn unless the manifest gives one. `speakers: false` keeps one voice. |
| `redact` | The same line as a page of transcript, every word under a black bar; each bar lifts off as its word is said, the punch phrase highlighted in amber when it is revealed. `kineticQuote` and `redact` are one treatment a clip: when both are on, give one of them `clips` (a clip named by neither falls to the one without a list). |
| `odometer` | A counter in a corner: rolling digits, the count going up on each clip — `montage.n` when the clip has it, else its place — at the punch phrase (`at: "phrase"`, else a quarter second in), a 9 rolling on to the next 0. `label` under it ("times"; "" for none). |
| `scrubber` | A date rail across the box: a year mark per new year, a tick per dated clip, a playhead that slides to each clip's day as it comes in, with a thumbnail of the clip (its segment's middle frame, `thumbs`) and its date riding under it. The rail keeps clear of an odometer in a corner on its edge. |
| `glitch` | A VHS tear at each cut between two years (`on: "every"`: every cut between clips): scanlines, torn bars in two channels and noise for `seconds` centred on the cut, the new year big with its colours split, and a `PLAY ▶` date stamp in the corner (`stamp`). Seeded, so every frame is the same tear on every render. |
| `thenNow` | For each pair — a clip and the very next one — a divider sweeps across the box with the THEN clip's date riding its left and the NOW clip's its right, a scrim on the THEN side. With a crossfade (`transition` > 0) the cut itself becomes a wipe (`xfade=transition=wipeleft`, on that join only) and the divider rides its edge, x = W·(1 − p), over the transition; on a hard cut the divider sweeps alone over `seconds`, centred on the cut. `dates: "year"` shows years only. |
| `receipts` | A clip's screenshots (`fx.receipts`, beside the manifest: png/jpg/webp) fly in one after another and fan on one side of the box (`width` of it), then a marker swipes amber over each card's `mark` (fractions of the shot: left, top, right, bottom). They fly out before the clip leaves. |
+| `punchIn` | The picture snaps in to `scale` (1.2) on each of a clip's `fx.punchIn` seconds — and, with `auto`, on each laugh its captions write ("haha", "lol", "lmao") — for `hold` seconds, about the upper third (`anchor: "upper"`) or the middle, with a white flash and a viewfinder's corners closing on it. Made where the cut is joined (`punchInParts`: the box cropped and scaled back over itself, between those seconds of the segment's clock), so no segment file changes; the hard-cut record names it. |
+| `whip` | Every cut between two clips (`on: "year"`: between years) slides like a whip pan — `xfade=transition=slideleft` on that join over the transition — with streaks of light raking across the box; on a hard cut the streaks alone flash across it. A THEN/NOW pair's cut stays a wipe. |
| `zoom` | A clip's screenshot (`fx.zoom`) drops in at the middle of the box, a focus box locks on to `focus`, then the card pushes in until the focus fills it (at the clip's `at` seconds when set) and drifts on the detail until the clip leaves. |
-- **The schedule.** `schedule.json` gains `fx: { keys, quotes?, quoteStyle?,
- odometer?, scrubber?, glitch?, thenNow?, receipts?, zoom? }` (`fxSchedule`,
+- **The schedule.** `schedule.json` gains `fx: { keys, box, quotes?, quoteStyle?,
+ odometer?, scrubber?, glitch?, thenNow?, whip?, punchIn?, receipts?, zoom? }` (`fxSchedule`,
fx.mjs) — only when an effect is on. Every time is in the cut's seconds: a
clip is drawn on from its mid-dissolve in to its mid-dissolve out, never
over a segment the deck hides (a card, a teaser). The words are the build's:
diff --git a/umtool/report-to-video/build-video.mjs b/umtool/report-to-video/build-video.mjs
@@ -141,10 +141,10 @@ import {
assertChrome, deckGeometry, deckOn, deckSchedule, endFadeOf, feedGeometry, feedOn, frameCount, hidesDeck, MUTE_FADE,
dipOf, muteSegmentSeconds, playWindow, postsGeometry, postWindows, resolveDeck, scheduleFrom, snapWindow, stampGeometry,
statsGeometry, teaserHits, teaserSeconds, teaserTitle, threadsGeometry,
- validateCutEdits, validatePosts, validateTeasers, fxGeometry,
+ validateCutEdits, validatePosts, validateTeasers, fxGeometry, even as evenPx,
} from "./deck.mjs";
// The effects region (`render.chrome.fx`, release 35): pure, in fx.mjs.
-import { fxOn, fxQuoteSpan, fxWipeJoins, fxWordsOf, validateFxEntries } from "./fx.mjs";
+import { fxOn, fxQuoteSpan, resolveFx, fxWhipJoins, fxWipeJoins, fxWordsOf, fxZoomJoins, validateFxEntries } from "./fx.mjs";
import { validateClaims } from "./factcheck.mjs";
import { validateThreadEntries } from "./threads.mjs";
import { validateFlipEntries } from "./flips.mjs";
@@ -3412,12 +3412,19 @@ export function segmentJoins(schedule) {
const moves = new Map((schedule.moves ?? []).map((m) => [m.segment, m]));
// A THEN/NOW pair's cut is a wipe (fx.mjs `thenNow`): on the THEN segment's
// join, for the transition out of it. Only when a pair asks.
+ // A whip cut (fx.mjs `whip`) likewise, where no wipe is; a punch-in
+ // (`punchIn`) on the segment it zooms. Only when the effects ask.
const wipes = fxWipeJoins(schedule);
+ const whips = fxWhipJoins(schedule);
+ const zooms = fxZoomJoins(schedule);
const joins = schedule.segments.map((s, i) => {
const hold = s.hold > 0 ? s.hold : 0;
const move = moves.get(s.id) ?? null;
- const j = hold || move ? { hold, move } : null;
- return wipes.has(i) ? { hold: 0, move: null, ...(j ?? {}), wipe: true } : j;
+ let j = hold || move ? { hold, move } : null;
+ if (wipes.has(i)) j = { hold: 0, move: null, ...(j ?? {}), wipe: true };
+ else if (whips.has(i)) j = { hold: 0, move: null, ...(j ?? {}), whip: true };
+ if (zooms.has(i)) j = { hold: 0, move: null, ...(j ?? {}), zoom: zooms.get(i) };
+ return j;
});
return joins.some(Boolean) ? joins : null;
}
@@ -3560,6 +3567,14 @@ export const endFadeAudioFilter = (fade, render) => {
export function joinInputChain(i, join, render) {
if (!join) return { parts: [], v: `[${i}:v]`, a: `[${i}:a]` };
const parts = [];
+ // The punch-ins first, in the segment's own clock (before a hold clones
+ // its last frame): each a crop of the footage box scaled back over it.
+ let vin = `[${i}:v]`;
+ if (join.zoom?.length) {
+ const z = punchInParts(i, join.zoom, render, vin);
+ parts.push(...z.parts);
+ vin = z.v;
+ }
// Picture: hold, move, end fade. Sound: mute, hold, end fade, dip -- the
// mute is in the clip's own clock and the hold is silence anyway; the end
// fade (the last segment) and the dip (one before a teaser that dips) are
@@ -3569,8 +3584,8 @@ export function joinInputChain(i, join, render) {
join.move ? moveFilter(join.move, render) : null,
join.fade ? endFadeVideoFilter(join.fade, render) : null,
].filter(Boolean);
- const v = vf.length ? `[j${i}v]` : `[${i}:v]`;
- if (vf.length) parts.push(`[${i}:v]${vf.join(",")}${v}`);
+ const v = vf.length ? `[j${i}v]` : vin;
+ if (vf.length) parts.push(`${vin}${vf.join(",")}${v}`);
const af = [
join.mute != null ? muteAudioFilter(join.mute) : null,
join.hold > 0 ? holdAudioFilter(join.hold) : null,
@@ -3585,6 +3600,35 @@ export function joinInputChain(i, join, render) {
}
/**
+ * A segment's punch-ins (fx.mjs `punchIn`) as graph parts on input `vin`:
+ * for each, the footage box's central (or upper-third) 1/scale cropped and
+ * scaled back to the box, laid over it from `at` to `until` (segment
+ * seconds). A snap, whole frames either side; everything outside the box --
+ * the ground the deck framing left -- is untouched.
+ *
+ * @returns {{ parts: string[], v: string }}
+ */
+export function punchInParts(i, zooms, render, vin) {
+ const parts = [];
+ let lab = vin;
+ zooms.forEach((z, k) => {
+ // The box the schedule drew the effects over (the feed's, the rail's), else the deck's.
+ const b = z.box ?? deckGeometry(render).footage;
+ const w = evenPx(b.width / z.scale), h = evenPx(b.height / z.scale);
+ const x = b.x + Math.round((b.width - w) / 2);
+ const y = b.y + Math.round((b.height - h) * (z.anchor === "center" ? 0.5 : 0.25));
+ const out = `[j${i}z${k}]`;
+ parts.push(
+ `${lab}split=2[j${i}z${k}a][j${i}z${k}b]`,
+ `[j${i}z${k}b]crop=${w}:${h}:${x}:${y},scale=${b.width}:${b.height}:flags=lanczos,setsar=1[j${i}z${k}c]`,
+ `[j${i}z${k}a][j${i}z${k}c]overlay=${b.x}:${b.y}:enable='between(t,${exprNum(z.at)},${exprNum(z.until)})'${out}`,
+ );
+ lab = out;
+ });
+ return { parts, v: lab };
+}
+
+/**
* The joins with the cut's edits merged in: a `muteFrom` (`mutes`: segment
* index → segment seconds), the end fade on the LAST segment
* (`fade`: `{ seconds, lastFrame }`) and a dip on the segment BEFORE a teaser
@@ -3768,7 +3812,9 @@ export function xfadeGraph(durs, D, joins = null, render = null, { joined = fals
// A THEN/NOW pair's cut (fx.mjs `thenNow`): the NOW clip wipes in from the
// right, its edge at x = W·(1 − p) -- where the effects' divider rides.
const wipe = !dip && !!joins?.[i - 1]?.wipe;
- const vx = dip ? "transition=custom:expr='A'" : wipe ? "transition=wipeleft" : "transition=fade";
+ // A whip cut (fx.mjs `whip`): the NOW clip slides in as the last slides out.
+ const whip = !dip && !wipe && !!joins?.[i - 1]?.whip;
+ const vx = dip ? "transition=custom:expr='A'" : wipe ? "transition=wipeleft" : whip ? "transition=slideleft" : "transition=fade";
const ax = dip ? "c1=nofade:c2=nofade" : "c1=tri:c2=tri";
parts.push(`${vlab}${ins[i].v}xfade=${vx}:duration=${D}:offset=${off.toFixed(3)}[v${i}]`);
parts.push(`${alab}${ins[i].a}acrossfade=d=${D}:${ax}[a${i}]`);
@@ -3890,8 +3936,8 @@ export function xfadeBatchLengths(durs, D, batches) {
export function xfadeBatchJoins(joins, batches) {
const out = batches.map(({ to }) => {
const j = joins?.[to - 1];
- if (!j?.dip && !j?.wipe) return null;
- return { ...(j.dip ? { dip: j.dip } : {}), ...(j.wipe ? { wipe: true } : {}) };
+ if (!j?.dip && !j?.wipe && !j?.whip) return null;
+ return { ...(j.dip ? { dip: j.dip } : {}), ...(j.wipe ? { wipe: true } : {}), ...(j.whip ? { whip: true } : {}) };
});
return out.some(Boolean) ? out : null;
}
@@ -4547,7 +4593,11 @@ export async function fxClipWords({ entries, segments, provenance = {}, render }
clock.set(e.id, from);
const span = fxQuoteSpan(e);
let got = null;
- if (!hasLocalMedia(e) && FX_CHANNELS_DIR && e.video) {
+ // The captions first when they mark who speaks (">>", a dash) and the
+ // kinetic line tells the voices apart: whisper.cpp's words carry no turns.
+ const cueWords = fxWordsOf(await montageCues(e, provenance), span.from - 0.05, span.to + 0.05);
+ if (resolveFx(render, "kineticQuote")?.speakers === "auto" && cueWords.some((w) => w.turn)) got = cueWords;
+ if (!got && !hasLocalMedia(e) && FX_CHANNELS_DIR && e.video) {
try {
const dir = await resolveVideoDir(FX_CHANNELS_DIR, e.channel ?? provenance.channelSlug, e.video);
const doc = JSON.parse(await readFile(path.join(dir, "transcript.json"), "utf8"));
@@ -4557,8 +4607,8 @@ export async function fxClipWords({ entries, segments, provenance = {}, render }
got = null;
}
}
- if (!got?.length) got = fxWordsOf(await montageCues(e, provenance), span.from - 0.05, span.to + 0.05);
- if (got.length) words.set(e.id, got.map((w) => ({ text: w.text, start: w.start - from, end: w.end - from })));
+ if (!got?.length) got = cueWords;
+ if (got.length) words.set(e.id, got.map((w) => ({ text: w.text, start: w.start - from, end: w.end - from, ...(w.turn ? { turn: true } : {}) })));
}
return { words, clock };
}
@@ -4678,6 +4728,7 @@ export function concatRecordText(segments, joins = null) {
...(joins[i].mute != null ? { mute: joins[i].mute } : {}),
...(joins[i].fade ? { fade: joins[i].fade } : {}),
...(joins[i].dip ? { dip: joins[i].dip } : {}),
+ ...(joins[i].zoom ? { zoom: joins[i].zoom } : {}),
})}`]
: []));
return list + lines.join("\n") + "\n";
diff --git a/umtool/report-to-video/chrome-fx.mjs b/umtool/report-to-video/chrome-fx.mjs
@@ -275,9 +275,16 @@ export function fxPlan(schedule, render, assets = {}) {
}
return `<span class="w${w.punch ? " punch" : ""}">${hl}<span class="t">${esc(w.text)}</span><i class="bar" data-k="${bk}"></i></span>`;
}).join(" ");
+ // Two voices: each on its own side, in its own colour, with its label
+ // (the manifest's; none by default -- which voice, never whose).
+ const voices = schedule.fx.quoteStyle?.voices;
+ const vi = kinetic && voices && Number.isInteger(pg.speaker) ? pg.speaker : null;
+ const voice = vi != null ? voices[vi] : null;
+ const vstyle = voice?.color ? ` --vc:${voice.color};` : "";
+ const vlabel = voice?.label ? `<div class="q-voice">${esc(voice.label)}</div>` : "";
html.push(
- `<div class="fx-quote ${kinetic ? "kinetic" : "redact"} ${posTop ? "top" : "bottom"}" data-k="${pk}" data-segment="${esc(q.segment)}" style="font-size:${size}px">` +
- `<div class="q-inner">${words}</div></div>`,
+ `<div class="fx-quote ${kinetic ? "kinetic" : "redact"} ${posTop ? "top" : "bottom"}${vi != null ? ` voice v${vi}` : ""}" data-k="${pk}" data-segment="${esc(q.segment)}"${vi != null ? ` data-voice="${vi}"` : ""} style="font-size:${size}px;${vstyle}">` +
+ `<div class="q-inner">${vlabel}${words}</div></div>`,
);
});
}
@@ -326,6 +333,48 @@ export function fxPlan(schedule, render, assets = {}) {
);
}
+ // ---- the punch-in: a flash and a viewfinder as the footage snaps in -------------
+ if (fx.punchIn) {
+ fx.punchIn.punches.forEach((pn, n) => {
+ const fk = `pf${n}`, bk = `pb${n}`;
+ init[fk] = { autoAlpha: 0 };
+ set(fk, pn.at, { autoAlpha: 0.32 });
+ add(fk, pn.at + frame, 0.14, { autoAlpha: 0 }, "power2.out");
+ init[bk] = { autoAlpha: 0, scale: 1.12 };
+ set(bk, pn.at, { autoAlpha: 1, scale: 1.12 });
+ add(bk, pn.at + frame, 0.22, { scale: 1 }, "power3.out");
+ add(bk, Math.max(pn.at + 0.3, pn.until - 0.2), 0.2, { autoAlpha: 0 }, "power1.in");
+ html.push(
+ `<div class="fx-punch" data-segment="${esc(pn.segment)}"><div class="pi-flash" data-k="${fk}"></div>` +
+ `<div class="pi-frame" data-k="${bk}"><i class="tl"></i><i class="tr"></i><i class="bl"></i><i class="br"></i></div></div>`,
+ );
+ });
+ }
+
+ // ---- the whip: speed streaks across the cut ------------------------------------
+ if (fx.whip) {
+ fx.whip.cuts.forEach((wc, n) => {
+ const rnd = fxRandom(7919 * (n + 3));
+ const streaks = [];
+ for (let j = 0; j < 9; j += 1) {
+ const key = `ws${n}_${j}`;
+ const y = Math.round(rnd() * (H - px(20)));
+ const h = Math.round(px(3) + rnd() * px(16));
+ const len = Math.round(W * (0.35 + rnd() * 0.5));
+ const delay = rnd() * wc.seconds * 0.3;
+ // Each streak enters a third of the way in and rakes off the left,
+ // fastest at the middle of the cut.
+ const x0 = Math.round(W - len * 0.35);
+ init[key] = { autoAlpha: 0, x: x0 };
+ set(key, wc.at + delay, { autoAlpha: 0.9 });
+ add(key, wc.at + delay + frame / 4, Math.max(frame, wc.seconds - delay), { x: -len - px(40) }, "sine.inOut");
+ set(key, wc.at + wc.seconds + frame, { autoAlpha: 0, x: x0 });
+ streaks.push(`<div class="wh-streak" data-k="${key}" style="top:${y}px; height:${h}px; width:${len}px"></div>`);
+ }
+ html.push(`<div class="fx-whip" data-segment="${esc(wc.segment)}">${streaks.join("")}</div>`);
+ });
+ }
+
// ---- THEN / NOW ----------------------------------------------------------------
if (fx.thenNow) {
const fw = render.width ?? 1920;
@@ -554,6 +603,14 @@ export function fxHtml(schedule, render, opts = {}) {
.fx-quote.kinetic .q-inner { color: ${pal.fg};
text-shadow: 0 0 ${px(2)}px rgba(0, 0, 0, 0.9), 0 ${px(2)}px ${px(3)}px rgba(0, 0, 0, 0.8), 0 ${px(4)}px ${px(18)}px rgba(0, 0, 0, 0.6); }
.fx-quote .w { position: relative; display: inline-block; }
+ /* Two voices: the first on the left, the second on the right, each its colour. */
+ .fx-quote.kinetic.voice .q-inner { color: var(--vc, ${pal.fg}); max-width: 74%; }
+ .fx-quote.kinetic.v0 { justify-content: flex-start; }
+ .fx-quote.kinetic.v0 .q-inner { text-align: left; }
+ .fx-quote.kinetic.v1 { justify-content: flex-end; }
+ .fx-quote.kinetic.v1 .q-inner { text-align: right; }
+ .fx-quote .q-voice { font-family: 'DeckSansBold', sans-serif; font-size: 0.42em; letter-spacing: 0.16em; text-transform: uppercase;
+ color: var(--vc, ${pal.accent}); margin-bottom: 0.1em; }
.fx-quote.kinetic .w { visibility: hidden; opacity: 0; }
.fx-quote.kinetic .w.punch { color: ${mix(pal.accent, "#ffffff", 0.12)};
text-shadow: 0 0 ${px(2)}px rgba(0, 0, 0, 0.9), 0 0 ${px(22)}px ${rgba(pal.accent, 0.7)}, 0 ${px(3)}px ${px(10)}px rgba(0, 0, 0, 0.7); }
@@ -583,6 +640,20 @@ export function fxHtml(schedule, render, opts = {}) {
text-transform: uppercase; color: ${pal.accent}; }
.od-pulse { position: absolute; inset: -${px(4)}px; border-radius: ${px(16)}px; box-shadow: 0 0 0 ${px(4)}px ${pal.accent}, 0 0 ${px(30)}px ${rgba(pal.accent, 0.8)}; }
+ /* The punch-in: a flash, and corner brackets closing on the picture. */
+ .fx-punch { position: absolute; inset: 0; }
+ .pi-flash { position: absolute; inset: 0; background: #ffffff; visibility: hidden; opacity: 0; }
+ .pi-frame { position: absolute; inset: ${px(26)}px; visibility: hidden; opacity: 0; }
+ .pi-frame i { position: absolute; width: ${px(64)}px; height: ${px(64)}px; border: 0 solid ${pal.fg};
+ filter: drop-shadow(0 0 ${px(6)}px rgba(0, 0, 0, 0.7)); }
+ .pi-frame .tl { left: 0; top: 0; border-left-width: ${px(6)}px; border-top-width: ${px(6)}px; }
+ .pi-frame .tr { right: 0; top: 0; border-right-width: ${px(6)}px; border-top-width: ${px(6)}px; }
+ .pi-frame .bl { left: 0; bottom: 0; border-left-width: ${px(6)}px; border-bottom-width: ${px(6)}px; }
+ .pi-frame .br { right: 0; bottom: 0; border-right-width: ${px(6)}px; border-bottom-width: ${px(6)}px; }
+ /* The whip: streaks of light raking across the cut. */
+ .fx-whip { position: absolute; inset: 0; }
+ .wh-streak { position: absolute; left: 0; border-radius: ${px(10)}px; visibility: hidden; opacity: 0;
+ background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.9) 70%, rgba(255, 255, 255, 0)); }
/* THEN / NOW: the divider, a scrim on the side that is THEN, and the two dates on its edges. */
.fx-wipe { position: absolute; inset: 0; }
.tn-scrim { position: absolute; left: 0; top: 0; height: ${H}px; background: ${rgba("#000000", 0.4)}; }
diff --git a/umtool/report-to-video/chrome-fx.test.mjs b/umtool/report-to-video/chrome-fx.test.mjs
@@ -420,3 +420,96 @@ appendFileSync(${JSON.stringify(path.join(dir, "runs.log"))}, a.join(" ") + "\\n
rmSync(dir, { recursive: true, force: true });
}
});
+
+// ---- reaction highlights -------------------------------------------------------------
+
+test("the page: two voices on their own sides and colours, with the manifest's labels", () => {
+ const ws = new Map([["c1", [
+ { text: "what", start: 1, end: 1.3 }, { text: "is", start: 1.3, end: 1.5 }, { text: "this", start: 1.5, end: 1.8 },
+ { text: "it's", start: 2.2, end: 2.5, turn: true }, { text: "news", start: 2.5, end: 2.9 },
+ ]]]);
+ const fx = { kineticQuote: { voices: [{ label: "Host" }, { label: "Video", color: "#22ab83" }] } };
+ const s = deckSchedule({ entries: [TIMELINE[0]], durs: [6.4], D: 0.5, render: render(fx), fxWords: ws });
+ const html = fxHtml(s, render(fx), { fonts: FONTS });
+ assert.match(html, /class="fx-quote kinetic bottom voice v0" data-k="qp0_0"[^>]*data-voice="0"/);
+ assert.match(html, /class="fx-quote kinetic bottom voice v1" data-k="qp0_1"[^>]*data-voice="1" style="font-size:\d+px; --vc:#22ab83;"/);
+ assert.ok(html.includes('<div class="q-voice">Host</div>') && html.includes('<div class="q-voice">Video</div>'));
+});
+
+test("pixels: the punch-in flashes the box white on its frame and is gone a fifth of a second on", { skip: !haveChromium }, async () => {
+ const fx = { punchIn: {} };
+ const { composeChrome } = await import("./compose-chrome.mjs");
+ const dir = mkdtempSync(path.join(tmpdir(), "fx-pi-"));
+ try {
+ const c1 = { ...TIMELINE[0], fx: { punchIn: [13] } };
+ const manifestPath = path.join(dir, "video.manifest.json");
+ writeFileSync(manifestPath, JSON.stringify({ slug: "t", title: "t", provenance: {}, render: render(fx), timeline: [c1] }));
+ const s = deckSchedule({ entries: [c1], durs: [6.4], D: 0.5, render: render(fx) });
+ const p = s.fx.punchIn.punches[0];
+ const still = async (t) => {
+ const png = path.join(dir, `pi-${t}.png`);
+ await composeChrome({ manifestPath, region: "fx", schedule: s, still: t, png });
+ return png;
+ };
+ const g = fxGeometry(render(fx));
+ const mid = [Math.round(g.width / 2) - 50, Math.round(g.height / 2) - 50, 100, 100];
+ assert.ok(inked(await still(p.at - FRAME), ...mid) < 0.01, "nothing before");
+ // The flash is white at a third: alpha ~82 of 255 over every pixel of the box.
+ const flash = crop(await still(p.at + FRAME / 2), ...mid);
+ let lit = 0;
+ for (let i = 0; i < flash.length; i += 4) if (flash[i + 3] > 60 && flash[i] > 240 && flash[i + 1] > 240 && flash[i + 2] > 240) lit += 1;
+ assert.ok(lit / (flash.length / 4) > 0.95, `the flash covers the box: ${lit}`);
+ assert.ok(inked(await still(p.at + 0.25), ...mid) < 0.01, "and is gone");
+ // The viewfinder's corners stay while the footage is in.
+ assert.ok(inked(await still(p.at + 0.5), 0, 0, 120, 120) > 0.05, "corner bracket");
+ } finally {
+ rmSync(dir, { recursive: true, force: true });
+ }
+});
+
+test("pixels: the whip's streaks rake across only during its cut", { skip: !haveChromium }, async () => {
+ const fx = { whip: {} };
+ const { dir, sched, still } = await project(fx);
+ try {
+ const w = sched.fx.whip.cuts[0];
+ const g = fxGeometry(render(fx));
+ const all = [0, 0, g.width, g.height];
+ assert.ok(inked(await still(w.at - FRAME), ...all) < 0.001, "clean before");
+ assert.ok(inked(await still(w.at + w.seconds / 2), ...all) > 0.005, "streaks mid-cut");
+ assert.ok(inked(await still(w.at + w.seconds + 2 * FRAME), ...all) < 0.001, "clean after");
+ } finally {
+ rmSync(dir, { recursive: true, force: true });
+ }
+});
+
+test("ffmpeg: the punch-in's graph changes the box between its seconds and nothing else", { skip: !haveFfmpeg }, async () => {
+ const { joinInputChain } = await import("./build-video.mjs");
+ const dir = mkdtempSync(path.join(tmpdir(), "fx-pi-ff-"));
+ try {
+ const r = render({});
+ const c = joinInputChain(0, { hold: 0, move: null, zoom: [{ at: 1, until: 1.5, scale: 1.25, anchor: "center" }] }, r);
+ const out = path.join(dir, "o.rgb");
+ const res = spawnSync("ffmpeg", ["-nostdin", "-v", "error", "-y", "-f", "lavfi", "-i", "testsrc2=s=1920x1080:r=30:d=2",
+ "-filter_complex", `${c.parts.join(";")};${c.v}format=rgb24[o]`, "-map", "[o]", "-f", "rawvideo", out], { maxBuffer: 1 << 28 });
+ assert.equal(res.status, 0, String(res.stderr));
+ const plain = path.join(dir, "p.rgb");
+ spawnSync("ffmpeg", ["-nostdin", "-v", "error", "-y", "-f", "lavfi", "-i", "testsrc2=s=1920x1080:r=30:d=2", "-vf", "format=rgb24", "-f", "rawvideo", plain]);
+ const a = readFileSync(out), b = readFileSync(plain);
+ const F = 1920 * 1080 * 3;
+ const frame = (buf, n) => buf.subarray(n * F, (n + 1) * F);
+ const region = (buf, n, x, y, w, h) => {
+ const f = frame(buf, n);
+ const rows = [];
+ for (let j = y; j < y + h; j += 1) rows.push(f.subarray((j * 1920 + x) * 3, (j * 1920 + x + w) * 3));
+ return Buffer.concat(rows);
+ };
+ // Frame 15 (0.5 s): untouched. Frame 36 (1.2 s): the box differs, the ground beside it does not.
+ assert.ok(frame(a, 15).equals(frame(b, 15)), "before the punch the frame is the input's");
+ assert.ok(!region(a, 36, 173, 2, 1574, 886).equals(region(b, 36, 173, 2, 1574, 886)), "the box is zoomed");
+ assert.ok(region(a, 36, 0, 0, 170, 1080).equals(region(b, 36, 0, 0, 170, 1080)), "left of the box untouched");
+ assert.ok(region(a, 36, 0, 900, 1920, 180).equals(region(b, 36, 0, 900, 1920, 180)), "below the box untouched");
+ assert.ok(frame(a, 50).equals(frame(b, 50)), "after it, the input's again");
+ } finally {
+ rmSync(dir, { recursive: true, force: true });
+ }
+});
diff --git a/umtool/report-to-video/deck.mjs b/umtool/report-to-video/deck.mjs
@@ -720,8 +720,8 @@ export function deckSchedule({
...(flips ? { flips } : {}),
// The stats region: present only when a clip declares it.
...(stats ? { stats } : {}),
- // The effects region: present only when an effect is on.
- ...(fx ? { fx } : {}),
+ // The effects region: present only when an effect is on, with the box it is drawn over.
+ ...(fx ? { fx: { ...fx, box: fxGeometry(render, { feed }) } } : {}),
// Present only when there are posts to draw, so a cut without them writes
// the schedule it always did.
...(placed.length ? { posts: roundPosts(placed) } : {}),
diff --git a/umtool/report-to-video/fx.mjs b/umtool/report-to-video/fx.mjs
@@ -11,8 +11,11 @@
// thenNow: { pairs: [{ then, now }], seconds, dates } a moving divider between a THEN clip and its NOW
// receipts: { position, width } a clip's screenshots fan in, a marker swipes the cited line
// zoom: { width } a screenshot pushed in on its focus box
+// punchIn: { scale, hold, anchor, auto } the footage snaps in on a moment (a laugh), then back
+// whip: { on } the cut between two clips slides like a whip pan
// }
-// timeline entry: "fx": { "punch": "…", "quote": false,
+// 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 } }
//
@@ -27,7 +30,7 @@
// deck.mjs), so the few date and phrase helpers it needs are its own.
/** Each effect's key under `render.chrome.fx`, in the order the page stacks them (later on top). */
-export const FX_KEYS = Object.freeze(["scrubber", "receipts", "zoom", "kineticQuote", "redact", "odometer", "thenNow", "glitch"]);
+export const FX_KEYS = Object.freeze(["scrubber", "receipts", "zoom", "kineticQuote", "redact", "odometer", "punchIn", "thenNow", "whip", "glitch"]);
export const FX_CORNERS = Object.freeze(["top-left", "top-right", "bottom-left", "bottom-right"]);
export const FX_QUOTE_POSITIONS = Object.freeze(["bottom", "top"]);
@@ -38,10 +41,16 @@ export const FX_DATES = Object.freeze(["date", "year"]);
export const FX_ODOMETER_AT = Object.freeze(["phrase", "start"]);
export const FX_SHOT_EXTS = Object.freeze([".png", ".jpg", ".jpeg", ".webp"]);
export const FX_RECEIPTS_MAX = 4;
+export const FX_ANCHORS = Object.freeze(["upper", "center"]);
+export const FX_WHIP_ON = Object.freeze(["every", "year"]);
+/** A kinetic line's two voices when the manifest names none: the palette's fg, then THEN's blue. */
+export const FX_VOICE_COLORS = Object.freeze([null, "#6fa8dc"]);
+/** The words a laugh is written as in captions (`punchIn.auto`). */
+export const FX_LAUGH_RE = /^(?:(?:ha){2,}h?|(?:he){2,}|lol|lmao|lmfao|rofl|laughs?|laughing|laughter)$/i;
/** Every effect's settings and their defaults. A manifest names only what it changes. */
export const FX_DEFAULTS = Object.freeze({
- kineticQuote: Object.freeze({ position: "bottom", size: 54, maxWords: 12, clips: null }),
+ kineticQuote: Object.freeze({ position: "bottom", size: 54, maxWords: 12, clips: null, speakers: "auto", voices: null }),
redact: Object.freeze({ position: "bottom", size: 44, maxWords: 14, clips: null }),
odometer: Object.freeze({ position: "top-right", label: "times", at: "phrase" }),
scrubber: Object.freeze({ position: "top", thumbs: true }),
@@ -49,6 +58,8 @@ export const FX_DEFAULTS = Object.freeze({
thenNow: Object.freeze({ pairs: Object.freeze([]), seconds: 0.6, dates: "date" }),
receipts: Object.freeze({ position: "right", width: 0.36 }),
zoom: Object.freeze({ width: 0.56 }),
+ punchIn: Object.freeze({ scale: 1.2, hold: 1.4, anchor: "upper", auto: true }),
+ whip: Object.freeze({ on: "every" }),
});
/** The motion every effect shares, in seconds. */
@@ -100,7 +111,7 @@ export function resolveFx(render, key) {
// ---------------------------------------------------------------------------
const ALLOWED = {
- kineticQuote: ["position", "size", "maxWords", "clips"],
+ kineticQuote: ["position", "size", "maxWords", "clips", "speakers", "voices"],
redact: ["position", "size", "maxWords", "clips"],
odometer: ["position", "label", "at"],
scrubber: ["position", "thumbs"],
@@ -108,6 +119,8 @@ const ALLOWED = {
thenNow: ["pairs", "seconds", "dates"],
receipts: ["position", "width"],
zoom: ["width"],
+ punchIn: ["scale", "hold", "anchor", "auto"],
+ whip: ["on"],
};
const oneOf = (list) => list.map((x) => `"${x}"`).join(", ");
@@ -147,6 +160,30 @@ export function validateFx(fx, where = "render.chrome.fx") {
}
}
}
+ if (k === "kineticQuote") {
+ if (v.speakers !== undefined && v.speakers !== "auto" && v.speakers !== false) errors.push(`${w}.speakers must be "auto" or false`);
+ if (v.voices !== undefined && v.voices !== null) {
+ if (!Array.isArray(v.voices) || v.voices.length < 1 || v.voices.length > 2) errors.push(`${w}.voices must be a list of one or two { label?, color? }`);
+ else {
+ v.voices.forEach((x, i) => {
+ if (!isObj(x) || Object.keys(x).some((kk) => kk !== "label" && kk !== "color")) errors.push(`${w}.voices[${i}] must be { label?, color? }`);
+ else {
+ if (x.label !== undefined && !(typeof x.label === "string" && x.label.trim().length <= 20)) errors.push(`${w}.voices[${i}].label must be at most 20 characters`);
+ if (x.color !== undefined && !/^#[0-9a-fA-F]{6}$/.test(String(x.color))) errors.push(`${w}.voices[${i}].color must be a #rrggbb colour`);
+ }
+ });
+ }
+ }
+ }
+ if (k === "punchIn") {
+ if (v.scale !== undefined && !numIn(v.scale, 1.05, 2)) errors.push(`${w}.scale must be from 1.05 to 2`);
+ if (v.hold !== undefined && !numIn(v.hold, 0.2, 6)) errors.push(`${w}.hold must be from 0.2 to 6 seconds`);
+ if (v.anchor !== undefined && !FX_ANCHORS.includes(v.anchor)) errors.push(`${w}.anchor must be ${oneOf(FX_ANCHORS)}`);
+ if (v.auto !== undefined && typeof v.auto !== "boolean") errors.push(`${w}.auto must be true or false`);
+ }
+ if (k === "whip") {
+ if (v.on !== undefined && !FX_WHIP_ON.includes(v.on)) errors.push(`${w}.on must be ${oneOf(FX_WHIP_ON)}`);
+ }
if (k === "odometer") {
if (v.position !== undefined && !FX_CORNERS.includes(v.position)) errors.push(`${w}.position must be ${oneOf(FX_CORNERS)}`);
if (v.label !== undefined && !(typeof v.label === "string" && v.label.trim().length <= 24)) {
@@ -226,12 +263,25 @@ export function validateFxEntries(manifest) {
if (!isObj(e.fx)) { errors.push(`${w} must be an object`); continue; }
if (e.type !== "clip" && e.type !== "image") errors.push(`${w} is for a clip or an image`);
for (const k of Object.keys(e.fx)) {
- if (!["punch", "quote", "receipts", "zoom"].includes(k)) errors.push(`${w}.${k} is not an effect field`);
+ if (!["punch", "quote", "receipts", "zoom", "punchIn", "speakers"].includes(k)) errors.push(`${w}.${k} is not an effect field`);
}
if (e.fx.punch !== undefined && !(typeof e.fx.punch === "string" && e.fx.punch.trim() && e.fx.punch.length <= 120)) {
errors.push(`${w}.punch must be the words to punch (at most 120 characters)`);
}
if (e.fx.quote !== undefined && typeof e.fx.quote !== "boolean") errors.push(`${w}.quote must be true or false`);
+ if (e.fx.punchIn !== undefined) {
+ const ok = Array.isArray(e.fx.punchIn) && e.fx.punchIn.length > 0 && e.fx.punchIn.length <= 8 &&
+ e.fx.punchIn.every((t) => typeof t === "number" && Number.isFinite(t) && t >= 0);
+ if (!ok) errors.push(`${w}.punchIn must be a list of 1 to 8 source seconds`);
+ else if (e.type === "clip" && Number.isFinite(e.start) && Number.isFinite(e.end) && e.fx.punchIn.some((t) => t < e.start || t > e.end)) {
+ errors.push(`${w}.punchIn has a second outside the clip (${e.start}–${e.end})`);
+ }
+ }
+ if (e.fx.speakers !== undefined) {
+ const ok = Array.isArray(e.fx.speakers) && e.fx.speakers.length > 0 &&
+ e.fx.speakers.every((x) => isObj(x) && Number.isFinite(x.at) && (x.who === 0 || x.who === 1) && Object.keys(x).every((kk) => kk === "at" || kk === "who"));
+ if (!ok) errors.push(`${w}.speakers must be a list of { at: <source s>, who: 0 | 1 }`);
+ }
if (e.fx.receipts !== undefined) {
const r = e.fx.receipts;
if (!Array.isArray(r) || !r.length || r.length > FX_RECEIPTS_MAX) {
@@ -343,16 +393,27 @@ export function fxWordsOf(spans, from = -Infinity, to = Infinity) {
const used = (spans ?? []).filter((s) => Number.isFinite(s?.start) && Number.isFinite(s?.end) && s.end >= s.start)
.slice().sort((a, b) => a.start - b.start);
for (const s of used) {
- const words = String(s.text ?? "").replace(/\[[^\]]*\]/g, " ").split(/\s+/).map(fxShown).filter((w) => w && fxNorm(w));
+ // A speaker's turn is marked in captions as ">>" or a dash before the
+ // words ("- Oh god, it is. - Sometimes…"): the next word carries `turn`.
+ const words = [];
+ let turn = false;
+ for (const raw of String(s.text ?? "").replace(/\[[^\]]*\]/g, " ").split(/\s+/)) {
+ if (/^(?:>>+|-|–|—)$/.test(raw)) { turn = true; continue; }
+ if (/^>>/.test(raw)) turn = true;
+ const w = fxShown(raw);
+ if (!w || !fxNorm(w)) continue;
+ words.push({ w, turn });
+ turn = false;
+ }
if (!words.length) continue;
- const chars = words.reduce((n, w) => n + w.length + 1, 0);
+ const chars = words.reduce((n, x) => n + x.w.length + 1, 0);
let c = 0;
- for (const w of words) {
+ for (const { w, turn: t } of words) {
const a = s.start + ((s.end - s.start) * c) / chars;
c += w.length + 1;
const b = s.start + ((s.end - s.start) * (c - 1)) / chars;
const mid = (a + b) / 2;
- if (mid >= from && mid <= to) out.push({ text: w, start: a, end: Math.max(a, b) });
+ if (mid >= from && mid <= to) out.push({ text: w, start: a, end: Math.max(a, b), ...(t ? { turn: true } : {}) });
}
}
return out;
@@ -473,7 +534,7 @@ export function fxSchedule({ segments, entries, metas = [], render, D, total, wo
ws = fb.map((w) => ({ ...w, start: w.start - f0, end: w.end - f0 }));
}
const placed = (ws ?? [])
- .map((w) => ({ text: w.text, at: r3(c.start + w.start), end: r3(c.start + w.end) }))
+ .map((w) => ({ text: w.text, at: r3(c.start + w.start), end: r3(c.start + w.end), ...(w.turn ? { turn: true } : {}) }))
.filter((w) => w.at < c.out - 0.05 && w.end > c.in - 0.3)
.map((w) => ({ ...w, at: r3(Math.max(c.in, w.at)) }));
cutWords.set(c.id, placed.length ? placed : null);
@@ -495,12 +556,24 @@ export function fxSchedule({ segments, entries, metas = [], render, D, total, wo
const ws = wordsOf(c);
if (!ws) continue;
const mask = punchMask(ws, fxPunchOf(c.entry));
- const marked = ws.map((w, j) => ({ ...w, punch: mask[j] }));
- const pages = quotePages(marked, cfg.maxWords).map((pw, p, all) => {
+ const who = style === "kinetic" && cfg.speakers === "auto" ? speakersOf(ws, c, sourceFrom) : null;
+ const marked = ws.map((w, j) => ({ ...w, punch: mask[j], ...(who ? { speaker: who[j] } : {}) }));
+ // A page holds one speaker's words: a turn starts a new page.
+ const runs = [];
+ for (const w of marked) {
+ const last = runs[runs.length - 1];
+ if (last && last[0].speaker === w.speaker) last.push(w);
+ else runs.push([w]);
+ }
+ const pages = runs.flatMap((run) => quotePages(run, cfg.maxWords)).map((pw, p, all) => {
const pin = r3(Math.max(c.in, pw[0].at - FX_MOTION.page));
const next = all[p + 1];
const pout = r3(next ? Math.max(pin + 0.3, next[0].at - FX_MOTION.page) : c.out);
- return { in: pin, out: pout, words: pw.map((w) => ({ text: w.text, at: r3(Math.min(Math.max(w.at, pin), pout - 0.05)), punch: w.punch })) };
+ return {
+ in: pin, out: pout,
+ ...(who ? { speaker: pw[0].speaker } : {}),
+ words: pw.map((w) => ({ text: w.text, at: r3(Math.min(Math.max(w.at, pin), pout - 0.05)), punch: w.punch })),
+ };
});
res.push({ segment: c.id, style, in: r3(c.in), out: r3(c.out), pages });
}
@@ -515,6 +588,14 @@ export function fxSchedule({ segments, entries, metas = [], render, D, total, wo
return c ? { position: c.position, size: c.size } : null;
};
out.quoteStyle = { ...(style("kineticQuote") ? { kinetic: style("kineticQuote") } : {}), ...(style("redact") ? { redact: style("redact") } : {}) };
+ // The two voices, only when a line has more than one speaker.
+ const kq = resolveFx(render, "kineticQuote");
+ if (kq && quotes.some((q) => q.pages.some((p) => p.speaker === 1))) {
+ out.quoteStyle.voices = [0, 1].map((i) => ({
+ label: String(kq.voices?.[i]?.label ?? "").trim(),
+ color: kq.voices?.[i]?.color ?? FX_VOICE_COLORS[i],
+ }));
+ }
}
// ---- the odometer ----------------------------------------------------------
@@ -604,6 +685,53 @@ export function fxSchedule({ segments, entries, metas = [], render, D, total, wo
out.thenNow = { wipes };
}
+ // ---- the punch-in: the footage snaps in on a moment ---------------------------
+ const pi = resolveFx(render, "punchIn");
+ if (pi) {
+ const rows = [];
+ for (const c of vclips) {
+ const f0 = sourceFrom(c.entry);
+ const seconds = new Set((Array.isArray(c.entry.fx?.punchIn) ? c.entry.fx.punchIn : []).map((t) => r3(t - f0)));
+ // A laugh written in the captions, when `auto`: the word's start.
+ if (pi.auto) for (const w of wordsOf(c) ?? []) if (FX_LAUGH_RE.test(fxNorm(w.text))) seconds.add(r3(w.at - c.start));
+ // In the segment's clock, inside the clip's clean span; two closer than
+ // the hold are one.
+ const lo = c.in - c.start, hi = c.out - c.start - 0.1;
+ let last = -Infinity;
+ for (const t of [...seconds].sort((a, b) => a - b)) {
+ if (t < lo || t > hi - 0.2 || t < last + pi.hold) continue;
+ const until = Math.min(hi, t + pi.hold);
+ rows.push({
+ segment: c.id, index: c.i, at: r3(c.start + t), until: r3(c.start + until),
+ segmentAt: r3(t), segmentUntil: r3(until), scale: pi.scale, anchor: pi.anchor,
+ });
+ last = t;
+ }
+ }
+ out.punchIn = { punches: rows };
+ }
+
+ // ---- the whip: a cut that slides like a whip pan --------------------------------
+ const wh = resolveFx(render, "whip");
+ if (wh) {
+ const wipeAt = new Set((out.thenNow?.wipes ?? []).map((w) => w.index));
+ const cuts = [];
+ for (let k = 1; k < vclips.length; k += 1) {
+ const a = vclips[k - 1], b = vclips[k];
+ if (b.i !== a.i + 1 || wipeAt.has(b.i)) continue;
+ if (wh.on === "year") {
+ const da = fxClipDate(a.entry, a.meta), db = fxClipDate(b.entry, b.meta);
+ if (!(da && db && da.y !== db.y)) continue;
+ }
+ const start = segments[b.i].start;
+ // With a crossfade the cut slides (`slideleft`) over [start, start + D];
+ // on a hard cut the streaks alone flash across it.
+ const real = D > 0;
+ cuts.push({ segment: b.id, index: b.i, at: r3(real ? start : start - 0.12), seconds: r4(real ? D : 0.24), real });
+ }
+ out.whip = { cuts };
+ }
+
// ---- receipts and the zoom -----------------------------------------------------
const rc = resolveFx(render, "receipts");
if (rc) {
@@ -656,6 +784,50 @@ export function fxWipeJoins(schedule) {
return new Set((schedule?.fx?.thenNow?.wipes ?? []).filter((w) => w.real).map((w) => w.index - 1));
}
+/** Which segments' cut out of them is a whip (`slideleft`): the outgoing segment's index, for its join. */
+export function fxWhipJoins(schedule) {
+ return new Set((schedule?.fx?.whip?.cuts ?? []).filter((w) => w.real).map((w) => w.index - 1));
+}
+
+/** Each segment's punch-ins in its own clock, for its join: index → [{at, until, scale, anchor}]. */
+export function fxZoomJoins(schedule) {
+ const out = new Map();
+ for (const p of schedule?.fx?.punchIn?.punches ?? []) {
+ if (!out.has(p.index)) out.set(p.index, []);
+ out.get(p.index).push({ at: p.segmentAt, until: p.segmentUntil, scale: p.scale, anchor: p.anchor, ...(schedule.fx.box ? { box: schedule.fx.box } : {}) });
+ }
+ return out;
+}
+
+/**
+ * Who says each word of a clip's line: 0 or 1. The clip's `fx.speakers`
+ * (source seconds; each holds until the next) when it has them, else the
+ * captions' own turn marks (">>", a dash), each turn handing over to the
+ * other voice; the first voice is whoever speaks first in the line. Null when
+ * the line has one voice. It says WHICH of two voices, never whose: the
+ * labels are the manifest's (`kineticQuote.voices`).
+ */
+export function speakersOf(words, c, sourceFrom) {
+ const marks = Array.isArray(c.entry?.fx?.speakers) ? [...c.entry.fx.speakers].sort((a, b) => a.at - b.at) : null;
+ let who;
+ if (marks?.length) {
+ const f0 = sourceFrom(c.entry);
+ who = words.map((w) => {
+ const src = w.at - c.start + f0;
+ let v = marks[0].who;
+ for (const m of marks) if (m.at <= src + 1e-6) v = m.who;
+ return v;
+ });
+ } else {
+ let v = 0;
+ who = words.map((w, j) => {
+ if (j > 0 && w.turn) v = 1 - v;
+ return v;
+ });
+ }
+ return who.some((v) => v === 1) ? who : null;
+}
+
// ---------------------------------------------------------------------------
// The geometry and the cue list.
// ---------------------------------------------------------------------------
@@ -773,6 +945,9 @@ export function fxPresetsFor(manifest) {
{ name: "odometer", label: "Odometer", summary: "A counter that rolls up on each clip", fx: { odometer: {} } },
{ name: "scrubber", label: "Timeline scrubber", summary: "A date rail, the playhead sliding to each clip's day with its picture", fx: { scrubber: {} } },
{ name: "glitch", label: "VHS glitch", summary: "A tape tear and the new year at each cut between years", fx: { glitch: {} } },
+ { name: "punch-in", label: "Punch-in", summary: "The picture snaps in on each marked second and each laugh in the captions", fx: { punchIn: {} } },
+ { name: "whip", label: "Whip cut", summary: "Every cut between clips slides like a whip pan, streaks across it", fx: { whip: {} } },
+ { name: "reaction", label: "Reaction highlights", summary: "Captions in each speaker's colour, punch-ins on laughs, whip cuts, a running count", fx: { kineticQuote: {}, punchIn: {}, whip: {}, odometer: {} } },
];
if (pairs.length) {
out.push({ name: "then-now", label: "THEN / NOW wipe", summary: `The cut from THEN to NOW wipes, the two dates on its edge (${pairs.map((p) => `${p.then} → ${p.now}`).join(", ")})`, fx: { thenNow: { pairs } } });
diff --git a/umtool/report-to-video/fx.test.mjs b/umtool/report-to-video/fx.test.mjs
@@ -341,7 +341,7 @@ test("fxPresetsFor: one preset per effect the cut can show, each a patch the val
const { fxPresetsFor } = await import("./fx.mjs");
const m = { render: render(undefined, { transition: 0 }), timeline: TIMELINE };
const presets = fxPresetsFor(m);
- assert.deepEqual(presets.map((p) => p.name), ["kinetic-quote", "redaction", "odometer", "scrubber", "glitch", "then-now", "receipts", "zoom", "everything"]);
+ assert.deepEqual(presets.map((p) => p.name), ["kinetic-quote", "redaction", "odometer", "scrubber", "glitch", "punch-in", "whip", "reaction", "then-now", "receipts", "zoom", "everything"]);
for (const p of presets) {
assert.equal(p.patch.render.transition, 0.4, `${p.name}: a hard-cut project gets a crossfade to wipe on`);
const chrome = { ...m.render.chrome, ...p.patch.render.chrome };
@@ -354,3 +354,93 @@ test("fxPresetsFor: one preset per effect the cut can show, each a patch the val
// The cut's own transition is kept.
assert.equal(fxPresetsFor({ render: render(undefined, { transition: 0.25 }), timeline: TIMELINE })[0].patch.render.transition, 0.25);
});
+
+// ---- reaction highlights: two voices, the punch-in, the whip ----------------------
+
+test("fxWordsOf marks a speaker's turn at '>>' and a dash; the kinetic line gives each voice its own pages", () => {
+ const ws = fxWordsOf([{ start: 0, end: 4, text: "- Oh god, it is. - Sometimes it's a slow news day. >> Yeah" }]);
+ assert.deepEqual(ws.filter((w) => w.turn).map((w) => w.text), ["Oh", "Sometimes", "Yeah"]);
+ const words = new Map([["c1", ws.map((w) => ({ ...w, start: w.start + 1, end: w.end + 1 }))]]);
+ const s = sched({ kineticQuote: {} }, { words, timeline: [clip("c1", "2024-05-22")], durs: [6.4] });
+ const q = s.fx.quotes[0];
+ assert.deepEqual(q.pages.map((p) => [p.speaker, p.words.map((w) => w.text).join(" ")]), [
+ [0, "Oh god, it is."], [1, "Sometimes it's a slow news day."], [0, "Yeah"],
+ ]);
+ assert.deepEqual(s.fx.quoteStyle.voices, [{ label: "", color: null }, { label: "", color: "#6fa8dc" }]);
+ // speakers: false keeps one voice and no voices block.
+ const off = sched({ kineticQuote: { speakers: false } }, { words, timeline: [clip("c1", "2024-05-22")], durs: [6.4] });
+ assert.ok(off.fx.quotes[0].pages.every((p) => !("speaker" in p)));
+ assert.equal(off.fx.quoteStyle.voices, undefined);
+ // A line with one voice has no speaker marks at all (the schedule it was).
+ const one = sched({ kineticQuote: {} }, { words: new Map([["c1", [{ text: "solo", start: 1, end: 1.4 }]]]), timeline: [clip("c1", "2024-05-22")], durs: [6.4] });
+ assert.ok(one.fx.quotes[0].pages.every((p) => !("speaker" in p)));
+});
+
+test("a clip's fx.speakers (source seconds) name the voices over the captions' turns; labels are the manifest's", () => {
+ const words = new Map([["c1", [{ text: "a", start: 1, end: 1.2 }, { text: "b", start: 2, end: 2.2 }, { text: "c", start: 3, end: 3.2 }]]]);
+ const c1 = clip("c1", "2024-05-22", { fx: { speakers: [{ at: 11.5, who: 1 }, { at: 12.5, who: 0 }] } });
+ const r = { kineticQuote: { voices: [{ label: "Host" }, { label: "Video", color: "#22ab83" }] } };
+ // The clip's segment starts at its play window's from (cutStart − lead-in = 10.6).
+ const s = sched(r, { words, timeline: [c1], durs: [6.4] });
+ assert.deepEqual(s.fx.quotes[0].pages.map((p) => [p.speaker, p.words.map((w) => w.text).join(" ")]), [[1, "a"], [0, "b c"]]);
+ const who = s.fx.quotes[0].pages.flatMap((p) => p.words.map(() => p.speaker));
+ // a at source 11.6 (≥ 11.5 → 1), b at 12.6 (≥ 12.5 → 0), c 13.6 → 0.
+ assert.deepEqual(who, [1, 0, 0]);
+ assert.deepEqual(s.fx.quoteStyle.voices, [{ label: "Host", color: null }, { label: "Video", color: "#22ab83" }]);
+ assert.match(validateFxEntries({ render: render({}), timeline: [clip("c1", "2024-05-22", { fx: { speakers: [{ at: 1, who: 2 }] } })] }).join(), /speakers must be a list/);
+ assert.match(validateFx({ kineticQuote: { voices: [{ color: "red" }] } }).join(), /#rrggbb/);
+});
+
+test("the punch-in: on a clip's marked seconds and its captions' laughs, inside the clip, in the segment's clock", async () => {
+ const words = new Map([["c1", [{ text: "that's", start: 1, end: 1.3 }, { text: "hahaha", start: 2.5, end: 3 }, { text: "lol", start: 2.9, end: 3.1 }]]]);
+ const c1 = clip("c1", "2024-05-22", { fx: { punchIn: [14.6] } });
+ const s = sched({ punchIn: {} }, { words, timeline: [c1, clip("c2", "2024-05-23")], durs: [6.4, 6.4] });
+ const p = s.fx.punchIn.punches;
+ // 2.5 (the laugh) and 14.6 − 10.6 = 4.0 (the mark); "lol" is inside the first's hold.
+ assert.deepEqual(p.map((x) => [x.segment, x.segmentAt, x.segmentUntil]), [["c1", 2.5, 3.9], ["c1", 4, 5.4]]);
+ near(p[0].at, s.segments[0].start + 2.5, FRAME, "cut time");
+ const { fxZoomJoins } = await import("./fx.mjs");
+ const zj = fxZoomJoins(s);
+ assert.deepEqual([...zj.keys()], [0]);
+ const joins = segmentJoins(s);
+ assert.equal(joins[0].zoom.length, 2);
+ assert.deepEqual(joins[0].zoom[0].box, { x: 173, y: 2, width: 1574, height: 886 });
+ assert.equal(joins[1], null);
+ // auto: false keeps only the marks.
+ assert.deepEqual(sched({ punchIn: { auto: false } }, { words, timeline: [c1], durs: [6.4] }).fx.punchIn.punches.map((x) => x.segmentAt), [4]);
+ assert.match(validateFxEntries({ render: render({}), timeline: [clip("c1", "2024-05-22", { fx: { punchIn: [99] } })] }).join(), /outside the clip/);
+});
+
+test("the punch-in's graph crops the box and lays it back over itself between its seconds; the record names it", async () => {
+ const { joinInputChain, concatRecordText, punchInParts } = await import("./build-video.mjs");
+ const r = render({});
+ const c = joinInputChain(0, { hold: 0, move: null, zoom: [{ at: 2.5, until: 3.9, scale: 1.2, anchor: "upper" }] }, r);
+ assert.deepEqual(c.parts, [
+ "[0:v]split=2[j0z0a][j0z0b]",
+ "[j0z0b]crop=1312:738:304:39,scale=1574:886:flags=lanczos,setsar=1[j0z0c]",
+ "[j0z0a][j0z0c]overlay=173:2:enable='between(t,2.5,3.9)'[j0z0]",
+ ]);
+ assert.equal(c.v, "[j0z0]");
+ // With a hold too, the hold clones the zoomed stream.
+ const h = joinInputChain(0, { hold: 1, move: null, zoom: [{ at: 1, until: 2, scale: 1.2, anchor: "center" }] }, r);
+ assert.match(h.parts.at(-2) ?? "", /^\[j0z0\]tpad=/);
+ assert.equal(punchInParts(3, [], r, "[3:v]").v, "[3:v]");
+ const rec = concatRecordText(["a.mp4"], [{ hold: 0, move: null, zoom: [{ at: 1, until: 2, scale: 1.2, anchor: "upper" }] }]);
+ assert.match(rec, /# join 0 \{"hold":0,"move":null,"zoom":\[/);
+ assert.equal(concatRecordText(["a.mp4"], [{ hold: 1, move: null }]).includes("zoom"), false);
+});
+
+test("the whip: every cut between clips slides (slideleft), but never one that wipes; a hard cut only streaks", () => {
+ const tn = { thenNow: { pairs: [{ then: "c3", now: "c4" }] }, whip: {} };
+ const s = sched(tn);
+ assert.deepEqual(s.fx.whip.cuts.map((c) => c.segment), ["c2", "c3"]);
+ const joins = segmentJoins(s);
+ assert.deepEqual(joins.map((j) => (j?.wipe ? "wipe" : j?.whip ? "whip" : null)), ["whip", "whip", "wipe", null]);
+ const xf = xfadeGraph([6.4, 6.4, 6.4, 6.4], 0.5, joins).parts.filter((p) => /xfade=/.test(p));
+ assert.deepEqual(xf.map((p) => /transition=(\w+)/.exec(p)[1]), ["slideleft", "slideleft", "wipeleft"]);
+ assert.deepEqual(xfadeBatchJoins(joins, [{ from: 0, to: 1 }, { from: 1, to: 4 }]), [{ whip: true }, null]);
+ const hard = sched({ whip: {} }, { D: 0 });
+ assert.ok(hard.fx.whip.cuts.every((c) => !c.real && c.seconds === 0.24));
+ assert.equal(segmentJoins(hard), null);
+ assert.deepEqual(sched({ whip: { on: "year" } }, { timeline: [clip("c1", "2019-01-01"), clip("c2", "2019-02-01"), clip("c3", "2020-01-01")], durs: [6.4, 6.4, 6.4] }).fx.whip.cuts.map((c) => c.segment), ["c3"]);
+});