Archilyzer · Source

archilyzer

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

commit 7356a819a6fa769fafb54ee777361dffd7d51a62
parent 81689c0fbe75a237ba5cba186c04909c18e50023
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed,  4 Nov 2026 13:01:53 -0500

umtool: a post item's CLOCK, run between items and rewound for a stinger; a per-item PACE; a repeated post item (operator, 4 Nov: "show a clock advancing as we show the newest posts/replies chronologically and quickly to convey how much he's posting in bursts")

THE CLOCK (post-clock.mjs): render.posts.clock {on, zone} is the cut's default (`umtool posts clock <p> on|off
[--zone]`, updatePostClock), fx [{kind: "clock", on?, rewind?}] one item's (`posts fx <p> <item> add clock
[--rewind auto|on|off] [--off]`). It shows the item's OWN post time ("4:10 AM ET · Wed 4 Nov", America/New_York),
never a parent's or a quote's, and does not move while they are read. Between consecutive clock items it runs in
the first 0.8 s from the earlier time -- hands spinning, minutes rolling, the date flipping, the gap flashing
("+38 min", "+12 h 4 min"); an earlier post REWINDS (hands backwards, a dashed ring, "⟲ rewind −12 h 6 min");
rewind off cuts to it, on rewinds anyway. Placed at the card's bottom-right by the counts row (else top-right),
judged over no word across the read; drawn over the card, never in it, so readInViewErrors never counts it. The
build shoots its frames alone and lays them on (shootClock); Play and the bench mount the same chip from
clockPlan (playView postClock, the bench's before).

THE PACE (post-narration.mjs POST_PACES): narration.pace (and render.postNarration.pace) fast plays a post back
to back -- lead 0.1, tail 0.15, ramp 0.3, linger 0.45 unless it sets one itself; normal is the cut's. It rides
postNarrationKnobs, so the schedule, the build, Play and the deck estimate honour it (`posts narrate <p> <item>
pace=fast`, `--cut pace=fast`).

A REPEATED ITEM: `timeline duplicate` already copies a post item (its takes reused, its knobs its own); proven
with a "do you want to die?" stinger that rewinds the clock. Docs: report-video.md (a caption, the clock, the
pace, a repeated item), knobs.md, cli.md.

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

Diffstat:
Mumtool/components/projects/PostBench.tsx | 3++-
Mumtool/components/projects/PostZoomPanel.tsx | 24++++++++++++++++++++++++
Mumtool/components/projects/review/PlayCut.tsx | 3+++
Mumtool/components/projects/review/PostItemPlayer.tsx | 45++++++++++++++++++++++++++++++++++++++++++---
Mumtool/docs/cli.md | 4+++-
Mumtool/docs/knobs.md | 35+++++++++++++++++++++++++++++++++++
Mumtool/docs/report-video.md | 91+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/lib/report/manifest.mjs | 34+++++++++++++++++++++++++++++++++-
Mumtool/lib/report/playView.mjs | 3+++
Mumtool/lib/report/postFxCli.mjs | 62+++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
Mumtool/lib/report/postNarrationCli.mjs | 12++++++++----
Mumtool/lib/report/postsCli.mjs | 16+++++++++++++---
Mumtool/report-to-video/package.json | 1+
Aumtool/report-to-video/post-clock.mjs | 329+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/report-to-video/post-clock.test.mjs | 103+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/report-to-video/post-narration.mjs | 16+++++++++++++++-
Mumtool/report-to-video/post-redact.mjs | 4+++-
Mumtool/report-to-video/post-render.mjs | 98+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
Mumtool/report-to-video/word-zoom.mjs | 7+++++--
19 files changed, 863 insertions(+), 27 deletions(-)

diff --git a/umtool/components/projects/PostBench.tsx b/umtool/components/projects/PostBench.tsx @@ -18,6 +18,7 @@ import { liveCombo } from "umtool-report-to-video/post-combo"; import PostZoomPanel from "./PostZoomPanel"; import { wordZoomTimes, zoomSpan } from "umtool-report-to-video/word-zoom"; import { captionTimes, resolveCaption } from "umtool-report-to-video/post-caption"; +import { clockPlan } from "umtool-report-to-video/post-clock"; import { sceneEntry } from "umtool-report-to-video/post-media-scene"; // --------------------------------------------------------------------------- @@ -316,7 +317,7 @@ export default function PostBench({ </span> </div> <div className="relative w-full overflow-hidden rounded border border-seam bg-black" style={{ aspectRatio: `${box.width} / ${box.height}` }}> - <PostItemPlayer project={project} entry={shown} plan={plan} box={box} s={s} playing={playing} cardKey={`${token}:${scene?.key ?? "-"}`} scene={scene} /> + <PostItemPlayer project={project} entry={shown} plan={plan} box={box} s={s} playing={playing} cardKey={`${token}:${scene?.key ?? "-"}`} scene={scene} clock={clockPlan(shown, render, before)} /> <ComboBadge project={project} entry={shown} plan={plan} combo={liveCombo(combo, render, entry) as ComboInfo | null} box={box} s={s} playing={playing} /> </div> <div className="flex items-center gap-2 text-[12px]"> diff --git a/umtool/components/projects/PostZoomPanel.tsx b/umtool/components/projects/PostZoomPanel.tsx @@ -219,6 +219,30 @@ export default function PostZoomPanel({ )} </div> {list.map((fx0, i) => { + // Its clock (post-clock.mjs): a row of its own, its rewind knob. + if (fx0?.kind === "clock") { + return ( + <div key={i} className="flex flex-wrap items-center gap-2 rounded border border-seam p-2" data-post-clock-fx={i}> + <b>#{i + 1} clock</b> + <span className="text-text-2">{fx0.on === false ? "off on this item" : "the post's own time, run from the item before"}</span> + {fx0.on !== false && ( + <label className="flex items-center gap-1"> + rewind + <select value={String(fx0.rewind ?? "auto")} onChange={(e) => void send({ set: i, patch: { rewind: e.target.value === "auto" ? null : e.target.value } })} data-post-clock-knob="rewind"> + {["auto", "on", "off"].map((x) => ( + <option key={x} value={x}> + {x} + </option> + ))} + </select> + </label> + )} + <button type="button" className="ink-link ml-auto" onClick={() => void send({ remove: i })} data-post-clock-remove={i}> + remove + </button> + </div> + ); + } if (fx0?.kind === "caption") { const c = resolveCaption(fx0); const t = ctimes[i] as { t?: number; source?: string; error?: string }; diff --git a/umtool/components/projects/review/PlayCut.tsx b/umtool/components/projects/review/PlayCut.tsx @@ -122,6 +122,8 @@ export type PlayEntry = { /** A post item (report-to-video/post-item.mjs): the entry its card is drawn from, and what plays when. */ post?: Record<string, unknown> & { id: string }; postPlan?: PostPlan; + /** Its clock (post-clock.mjs clockPlan), or null. */ + postClock?: { to: number; from: number | null; mode: "forward" | "rewind" | "none"; zone: string; gap: number; forced: boolean } | null; /** Its combo badge (post-combo.mjs): the attachment it repeats, its count, the knobs. */ postCombo?: ComboInfo; /** Its media scene (post-media-scene.mjs): which, its place in it, its items, the anchor. */ @@ -857,6 +859,7 @@ export default function PlayCut({ published={asPublished} uncensored={uncensored} scene={postNow.entry.postScene ?? null} + clock={postNow.entry.postClock ?? null} /> ) : null; // A post item that repeats an earlier one's attachment: its combo badge, beside the player. diff --git a/umtool/components/projects/review/PostItemPlayer.tsx b/umtool/components/projects/review/PostItemPlayer.tsx @@ -8,6 +8,7 @@ import { blurCqw, blurOf, labelBoxOf, pixelGrid } from "umtool-report-to-video/p import { CAPTION_SLIDE, captionCss, captionInnerHtml, captionOpacityAt, captionPlan, captionSlideAt, measureCaptionWords, mountCaptions, paletteOfDoc, placeCaption, setCaptionState, slideDir, } from "umtool-report-to-video/post-caption"; +import { clockCss, clockFace, clockHtml, clockStateAt, measureClockPlace, mountClock, setClockState } from "umtool-report-to-video/post-clock"; import { WORD_ZOOM_HIGHLIGHT_ALPHA, findMatch, highlightAt, resolveWordZoom, targetScope, targetTextOf, wordZoomTimes, zoomAt, zoomProgressAt, zoomSpan, zoomWindow } from "umtool-report-to-video/word-zoom"; // --------------------------------------------------------------------------- @@ -34,6 +35,10 @@ import { WORD_ZOOM_HIGHLIGHT_ALPHA, findMatch, highlightAt, resolveWordZoom, tar // rule (placeCaption, the words read while it is up avoided), faded and slid in // on the same curve, and tracking the phrase as the card pans (measured each tick). // +// THE CLOCK (post-clock.mjs) plays live from `clock` (clockPlan: the caller has +// the item before it): the build's chip mounted in the card page, placed by the +// same rule, set each tick to clockStateAt -- the run, the badge, the rewind. +// // READ-FOLLOW (read-follow.mjs) plays live on the plan's `follow`: the card // page carries the read's blocks and its flow; the pan's path is worked out // from the page's geometry once it is drawn, and each tick sets the state at @@ -358,7 +363,7 @@ function MediaEl({ } export default function PostItemPlayer({ - project, take = null, entry, plan, box, s, playing, cardKey = null, speed = 1, published = false, uncensored = false, scene = null, + project, take = null, entry, plan, box, s, playing, cardKey = null, speed = 1, published = false, uncensored = false, scene = null, clock = null, }: { project: string; take?: string | null; @@ -378,6 +383,8 @@ export default function PostItemPlayer({ uncensored?: boolean; /** Its media scene (post-media-scene.mjs): which, and its place in it. */ scene?: { key: string; n: number; of: number } | null; + /** Its clock (post-clock.mjs clockPlan, from the item before it), or none. */ + clock?: { to: number; from: number | null; mode: "forward" | "rewind" | "none"; zone: string; gap: number; forced: boolean } | null; }) { const wrap = useRef<HTMLDivElement | null>(null); const [scale, setScale] = useState(0); @@ -518,14 +525,36 @@ export default function PostItemPlayer({ setCaps(placedCaps); return true; }, [entry, zoomTimes, box.height, follow, layout.mode, plan.steps, plan.total, plan.narration]); + // ---- the clock, live: mounted and placed once the page is drawn, set each tick ---- + const [clockAt, setClockAt] = useState<{ x: number; y: number } | null>(null); + const placeClock = useCallback(() => { + const doc = readFrame.current?.contentDocument; + if (!doc || doc.body?.getAttribute("data-post-ready") !== "1") return; + if (!clock) { + mountClock(null, doc); + setClockAt(null); + return; + } + const face = clockFace(clock.to, clock.zone); + const size = mountClock({ css: clockCss({ height: box.height, palette: paletteOfDoc(doc) }), html: clockHtml(), widest: { time: "12:58 PM", zone: face.zone, date: "Wed 30 Sep" } }, doc); + // Placed as the build places it: as the card is at the read's end (a threaded card's own post in). + const route = follow && doc.querySelector("[data-post-flow]") ? followPath(follow, measureFollow(doc)) : null; + if (follow && route) applyFollowState(followStateAt(follow, route, plan.total), doc); + const at = size ? measureClockPlace({ size, inset: Math.round(22 * (box.height / 1080)) }, doc) : null; + if (follow && route) applyFollowState(followStateAt(follow, route, 0), doc); + setClockAt(at ? { x: at.x, y: at.y } : null); + }, [clock, box.height, follow, plan.total]); const onFrameLoad = useCallback(() => { let tries = 0; const tick = () => { - if (measure() || tries++ > 50) return; + if (measure() || tries++ > 50) { + placeClock(); + return; + } setTimeout(tick, 100); }; tick(); - }, [measure]); + }, [measure, placeClock]); useEffect(() => { // The item changed under a loaded page (a knob, a zoom added): measure again. onFrameLoad(); @@ -567,6 +596,13 @@ export default function PostItemPlayer({ }); setCaptionState({ list }, doc); }, [capsUp, s, follow, followNow, box.height]); + const clockSt = useMemo(() => (clock ? clockStateAt(clock, s) : null), [clock, s]); + useEffect(() => { + const doc = readFrame.current?.contentDocument; + if (!doc) return; + const until = layout.mode === "stack" && plan.steps.length ? plan.steps[0].at : Infinity; + setClockState(clockSt && clockAt && s < until ? { ...clockAt, st: clockSt } : null, doc); + }, [clockSt, clockAt, s, layout.mode, plan.steps]); const src = shown && inStep ? mediaTimeAt(shown, s) : null; const cue = wordsRel && src !== null ? (cues[wordsRel] ?? []).find((c) => src >= c.start && src < c.end) ?? null : null; return ( @@ -585,6 +621,9 @@ export default function PostItemPlayer({ data-post-zoom={zooms.length ? String(Math.round(zf * 100) / 100) : undefined} data-post-zoom-fx={live ? String(live.i) : undefined} data-post-captions={caps.length ? String(caps.length) : undefined} + data-post-clock={clockSt ? `${clockSt.time} ${clockSt.date}` : undefined} + data-post-clock-mode={clockSt ? clockSt.mode : undefined} + data-post-clock-gap={clockSt && clockSt.gapOpacity > 0 ? clockSt.gap : undefined} data-post-caption-fx={capsUp.length ? capsUp.map((c) => String(c.i)).join(" ") : undefined} data-post-caption-place={capsUp.length ? capsUp.map((c) => c.placed.place).join(" ") : undefined} data-post-follow-block={followNow?.current !== null && followNow?.current !== undefined ? String(followNow.current) : undefined} diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md @@ -87,7 +87,9 @@ Inbox cannot disagree about what is wrong with one. | `posts reread <project> <item> [--without parent:0\|parent:1\|quoted[,…]] [--drop-parts 3,4] [--drop-urls] [--dry-run] [--json]` | a narrated read **re-joined without a piece**, no TTS ([knobs.md](knobs.md#thread-reads-every-part-of-a-read-on-screen-while-it-is-said), [report-video.md](report-video.md#thread-reads)): the picked take's kept parts cut out of its own file (ffmpeg) and joined with the read's pauses, measured, added as a derived take (`steps: [{op: "rejoin", drop}]`, its parts re-timed with their roles, its word timings moved, its slurs state kept) and picked — ONE write (one undo point). `--without` drops the parts that read the post it answers (`parent:0`), its parent (`parent:1`) or the quoted post; `--drop-parts` by number; `--drop-urls` the parts that are nothing but a link. Nothing to drop, every part dropped or a take read in one go: **exit 1**. `posts set-item … thread.parent.<i>=context\|hidden` (or `thread.quoted=…`) on a piece the take reads runs it first (`--no-reread`: refused, as before) | | `timeline <project> threads [--json]` · `timeline <project> threads --write [--conversation <id>]` | **the cut's conversations** ([report-video.md](report-video.md#thread-reads), `post-conversation.mjs`): each tree of two post items or more — its root, its items' places, whether they play as one run (one scene) or are split by other entries, a reply placed before the post it answers, an item re-reading a post its run already read (with `posts set-item <p> <item> thread.parent.<i>=context`). `--write` gathers each (or the one holding `<id>`: its root, a post, an item) at its first item's place in TREE order — a post after what it answers, sibling branches by date, each depth first — in ONE write (one undo point); never across a section boundary (gathered within each section, and said) | | `posts roles <project> [<item> …] [--write] [--set <n>=<role>,…] [--json]` | a narrated read **piece by piece** ([knobs.md](knobs.md#thread-reads-every-part-of-a-read-on-screen-while-it-is-said), [report-video.md](report-video.md#thread-reads)): the text each part of the picked take reads -- `parent:<i>`, `quoted`, `post`, `media:<i>` -- stored or inferred, what the card shows for each, and the build's guard (a part read off a post the card hides is refused). `--write` stores the inferred roles on the picked takes' parts (one write; the import stores them for every new take); `<item> --set n=role,…` sets parts' roles by hand (`off`: inferred again); a part out of range or an unknown role is refused (**exit 1**) | -| `posts narrate <project> --import [--dry-run] [--json]` · `--list` · `<item> [--script "…"] [--pick <n>] [--approve\|--unapprove] [--off\|--on] [lead= tail= ramp= linger= clip=read\|full wet= lowpass= duck=on\|off short=hold\|loop attach=under\|after lufs=]` · `<item> --take [--note "…"] [--voice v] [--engine e] [--speed s] [--script "…"]` · `<item> --derive <n> --op enhance\|convert [--engine e] [--voice v]` · `<item> --delete <n>` · `--all --draft-scripts [--force]` · `--all --take [--limit N]` · `--cut <k=v>…` | a **narrated post item** ([report-video.md](report-video.md#narrated-post-items), [knobs.md](knobs.md#a-narrated-post-item)): `--import` reads `narration/posts/index.json` (`[{id, entry, script, takes: [{file, engine, voice, seconds}], pick}]`, and a take's `take-<n>.parts.json`) into the cut in ONE write, measuring each take (length, loudness); a re-run adds only takes not there. `--take` asks the EDITOR for a new take (`POST /api/ops/tts`, its `out` the next `narration/posts/<postId>/take-<n>.<engine>-<voice>.wav`; a job, waited for; `ARCHILYZER_EDITOR_URL`, `WORKER_TOKEN`) and picks it, its `--note` kept with it; `--pick <n>` is the take's number as `--list` shows it. `--derive <n>` makes a NEW take from take n through the editor's `voice-enhance` / `voice-convert` op (a stock synthetic voice; "not installed" until the editor has the engine), the original kept; `--delete <n>` moves a take's file to the post's `.trash/`. A new script or pick takes the approval away. `--all --draft-scripts` writes every post's words as its script, VERBATIM (cleaned only to be spoken: @handles, links, emoji dropped; `plan(s)` → plans, `w/` → with, `&` → and; paragraphs kept). `--cut` sets `render.postNarration` (and its read-follow: `follow=on\|off`, `follow.dim=`, `follow.ease=`; its thread reads: `thread.parent=`, `thread.quoted=`, `thread.carry=`, `thread.reveal=`, `thread.shrink=`, `thread.dim=`, `thread.seconds=`, `thread.pan=`). Refused in the build's words (**exit 1**) | +| `posts narrate <project> --import [--dry-run] [--json]` · `--list` · `<item> [--script "…"] [--pick <n>] [--approve\|--unapprove] [--off\|--on] [lead= tail= ramp= linger= clip=read\|full wet= lowpass= duck=on\|off short=hold\|loop attach=under\|after lufs= pace=fast\|normal]` · `<item> --take [--note "…"] [--voice v] [--engine e] [--speed s] [--script "…"]` · `<item> --derive <n> --op enhance\|convert [--engine e] [--voice v]` · `<item> --delete <n>` · `--all --draft-scripts [--force]` · `--all --take [--limit N]` · `--cut <k=v>…` | a **narrated post item** ([report-video.md](report-video.md#narrated-post-items), [knobs.md](knobs.md#a-narrated-post-item)): `--import` reads `narration/posts/index.json` (`[{id, entry, script, takes: [{file, engine, voice, seconds}], pick}]`, and a take's `take-<n>.parts.json`) into the cut in ONE write, measuring each take (length, loudness); a re-run adds only takes not there. `--take` asks the EDITOR for a new take (`POST /api/ops/tts`, its `out` the next `narration/posts/<postId>/take-<n>.<engine>-<voice>.wav`; a job, waited for; `ARCHILYZER_EDITOR_URL`, `WORKER_TOKEN`) and picks it, its `--note` kept with it; `--pick <n>` is the take's number as `--list` shows it. `--derive <n>` makes a NEW take from take n through the editor's `voice-enhance` / `voice-convert` op (a stock synthetic voice; "not installed" until the editor has the engine), the original kept; `--delete <n>` moves a take's file to the post's `.trash/`. A new script or pick takes the approval away. `--all --draft-scripts` writes every post's words as its script, VERBATIM (cleaned only to be spoken: @handles, links, emoji dropped; `plan(s)` → plans, `w/` → with, `&` → and; paragraphs kept). `--cut` sets `render.postNarration` (and its read-follow: `follow=on\|off`, `follow.dim=`, `follow.ease=`; its thread reads: `thread.parent=`, `thread.quoted=`, `thread.carry=`, `thread.reveal=`, `thread.shrink=`, `thread.dim=`, `thread.seconds=`, `thread.pan=`). Refused in the build's words (**exit 1**) | +| `posts fx <project> <item> add caption --match "…" --text "…" [--target post\|quoted\|parent:<i>] [--occurrence n] [--at s] [--lead s] [--hold s] [--place below\|above\|side]` · `add clock [--rewind auto\|on\|off] [--off]` · `set <n> [--text …] [--place …] [--rewind …]` | a post item's **caption** ([report-video.md](report-video.md#a-caption), [knobs.md](knobs.md#a-caption-a-chip-explaining-a-phrase-as-it-is-read)): a chip explaining a phrase (any script: CJK drawn), up as it is read -- `--at`, else the take's word timings, else the reading estimate -- held `--hold` s, by the phrase and never over a word read while it is up; it waits for a word zoom. Its **clock** ([knobs.md](knobs.md#the-clock-each-posts-own-time-on-its-card-run-between-items)): the post's own time on the card, run from the clock item before it (forward; a REWIND when earlier: `--rewind`), `--off` not on this item. Through `updatePostFx`, refused in the build's words (**exit 1**); a zoom's knob on a caption, or a caption's on a zoom (**exit 1**) | +| `posts clock <project> [on\|off\|default] [--zone <IANA zone>] [--json]` | the cut's **clock** default (`render.posts.clock`, `updatePostClock`); bare, which items show it and their times | | `posts fx <project> <item> [ls]` · `add word-zoom --match "…" [--target post\|quoted\|parent:<i>] [--occurrence n] [--at s] [--scale s] [--hold s] [--lead s] [--ease out\|inOut\|snap] [--highlight #rrggbb\|off]` · `set <n> [those flags; default clears one]` · `remove <n>` · `posts narrate <project> <item> --words [--worker <id>]` | a post item's **word zoom** ([report-video.md](report-video.md#a-word-zoom), [knobs.md](knobs.md#a-word-zoom-a-post-items-card-pushed-in-on-a-word-as-it-is-read)): the card pushed in on a word as it is read, a highlight under it, then back out -- through `updatePostFx`, refused in the build's words (a match not in the words, a knob out of bounds; **exit 1**). Its time is `--at`, else the word's start in the picked take's word timings; `ls` prints each zoom's time and where it came from. An un-narrated post's `add` fills `at` with the reading estimate. `--words` asks the EDITOR's transcribe op (`words: true`, a job per take or per part file; `ARCHILYZER_EDITOR_URL`, `WORKER_TOKEN`) and keeps the words heard, aligned to the script, on the take (`takes[i].words`) | | `posts fit <project> [--all \| <item> …] [--linger <s>] [--dry-run] [--json]` · `posts set-item <project> <item> fit=read[:<linger>]` | narrated posts' video attachments cut to their **best part** for the read (lead + take + tail + linger): a scored scan of the sound (loudness, its peaks), the speech (a transcript) and the scene cuts, the start snapped to a pause or a cut, recorded with why (`narration.window`) -- ONE write; each post's old and new length printed. A video no longer than the read is left as it is | | `posts avatar <project> [<handle> <image-file> \| <handle> off] [--json]` · `posts avatars <project> [--dry-run] [--json]` | the **authors' pictures** (`postAvatars`): `avatar` copies a picture into `posts-media/_avatars/` for every card that draws that handle (manual; never replaced by the archive's), `off` clears it, no handle lists them; `avatars` copies the archive's (the channels' `posts-media/_avatars/avatars.json`, capture-posts') for every author the cut's cards draw unblurred that it has none of. A blurred author never shows one | diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -762,6 +762,41 @@ snapshot and every script keep their words. | `render.posts.slurs.add` — the project's own words (always masked; a word, or `{word, forms?, mask?, say?}`) · `.except` — never masked here (a form, a slur's word or its id) | — | `umtool posts slurs <p> add <word>` · `except <word>` · `remove <word>` (one writer, `updatePostSlurs`) | — | | what the cut masks | — | `umtool posts slurs <p> ls [--json]`: per slur (its mask, never the word) and per post, and each read that needs word timings | — | +## A caption (a chip explaining a phrase as it is read) + +`fx: [{kind: "caption", match, text, …}]` on a post item ([report-video.md](report-video.md#a-caption): the shape, +the time, the place, the render). One writer, `updatePostFx`, refused in the build's words (`captionErrors`, +`report-to-video/post-caption.mjs`, through `validatePostFx`). Its bench is the post bench's **word zoom · caption** +block; Play the cut and the bench draw the build's own chip, live. + +| Knob | In umtool | From a terminal | Route | +|---|---|---|---| +| a caption -- `match` (the phrase as the card shows it), `text` (≤ 160 characters, any script: CJK is drawn in Noto Sans CJK; the part before " — " bold), `occurrence`, `target` (`post`, `quoted`, `parent:<i>`) | post bench: click a word (shift-click: a phrase), type the text, **Caption here**; a caption's text field | `umtool posts fx <p> <item> add caption --match "Fudōshin" --text '不動心 · fudōshin — "immovable mind"' [--target quoted] [--occurrence n]` | `POST /api/report/post-item {project, op: "fx", id, fx: {add: {kind: "caption", match, text, …}}, token}` | +| `at` -- item seconds (0–600); absent: the matched word's start in the picked take's word timings, else the reading estimate (a narrated read spread over its script by characters; un-narrated, 1 s + 3 words a second) | the caption's **−0.1** / **+0.1**, **at playhead**, **from the read** (clears it) | `umtool posts fx <p> <item> set <n> --at 4.2` (`--at default`: back to the words / the estimate) | `fx: {set: <i>, patch: {at}}` | +| `lead` 0–3 s in before the word (0.15), `hold` 0.5–10 s from it (2.5), `place` `below` \| `above` \| `side` (below) -- it never covers a word read while it is up (the next place that is clear wins); it waits for a word zoom it would be up with | the caption's **lead**, **hold**, **place** | `set <n> --lead 0.3 --hold 3 --place above` (`default` clears one) | `fx: {set: <i>, patch: {…}}` | +| remove one | the caption's **remove** | `umtool posts fx <p> <item> remove <n>` | `fx: {remove: <i>}` | +| list them, each with its time and where it came from | the block's rows; the plan strip marks each (blue) | `umtool posts fx <p> <item> [ls] [--json]` | — | + +## The clock (each post's own time on its card, run between items) + +`render.posts.clock` (the cut's default) and `fx: [{kind: "clock", on?, rewind?}]` on a post item +([report-video.md](report-video.md#the-clock)): the item's own post time, "4:10 AM ET · Wed 4 Nov", run forward +from the clock item before it in its first 0.8 s (the gap flashing), or rewound when it is earlier. Refused in the +build's words (`clockErrors`, `validateClockRender`, `report-to-video/post-clock.mjs`). + +| Knob | In umtool | From a terminal | Route | +|---|---|---|---| +| the cut's clock -- `on` (off by default), `zone` (an IANA zone; `America/New_York`) | — | `umtool posts clock <p> on\|off\|default [--zone America/New_York]` (`updatePostClock`); bare: which items show it | — | +| one item's clock -- on (or `on: false`: not on this item though the cut's is) | post bench, the clock's row (**remove**) | `umtool posts fx <p> <item> add clock [--off]` · `remove <n>` | `fx: {add: {kind: "clock"}}` | +| `rewind` `auto` (an earlier post rewinds) \| `on` (rewinds anyway) \| `off` (cuts straight to its time) | the clock's **rewind** | `umtool posts fx <p> <item> set <n> --rewind on\|off\|auto` | `fx: {set: <i>, patch: {rewind}}` | + +## The pace (a burst played back to back) + +| Knob | In umtool | From a terminal | Route | +|---|---|---|---| +| `narration.pace` -- `fast` (lead 0.1, tail 0.15, ramp 0.3, linger 0.45, unless the post sets one itself) \| `normal` (the cut's gaps); `render.postNarration.pace` the cut's. The schedule, the build, Play and the deck's estimate honour it | — | `umtool posts narrate <p> <item> pace=fast\|normal\|default` · `umtool posts narrate <p> --cut pace=fast` | — | +| a REPEATED item (a stinger): a second copy of a post item, its narration and takes reused, its own knobs | — | `umtool timeline <p> duplicate <id>` then `timeline <p> move <id>-copy --to <n>` | — | + ## A word zoom (a post item's card pushed in on a word as it is read) `fx: [{kind: "word-zoom", match, …}]` on a post item ([report-video.md](report-video.md#a-word-zoom): the shape, the diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md @@ -659,6 +659,97 @@ post's insert and `umtool posts avatars <p>`, or set by hand with `umtool posts <p> <handle> <image>` (never replaced by the archive's). Every card that draws that author unblurred shows it — the render, Play and the bench; a redacted author never. +### A caption + +A post item may carry a CAPTION: a small chip explaining a phrase, up as the phrase is +read and held a beat (`report-to-video/post-caption.mjs`; operator, 4 Nov: `不動心 · +fudōshin — "immovable mind"` on "Fudōshin"). It sits beside a word zoom in `fx`: + +```jsonc +"fx": [{ + "kind": "caption", + "match": "Fudōshin", // the phrase as the card shows it (as a word zoom's) + "text": "不動心 · fudōshin — \"immovable mind\"", // ≤ 160 characters, any script; the part before " — " bold + "target": "post", "occurrence": 1, // whose words, its n-th time (as a word zoom's) + "at": 4.2, // item seconds; absent: the take's word timings, else the estimate + "lead": 0.15, "hold": 2.5, // in this long before the word; held this long from it + "place": "below" // "below" (default) | "above" | "side" +}] +``` + +**When** -- a word zoom's rule: `at`, else the matched word's start in the picked take's +word timings (lead + start ÷ rate), else the READING ESTIMATE: a narrated read spread over +its script by characters (the card's words aligned to the script), an un-narrated post's +1 s + 3 words a second. It fades and slides in over 0.3 s and out over 0.35 s. A caption +that would be up while a word zoom is (its lead-in to back out) WAITS for the zoom to be +out; two captions of a post up at once are refused, and one is gone by a stack card's media +phase. + +**Where**: a chip by the phrase -- the card's palette (a panel of its background toward the +accent, the accent's border), its faces, then the CJK faces (`Noto Sans CJK JP`, `Source +Han Sans`, `WenQuanYi Zen Hei`) so 不動心 is drawn -- with a notch pointing at the phrase and +an accent underline under it. It never covers a word read while it is up: `place` first, +then below, above, side (each vertical place centred on the phrase, then its edges aligned); +among the places clear of the read, the one hiding fewest of the card's other words; the +build notes a WARNING when none is clear. It tracks the phrase while the card pans +(read-follow), and it is drawn OVER the card, never in it -- no `data-w`, no +`data-post-block` -- so `readInViewErrors` never counts it. + +**The render**: on the card page as drawn at the caption's peak, the phrase measured (a +phrase cut off the card is refused), the chip placed, then shot alone on a clear page (the +chip with its notch; the underline apart) and laid over the card (`postSegmentArgs` +`captionFx`): fading, sliding in toward the phrase, riding the phrase's track. Play and the +bench mount the same markup in the card frame (`mountCaptions`, `setCaptionState`) on the +same curve. The post record (`<id>.post.json`) keeps each caption's time, span, place and box. + +### The clock + +A post item may show its CLOCK (`report-to-video/post-clock.mjs`; operator, 4 Nov: "show a +clock advancing as we show the newest posts/replies chronologically and quickly to convey +how much he's posting in bursts"; "the clock should probably just be for mr obvious' +replies ... so it generally always goes forward unless there's a compelling reason to go +back"): a small chip on the card, "4:10 AM ET · Wed 4 Nov" with an analogue face, in the +cut's zone (`America/New_York`). + +```jsonc +"render": { "posts": { "clock": { "on": true, "zone": "America/New_York" } } }, // the cut's default +"fx": [{ "kind": "clock", "on": false, "rewind": "auto" }] // one item's ("on" default true) +``` + +It shows the ITEM's own post time (`entry.date`) -- never a parent's or a quote's -- and it +does not move while they are read. Between two consecutive clock items, in the first 0.8 s +of the second it RUNS from the earlier time to this one (`easeInOut`): the hands spin, the +minutes roll, the date flips day by day, the gap flashes in a badge beside it ("+39 s", +"+38 min", "+2 h 14 min", "+3 d 4 h") for 0.9 s, then fades over 0.4 s. When this post is +EARLIER than the one before it REWINDS: the hands spin backwards, the face's ring dashes, and +the badge says "⟲ rewind −12 h 6 min". `rewind: "off"` cuts straight to the time; `"on"` +rewinds even forward (a repeat of the same post spins back a full turn to itself). An item +after a non-clock entry shows its time without a run. + +It sits at the card's bottom-right corner, beside the counts row, else its top-right -- the +first over no word of the card -- drawn over the card, never in it (`readInViewErrors` +never counts it). The render shoots its frames alone on a clear page (each distinct state +once: the run and the badge's fade) and lays them over the card from the first frame (a +stack card's, until its media phase); Play and the bench mount the same chip +(`mountClock`, `setClockState`) from `clockPlan`, which needs the item before it (`playView` +`postClock`; the bench's `before`). + +### The pace + +`pace: "fast"` on a narrated post's narration (or `render.postNarration.pace`, the cut's) +plays it BACK TO BACK (`POST_PACES`): lead 0.1, tail 0.15, ramp 0.3, linger 0.45 -- unless +the post sets one of those itself (its own always wins); `"normal"` is the cut's gaps (on a +post, it undoes a cut's `fast`). It rides the narration's knobs (`postNarrationKnobs`), so the +schedule, the build, Play and the deck's estimate all honour it. An un-narrated post has no +read gaps to shorten (its `hold` is its length). + +### A repeated item + +`umtool timeline <p> duplicate <id>` copies a post item to just after itself under a fresh +id (`<id>-copy`), its narration and takes REUSED (the same files), its knobs its own -- move +it where the stinger goes (`timeline move <id>-copy --to <n>`) and give it its own pace, +clock or captions. Two items of one post build two segments. + ### A word zoom A post item's card may PUSH IN ON A WORD as it is read (`report-to-video/word-zoom.mjs`; diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs @@ -2681,7 +2681,7 @@ export function handlesWithoutAvatar(m, handles) { // ---- a post item's narration (report-to-video/post-narration.mjs) ---------- /** The narration keys a write may set on one post item (post-narration.mjs; knobs.md, "A narrated post item"). */ -export const POST_NARRATION_KNOBS = Object.freeze(["script", "excerpt", "engine", "voice", "speed", "pick", "approved", "off", "lead", "tail", "ramp", "linger", "clip", "wet", "lowpassHz", "duck", "short", "attach", "lufs", "rate", "window"]); +export const POST_NARRATION_KNOBS = Object.freeze(["script", "excerpt", "engine", "voice", "speed", "pick", "approved", "off", "lead", "tail", "ramp", "linger", "clip", "wet", "lowpassHz", "duck", "short", "attach", "lufs", "rate", "pace", "window"]); /** * One post item's narration, changed in place (`m` the manifest inside a @@ -2993,6 +2993,38 @@ export async function updatePostRedact(dir, change, { token = null } = {}) { }); } +// ---- the clock (post-clock.mjs; `umtool posts clock`) ----------------------- + +/** + * SET THE CUT's CLOCK (`render.posts.clock`): `{ on?, zone? }` (a null: back to + * the default -- off, America/New_York). One item's own (`fx: [{kind: "clock"}]`) + * wins over it. Validated with the build's check. + * + * @param {string} dir + * @param {{ on?: boolean | null, zone?: string | null }} patch + * @param {{ token?: string | null }} [opts] + */ +export async function updatePostClock(dir, patch, { token = null } = {}) { + if (!isObj(patch) || !Object.keys(patch).length) throw new Error("say on, off or a zone"); + return structural(dir, "post-clock", token, (m) => { + if (!isObj(m.render)) m.render = {}; + const posts = isObj(m.render.posts) ? m.render.posts : {}; + const c = isObj(posts.clock) ? { ...posts.clock } : {}; + for (const [k, v] of Object.entries(patch)) { + if (!["on", "zone"].includes(k)) throw new StructureRefused([`render.posts.clock.${k} is not a clock knob (on, zone)`]); + if (v === null || v === undefined) delete c[k]; + else c[k] = v; + } + if (Object.keys(c).length) posts.clock = c; + else delete posts.clock; + if (Object.keys(posts).length) m.render.posts = posts; + else delete m.render.posts; + const errors = validatePostsRender(m.render); + if (errors.length) throw new StructureRefused(errors); + return { clock: posts.clock ?? null }; + }); +} + // ---- the slur filter (post-slurs.mjs; `umtool posts slurs`) --------------- /** diff --git a/umtool/lib/report/playView.mjs b/umtool/lib/report/playView.mjs @@ -16,6 +16,7 @@ import { rejectionOf } from "./rejectReasons.mjs"; import { dateKeyLabel } from "./playCut.mjs"; import { postDay, postItemPlan } from "umtool-report-to-video/post-item"; import { planContext } from "umtool-report-to-video/post-conversation"; +import { clockPlan } from "umtool-report-to-video/post-clock"; import { pickWindow, projectCache, windowVersion, windowsFor } from "./serve.mjs"; import { playableTakes, resolveTakeManifest } from "./takeManifest.mjs"; import { readWorkingCut } from "./workingCut.mjs"; @@ -64,6 +65,8 @@ export function postPlayEntry(e, render = undefined, ctx = null, mediaScene = nu // `prev`: the item before it in the cut (post-thread.mjs: a parent that is that item is carried in); `scene`: the // posts its run left on screen (post-conversation.mjs: one conversation played as one scene) -- it wins the card. postPlan: postItemPlan(sceneEntry(e, mediaScene), render, { prev: ctx?.prev ?? null, scene: ctx?.scene ?? null, mediaScene: ctx?.scene ? null : mediaScene }), + // Its clock (post-clock.mjs): its post's time, run from the clock item before it. + postClock: clockPlan(e, render, ctx?.prev ?? null), ...(mediaScene ? { postScene: { key: mediaScene.key, n: mediaScene.n, of: mediaScene.of, ids: mediaScene.ids, anchor: mediaScene.anchor.id } } : {}), }; } diff --git a/umtool/lib/report/postFxCli.mjs b/umtool/lib/report/postFxCli.mjs @@ -22,9 +22,10 @@ import { WORD_ZOOM_DEFAULTS, WORD_ZOOM_EASES, findMatch, readingEstimate, resolveWordZoom, scriptWordTimes, targetTextOf, wordZoomTimes, } from "umtool-report-to-video/word-zoom"; import { CAPTION_DEFAULTS, CAPTION_PLACES, captionTimes, resolveCaption } from "umtool-report-to-video/post-caption"; +import { CLOCK_REWINDS, CLOCK_ZONE, clockFace, clockOn, clockZoneOf } from "umtool-report-to-video/post-clock"; import { readManifest } from "../projects/report.mjs"; import { withEditNotes } from "./edit-guard.mjs"; -import { manifestToken, updatePostFx, updatePostNarration } from "./manifest.mjs"; +import { manifestToken, updatePostClock, updatePostFx, updatePostNarration } from "./manifest.mjs"; import { findPostItem } from "./postNarrationCli.mjs"; export const FX_USAGE = [ @@ -33,6 +34,7 @@ export const FX_USAGE = [ " [--at s] [--scale s] [--hold s] [--lead s] [--ease out|inOut|snap] [--highlight #rrggbb|off] [--json]", " umtool posts fx <project> <item> add caption --match \"…\" --text \"…\" [--target post|quoted|parent:<i>] [--occurrence n]", " [--at s] [--lead s] [--hold s] [--place below|above|side] [--json]", + " umtool posts fx <project> <item> add clock [--rewind auto|on|off] [--off]", " umtool posts fx <project> <item> set <n> [those flags; `default` clears one] | remove <n>", " A WORD ZOOM: the card pushed in on a word (or a phrase) as it is read, a highlight under it, then back out.", " --match is the word as the card shows it (case and edge punctuation aside); --occurrence its n-th time in the", @@ -47,6 +49,10 @@ export const FX_USAGE = [ " the word's start in the take's word timings, else the reading estimate (a narrated read spread over its script).", ` --lead 0–3 s in before the word (${CAPTION_DEFAULTS.lead}), --hold 0.5–10 s from it (${CAPTION_DEFAULTS.hold}), --place ${CAPTION_PLACES.join("|")} (${CAPTION_DEFAULTS.place}).`, " A caption up while a word zoom is waits for the zoom to be out.", + " A CLOCK: the post's own time on its card (\"4:10 AM ET · Wed 4 Nov\", the cut's zone), run from the clock item", + " before it in its first 0.8 s -- forward with the gap flashing (\"+38 min\"), or REWOUND when this post is earlier", + " (⟲ rewind). --rewind off cuts straight to it, on rewinds anyway; --off: no clock on this item though the cut's is", + " on (umtool posts clock <p> on).", ].join("\n"); export class FxError extends Error {} @@ -70,6 +76,8 @@ export function fxPatchOf(str) { out[key] = x; } } + const rw = str("--rewind"); + if (rw !== null) out.rewind = rw === "default" || rw === "auto" ? null : rw; const tx = str("--text"); if (tx !== null) out.text = tx; const pl = str("--place"); @@ -89,10 +97,16 @@ export function fxLines(e, render) { if (!list.length) return [`${e.id}: no effects (add one: umtool posts fx <p> ${e.id} add word-zoom --match "…" | add caption --match "…" --text "…")`]; const times = wordZoomTimes(e, render); const ctimes = captionTimes(e, render); - const nz = list.filter((f) => f?.kind !== "caption").length; + const nz = list.filter((f) => f?.kind === "word-zoom").length; + const nc = list.filter((f) => f?.kind === "caption").length; + const clk = list.some((f) => f?.kind === "clock"); return [ - `${e.id}: ${nz} word zoom(s), ${list.length - nz} caption(s)${isNarrated(e) || !nz ? "" : " (not narrated: a zoom needs at)"}`, + `${e.id}: ${nz} word zoom(s), ${nc} caption(s)${clk ? ", its clock" : ""}${isNarrated(e) || !nz ? "" : " (not narrated: a zoom needs at)"}`, ...list.map((fx0, i) => { + if (fx0?.kind === "clock") { + const on = fx0.on !== false; + return ` #${i + 1} clock ${on ? `on -- ${clockFace(Date.parse(e.date), clockZoneOf(render)).time} ${clockFace(Date.parse(e.date), clockZoneOf(render)).date}, rewind ${fx0.rewind ?? "auto"}` : "off (the cut's clock not shown here)"}`; + } if (fx0?.kind === "caption") { const c = resolveCaption(fx0); const t = ctimes[i]; @@ -108,7 +122,7 @@ export function fxLines(e, render) { } /** `umtool posts fx …` (postsCli.mjs routes it here). */ -export async function fxCommand(project, words, { json = false, out = (s) => console.log(s), str }) { +export async function fxCommand(project, words, { json = false, out = (s) => console.log(s), str, off = false }) { const manifest = await readManifest(project.dir); if (!manifest) throw new FxError(`${project.id} has no manifest`); const render = manifest.render ?? {}; @@ -133,8 +147,17 @@ export async function fxCommand(project, words, { json = false, out = (s) => con return 0; } if (verb === "add") { - if (arg !== "word-zoom" && arg !== "caption") throw new FxError("add names the effect: add word-zoom --match \"…\" | add caption --match \"…\" --text \"…\""); + if (arg !== "word-zoom" && arg !== "caption" && arg !== "clock") throw new FxError("add names the effect: add word-zoom --match \"…\" | add caption --match \"…\" --text \"…\" | add clock"); const patch = Object.fromEntries(Object.entries(fxPatchOf(str)).filter(([, v]) => v !== null)); + if (arg === "clock") { + const extra = Object.keys(patch).filter((k) => k !== "rewind"); + if (extra.length) throw new FxError(`--${extra[0]} is not a clock's knob (--rewind ${CLOCK_REWINDS.join("|")}, --off)`); + if ((e.fx ?? []).some((f) => f?.kind === "clock")) throw new FxError(`${e.id} has its clock already (set <n> --rewind …, or remove <n>)`); + const { result } = await write({ add: { kind: "clock", ...patch, ...(off ? { on: false } : {}) } }); + say(result.entry, { index: result.index }); + return 0; + } + if ("rewind" in patch) throw new FxError("--rewind is a clock's knob (add clock …)"); if (arg === "caption") { if (typeof patch.match !== "string" || !patch.match.trim()) throw new FxError("add caption needs --match \"<the phrase, as the card shows it>\""); if (typeof patch.text !== "string" || !patch.text.trim()) throw new FxError("add caption needs --text \"<what the chip says>\""); @@ -174,6 +197,35 @@ export async function fxCommand(project, words, { json = false, out = (s) => con throw new FxError(`${verb}: ls, add, set or remove`); } +export const CLOCK_USAGE = [ + "usage: umtool posts clock <project> [on|off|default] [--zone <IANA zone>] [--json]", + " THE CUT's CLOCK (render.posts.clock): each post item's own time on its card (\"4:10 AM ET · Wed 4 Nov\"), run", + " forward between two clock items (the gap flashing), rewound when the next is earlier. on/off is the cut's", + ` default (an item's own: umtool posts fx <p> <item> add clock [--off]); --zone the clock's zone (${CLOCK_ZONE}).`, + " With no word: which items show it.", +].join("\n"); + +/** `umtool posts clock …` (postsCli.mjs routes it here). */ +export async function clockCommand(project, words, { json = false, out = (s) => console.log(s), str }) { + const [verb] = words; + const zone = str("--zone"); + if (verb !== undefined && !["on", "off", "default", "ls"].includes(verb)) throw new FxError(`${verb}: on, off or default`); + if ((verb && verb !== "ls") || zone !== null) { + const patch = {}; + if (verb === "on" || verb === "off") patch.on = verb === "on"; + if (verb === "default") patch.on = null; + if (zone !== null) patch.zone = zone === "default" ? null : zone; + await withEditNotes(project, async () => updatePostClock(project.dir, patch, { token: await manifestToken(project.dir) })); + } + const manifest = await readManifest(project.dir); + const render = manifest?.render ?? {}; + const items = (manifest?.timeline ?? []).filter((x) => x?.type === "post"); + const shown = items.filter((x) => clockOn(x, render)); + if (json) out(JSON.stringify({ ok: true, clock: render.posts?.clock ?? null, zone: clockZoneOf(render), items: shown.map((x) => x.id) }, null, 2)); + else out([`clock: the cut's ${render.posts?.clock?.on ? "on" : "off"}, zone ${clockZoneOf(render)}; ${shown.length} of ${items.length} post item(s) show it`, ...shown.slice(0, 40).map((x) => ` ${x.id} ${clockFace(Date.parse(x.date), clockZoneOf(render)).time} ${clockFace(Date.parse(x.date), clockZoneOf(render)).date}`)].join("\n")); + return 0; +} + /** * Where a take is transcribed from: its PARTS (a long post read part by part), * each on its own file and offset by its start in the take, when every part's diff --git a/umtool/lib/report/postNarrationCli.mjs b/umtool/lib/report/postNarrationCli.mjs @@ -42,9 +42,9 @@ export const NARRATE_USAGE = [ " umtool posts narrate <project> --list [--json]", " umtool posts narrate <project> <item> [--script \"…\"] [--take [--note \"…\"] [--voice v] [--engine e] [--speed s]]", " [--pick <n>] [--approve|--unapprove] [--off|--on] [lead=… tail=… ramp=… linger=… clip=read|full", - " wet=… lowpass=… duck=on|off short=hold|loop attach=under|after lufs=… rate=…] [--json]", + " wet=… lowpass=… duck=on|off short=hold|loop attach=under|after lufs=… rate=… pace=fast|normal] [--json]", " umtool posts narrate <project> --all --draft-scripts [--force] | --all --take [--limit N]", - " umtool posts narrate <project> --cut lead=… tail=… ramp=… linger=… clip=read|full wet=… lowpass=… duck=on|off short=hold|loop lufs=… rate=… engine=… voice=… follow=on|off follow.dim=… follow.ease=…", + " umtool posts narrate <project> --cut lead=… tail=… ramp=… linger=… clip=read|full wet=… lowpass=… duck=on|off short=hold|loop lufs=… rate=… pace=fast|normal engine=… voice=… follow=on|off follow.dim=… follow.ease=…", " --cut thread.parent=auto|full|excerpt|context|carry|hidden thread.quoted=… thread.carry=auto|on|off thread.reveal=on|off thread.shrink=… thread.dim=… thread.seconds=… thread.pan=…", " A NARRATED POST ITEM: its script read by a stock synthetic voice, its attachment playing under the read (muffled,", " then clean). Takes are files of the project (narration/posts/<postId>/take-<n>.<engine>-<voice>.wav) the EDITOR", @@ -57,6 +57,8 @@ export const NARRATE_USAGE = [ " --derive <n> --op enhance|convert [--engine e] [--voice v]: a NEW take made from take n by the editor's op", " (enhance: denoise, level; convert: the performance kept, the timbre a STOCK synthetic voice) -- the original kept.", " A narrated post lasts lead + its read + tail + linger (1.8 s); a longer video is cut to that -- its best part,", + " pace=fast plays a post (or, with --cut, every post) back to back: lead 0.1, tail 0.15, ramp 0.3, linger 0.45 --", + " unless it sets one itself; pace=normal the cut's gaps.", " once `umtool posts fit` has scanned it (else from its in point). clip=full plays the attachments whole.", " rate=0.8–1.5 (default 1): the READ sped up (its pitch kept), the attachment untouched; the post's length, its", " muffle and its parts follow the faster read (a 10 s take at rate=1.25 reads in 8 s).", @@ -215,7 +217,7 @@ export function narrationLines(e, render) { }); if (plan.narration) { const k = postNarrationKnobs(e, render); - lines.push(` mix: ${["lead", "tail", "ramp", "linger", "clip", "wet", "lowpassHz", "duck", "short", "attach", "lufs", "rate"].map((x) => fmtKnob(x, k[x])).join(" ")}`); + lines.push(` mix: ${["lead", "tail", "ramp", "linger", "clip", "wet", "lowpassHz", "duck", "short", "attach", "lufs", "rate", "pace"].map((x) => fmtKnob(x, k[x])).join(" ")}`); if (n.window) lines.push(` window: attachment ${n.window.media + 1} ${n.window.start}–${n.window.end} s (score ${n.window.score}): ${n.window.reason}`); lines.push(` plays: voice ${plan.narration.at}–${(plan.narration.at + plan.narration.seconds).toFixed(2)} s, muffled to ${plan.narration.voiceEnd} s, clean from ${plan.narration.rampEnd} s; attachments ${plan.steps.map((s) => `${s.kind} ${s.at}+${s.seconds}`).join(", ") || "none"}${plan.held ? `, held ${plan.held} s` : ""}`); } @@ -240,6 +242,8 @@ export function mixPatchOf(pairs, { cut = false } = {}) { if (["lead", "tail", "ramp", "linger", "wet", "lufs", "rate"].includes(k)) out[k] = clear ? null : num(); else if (k === "clip") out.clip = clear ? null : v; else if (k === "lowpass" || k === "lowpassHz") out.lowpassHz = clear ? null : num(); + // The pace (post-narration.mjs POST_PACES): fast plays it back to back; normal (or default) the cut's gaps. + else if (k === "pace") out.pace = clear ? null : v; else if (k === "duck") out.duck = clear ? null : ON.has(v) ? true : OFF.has(v) ? false : (() => { throw new NarrateError("duck= takes on or off"); })(); else if (k === "short") out.short = clear ? null : v; else if (k === "attach" && !cut) out.attach = clear ? null : v; @@ -265,7 +269,7 @@ export function mixPatchOf(pairs, { cut = false } = {}) { if (!m) throw new NarrateError("fit= takes read or read:<linger seconds>"); out.linger = m[1] !== undefined ? Number(m[1]) : null; out.clip = null; - } else throw new NarrateError(`${pair}: not a narration knob (lead, tail, ramp, end, wet, lowpass, duck, short, ${cut ? "linger, clip, lufs, rate, engine, voice, follow, follow.dim, follow.ease, thread.parent|quoted|carry|reveal|shrink|dim|seconds|pan" : "linger, clip, attach, lufs, rate, fit"})`); + } else throw new NarrateError(`${pair}: not a narration knob (lead, tail, ramp, end, wet, lowpass, duck, short, ${cut ? "linger, clip, lufs, rate, pace, engine, voice, follow, follow.dim, follow.ease, thread.parent|quoted|carry|reveal|shrink|dim|seconds|pan" : "linger, clip, attach, lufs, rate, pace, fit"})`); } if (!Object.keys(out).length) throw new NarrateError("nothing to set"); return out; diff --git a/umtool/lib/report/postsCli.mjs b/umtool/lib/report/postsCli.mjs @@ -114,7 +114,9 @@ export const POSTS_USAGE = [ " (umtool posts narrate --help)", " umtool posts fit <project> [--all|<item> …] [--linger s] [--dry-run] narrated posts' videos cut to their best part", " umtool posts fx <project> <item> [ls] | add word-zoom --match \"…\" [--at s] … | add caption --match \"…\" --text \"…\" | set <n> … | remove <n>", - " a WORD ZOOM (the card pushed in on a word) or a CAPTION (a chip explaining a phrase) as it is read (umtool posts fx --help)", + " a WORD ZOOM (the card pushed in on a word) or a CAPTION (a chip explaining a phrase) as it is read,", + " or its CLOCK (add clock [--rewind auto|on|off] [--off]) (umtool posts fx --help)", + " umtool posts clock <project> [on|off|default] [--zone <IANA zone>] the cut's CLOCK default: each post's time on its card, run between items", " umtool posts avatar <project> [<handle> <image-file> | <handle> off] [--json]", " an author's PICTURE on every card that draws them (postAvatars): the file copied into posts-media/_avatars/,", " never replaced by the archive's; `off` clears it; no handle lists them. A blurred author never shows one.", @@ -138,7 +140,7 @@ export const POSTS_USAGE = [ " umtool posts scenes <project> [on|off] [--json] the MEDIA SCENES: neighbours with the same attachment", ].join("\n"); -const VALUED = new Set(["--set", "--attach", "--flag", "--author", "--id", "--crop", "--since", "--until", "--replies", "--order", "--limit", "--after", "--script", "--note", "--voice", "--engine", "--speed", "--pick", "--linger", "--derive", "--op", "--delete", "--match", "--target", "--occurrence", "--at", "--scale", "--hold", "--lead", "--ease", "--highlight", "--worker", "--without", "--drop-parts", "--text", "--place"]); +const VALUED = new Set(["--set", "--attach", "--flag", "--author", "--id", "--crop", "--since", "--until", "--replies", "--order", "--limit", "--after", "--script", "--note", "--voice", "--engine", "--speed", "--pick", "--linger", "--derive", "--op", "--delete", "--match", "--target", "--occurrence", "--at", "--scale", "--hold", "--lead", "--ease", "--highlight", "--worker", "--without", "--drop-parts", "--text", "--place", "--rewind", "--zone"]); const SLUG_RE = /^[A-Za-z0-9._-]+$/; const POST_ID_RE = /^[A-Za-z0-9_-]{1,64}$/; @@ -438,7 +440,15 @@ export async function postsCommand(args, { root = REPORTS_ROOT, out = (s) => con err(FX_USAGE); return 2; } - return await fxCommand(await projectOf(projectArg, root), words.slice(2), { json, out, str }); + return await fxCommand(await projectOf(projectArg, root), words.slice(2), { json, out, str, off: flags.has("--off") }); + } + if (verb === "clock") { + const { CLOCK_USAGE, clockCommand } = await import("./postFxCli.mjs"); + if (!projectArg || flags.has("--help")) { + err(CLOCK_USAGE); + return 2; + } + return await clockCommand(await projectOf(projectArg, root), words.slice(2), { json, out, str }); } if (verb === "fit") { const { FIT_USAGE, fitCommand } = await import("./postNarrationCli.mjs"); diff --git a/umtool/report-to-video/package.json b/umtool/report-to-video/package.json @@ -76,6 +76,7 @@ "./post-render": "./post-render.mjs", "./word-zoom": "./word-zoom.mjs", "./post-caption": "./post-caption.mjs", + "./post-clock": "./post-clock.mjs", "./read-follow": "./read-follow.mjs", "./presets": "./presets.mjs", "./prune-frames": "./prune-frames.mjs", diff --git a/umtool/report-to-video/post-clock.mjs b/umtool/report-to-video/post-clock.mjs @@ -0,0 +1,329 @@ +// A POST ITEM's CLOCK (umtool/docs/report-video.md, "The clock"; operator, 4 Nov: +// "show a clock advancing as we show the newest posts/replies chronologically +// and quickly to convey how much he's posting in bursts" -- "the clock should +// probably just be for mr obvious' replies and ignore the messages he's replying +// to so it generally always goes forward unless there's a compelling reason to +// go back at some point (e.g. 'you want to die' combo)"). +// +// A small clock-and-date chip on the card: "4:10 AM ET · Wed 4 Nov", in the +// operator's zone (America/New_York; render.posts.clock.zone). It shows the +// ITEM's own post time (entry.date) -- never a parent's or a quote's, and it +// does not move while they are read. Between two consecutive clock items, in +// the first CLOCK_TICK seconds of the second it RUNS from the earlier time to +// this one: the hands spin, the minutes roll, the date flips, the gap flashes +// ("+38 min", "+2 h 14 min", "+3 d 4 h"). When this post is EARLIER than the +// one before (a stinger that jumps back), it REWINDS: the hands spin backwards, +// a "⟲ rewind" badge with the gap, the date flipping back -- deliberate, never a +// glitch. `rewind: "off"` cuts straight to the time; `"on"` rewinds even +// forward (or across no gap: a repeated post spins back a full turn to itself). +// +// render.posts.clock = { on?: true, zone?: "America/New_York" } // the cut's default +// entry.fx = [{ kind: "clock", on?: false, rewind?: "auto" | "on" | "off" }] // one item's +// +// WHERE: the card's bottom-right corner (beside the counts row, never read +// text), else its top-right; the first place over no word of the card. Drawn +// OVER the card, never in it (no data-w, no data-post-block): readInViewErrors +// never counts it, and it covers no read text. +// +// Pure but for the DOM functions (mountClock, measureClockPlace, setClockState), +// SELF-CONTAINED: the build passes them to a page, Play calls them on its frame. + +import { mixHex, rgbaOf } from "./post-item.mjs"; + +export const CLOCK_ZONE = "America/New_York"; +/** How long the clock runs from the earlier time to this one, seconds. */ +export const CLOCK_TICK = 0.8; +/** The gap's badge stays this long after the run, then fades over CLOCK_FLASH_OUT. */ +export const CLOCK_FLASH_HOLD = 0.9; +export const CLOCK_FLASH_OUT = 0.4; +export const CLOCK_REWINDS = Object.freeze(["auto", "on", "off"]); +const CLOCK_KEYS = new Set(["kind", "on", "rewind"]); +const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v); +const fin = (v) => typeof v === "number" && Number.isFinite(v); + +/** A zone Intl knows. */ +export function validZone(zone) { + try { + new Intl.DateTimeFormat("en-US", { timeZone: String(zone) }); + return typeof zone === "string" && zone.length > 0; + } catch { + return false; + } +} + +/** Every reason a clock fx (entry `e`'s fx[i], named `fw`) cannot be built. word-zoom.mjs validatePostFx calls it. */ +export function clockErrors(e, fx, fw) { + const errors = []; + for (const k of Object.keys(fx)) if (!CLOCK_KEYS.has(k)) errors.push(`${fw}.${k} is not a clock key (${[...CLOCK_KEYS].join(", ")})`); + if (fx.on !== undefined && typeof fx.on !== "boolean") errors.push(`${fw}.on must be true or false`); + if (fx.rewind !== undefined && !CLOCK_REWINDS.includes(fx.rewind)) errors.push(`${fw}.rewind must be one of ${CLOCK_REWINDS.join(", ")}`); + if ((Array.isArray(e?.fx) ? e.fx : []).filter((f) => f?.kind === "clock").length > 1) errors.push(`${fw}: one clock per item`); + if (fx.on !== false && !Number.isFinite(Date.parse(String(e?.date ?? "")))) errors.push(`${fw}: the post has no date to show (its date)`); + return errors; +} + +/** Every reason `render.posts.clock` is refused (post-redact.mjs validatePostsRender calls it). */ +export function validateClockRender(c) { + if (c === undefined) return []; + if (!isObj(c)) return ["render.posts.clock must be { on?, zone? }"]; + const errors = []; + for (const k of Object.keys(c)) if (!["on", "zone"].includes(k)) errors.push(`render.posts.clock.${k} is not a clock knob (on, zone)`); + if (c.on !== undefined && typeof c.on !== "boolean") errors.push("render.posts.clock.on must be true or false"); + if (c.zone !== undefined && !validZone(c.zone)) errors.push(`render.posts.clock.zone ${JSON.stringify(c.zone)} is not a time zone (an IANA name: America/New_York)`); + return errors; +} + +/** The item's clock fx, or null. */ +const clockFxOf = (entry) => (Array.isArray(entry?.fx) ? entry.fx.find((f) => isObj(f) && f.kind === "clock") ?? null : null); + +/** Whether post item `entry` shows the clock: its own fx (on unless `on: false`), else the cut's `render.posts.clock.on`. */ +export function clockOn(entry, render) { + if (entry?.type !== undefined && entry.type !== "post") return false; + if (!Number.isFinite(Date.parse(String(entry?.date ?? "")))) return false; + const fx = clockFxOf(entry); + if (fx) return fx.on !== false; + return render?.posts?.clock?.on === true; +} + +/** The cut's zone. */ +export const clockZoneOf = (render) => (validZone(render?.posts?.clock?.zone) ? render.posts.clock.zone : CLOCK_ZONE); + +/** + * THE CLOCK's PLAN for post item `entry`: `{ to, from, mode, zone, gap }` -- + * `to` its post's time (ms), `from` the time the clock showed on the item + * before it when that one is a clock item too (else null: no run), `mode` + * "forward" | "rewind" | "none", `gap` to - from (ms). Null when it shows no clock. + * @param {Record<string, any>} entry + * @param {Record<string, any>} [render] + * @param {Record<string, any> | null} [prev] + * @returns {{ to: number, from: number | null, mode: "forward" | "rewind" | "none", zone: string, gap: number, forced: boolean } | null} + */ +export function clockPlan(entry, render = undefined, prev = null) { + if (!clockOn(entry, render)) return null; + const to = Date.parse(entry.date); + const zone = clockZoneOf(render); + const rewind = clockFxOf(entry)?.rewind ?? "auto"; + const from = prev && clockOn(prev, render) ? Date.parse(prev.date) : null; + if (from === null || rewind === "off") return { to, from: null, mode: "none", zone, gap: 0, forced: false }; + if (rewind === "on") return { to, from: from > to ? from : to + 12 * 3600e3, mode: "rewind", zone, gap: to - from, forced: from <= to }; + if (from === to) return { to, from: null, mode: "none", zone, gap: 0, forced: false }; + return { to, from, mode: from > to ? "rewind" : "forward", zone, gap: to - from, forced: false }; +} + +/** A gap as the badge says it: "+38 min", "+2 h 14 min", "+3 d 4 h", "+45 s" (its sign kept). */ +export function gapLabel(ms) { + const sign = ms < 0 ? "−" : "+"; + let s = Math.round(Math.abs(ms) / 1000); + if (s < 60) return `${sign}${s} s`; + const d = Math.floor(s / 86400); + s -= d * 86400; + const h = Math.floor(s / 3600); + s -= h * 3600; + const m = Math.floor(s / 60); + if (d) return `${sign}${d} d${h ? ` ${h} h` : ""}`; + if (h) return `${sign}${h} h${m ? ` ${m} min` : ""}`; + return `${sign}${m} min`; +} + +const fmtCache = new Map(); +const fmt = (zone, o) => { + const k = `${zone}|${JSON.stringify(o)}`; + if (!fmtCache.has(k)) fmtCache.set(k, new Intl.DateTimeFormat(o.locale ?? "en-US", { timeZone: zone, ...o, locale: undefined })); + return fmtCache.get(k); +}; + +/** A moment's face in a zone: `{ time: "4:10 AM", zone: "ET", date: "Wed 4 Nov", h, m }` (h 0–23, m 0–59.99 its local clock). */ +export function clockFace(ms, zone = CLOCK_ZONE) { + const d = new Date(ms); + const time = fmt(zone, { hour: "numeric", minute: "2-digit" }).format(d); + const zn = (fmt(zone, { timeZoneName: "shortGeneric", hour: "numeric" }).formatToParts(d).find((p) => p.type === "timeZoneName")?.value ?? "").replace(/^GMT$/, "UTC"); + const date = fmt(zone, { locale: "en-GB", weekday: "short", day: "numeric", month: "short" }).format(d).replace(",", ""); + const parts = Object.fromEntries(fmt(zone, { hourCycle: "h23", hour: "2-digit", minute: "2-digit", second: "2-digit" }).formatToParts(d).map((p) => [p.type, p.value])); + return { time, zone: zn, date, h: Number(parts.hour) % 24, m: Number(parts.minute) + Number(parts.second) / 60 }; +} + +const easeInOut = (x) => { + const v = Math.min(1, Math.max(0, x)); + return v < 0.5 ? 4 * v ** 3 : 1 - (-2 * v + 2) ** 3 / 2; +}; + +/** + * THE CLOCK AT item second `s`: what the chip shows -- `{ time, zone, date, + * hour, minute (hand angles, degrees), gap, gapOpacity, mode, running }`. The + * hands' angles run continuously from the earlier time (a rewind: backwards). + * @param {ReturnType<typeof clockPlan>} plan + * @param {number} s + */ +export function clockStateAt(plan, s) { + if (!plan) return null; + const run = plan.from === null || plan.mode === "none" ? 1 : easeInOut(s / CLOCK_TICK); + const shown = plan.from === null ? plan.to : plan.from + (plan.to - plan.from) * run; + const face = clockFace(shown, plan.zone); + // The hands from the minutes elapsed (continuous across days: the hour hand turns once per 12 h, the minute hand per hour). + const end = clockFace(plan.to, plan.zone); + const endMin = end.h * 60 + end.m; + const minutes = endMin + (shown - plan.to) / 60000; + const ga = plan.mode === "none" ? 0 : s < CLOCK_TICK + CLOCK_FLASH_HOLD ? Math.min(1, s / 0.15) : Math.max(0, 1 - (s - CLOCK_TICK - CLOCK_FLASH_HOLD) / CLOCK_FLASH_OUT); + return { + time: face.time, + zone: face.zone, + date: face.date, + hour: ((minutes / 2) % 360 + 360) % 360, + minute: ((minutes * 6) % 360 + 360) % 360, + // Unwrapped (the DOM rotates by these, so a run spins rather than snapping back across 0). + hourTurn: minutes / 2, + minuteTurn: minutes * 6, + gap: plan.mode === "rewind" ? `⟲ rewind${plan.forced ? "" : ` ${gapLabel(plan.gap)}`}` : plan.mode === "forward" ? gapLabel(plan.gap) : "", + gapOpacity: Math.round(ga * 1000) / 1000, + mode: plan.mode, + running: plan.mode !== "none" && s < CLOCK_TICK, + }; +} + +/** The item seconds whose frames differ (the run and the badge's fade), at `fps`: `[0, 1/fps, …]` up to the last change. */ +export function clockFrameTimes(plan, fps = 30) { + if (!plan || plan.mode === "none") return [0]; + const end = CLOCK_TICK + CLOCK_FLASH_HOLD + CLOCK_FLASH_OUT; + const out = []; + for (let f = 0; f / fps <= end + 1e-9; f += 1) out.push(f / fps); + return out; +} + +// --------------------------------------------------------------------------- +// THE LOOK, and the DOM (self-contained). +// --------------------------------------------------------------------------- + +/** The chip's CSS for a page `height` px tall, in the card's palette. */ +export function clockCss({ height = 1080, palette = {} } = {}) { + const k = height / 1080; + const pal = { bg: "#12100c", fg: "#f6f1e6", muted: "#a2957f", accent: "#c8752a", ...palette }; + const panel = mixHex(pal.bg, pal.fg, 0.08); + const px = (v) => `${Math.round(v * k)}px`; + return ` +[data-post-clock-layer] { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; z-index: 61; } +.pclock { position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: ${px(12)}; padding: ${px(7)} ${px(16)} ${px(7)} ${px(9)}; + background: ${panel}; color: ${pal.fg}; border: ${Math.max(1, Math.round(1.5 * k))}px solid ${rgbaOf(pal.fg, 0.18)}; border-radius: ${px(999)}; + box-shadow: 0 ${px(4)} ${px(16)} ${rgbaOf("#000000", 0.4)}; font-family: 'PostSans', 'Noto Sans CJK JP', sans-serif; white-space: nowrap; font-synthesis: none; } +.pclock-face { width: ${px(44)}; height: ${px(44)}; flex: none; } +.pclock-face circle { fill: ${rgbaOf(pal.bg, 0.6)}; stroke: ${pal.accent}; stroke-width: 2.4; } +.pclock-face .tk { stroke: ${rgbaOf(pal.fg, 0.45)}; stroke-width: 1.6; } +.pclock-face .hh { stroke: ${pal.fg}; stroke-width: 3.2; stroke-linecap: round; } +.pclock-face .mh { stroke: ${pal.accent}; stroke-width: 2.2; stroke-linecap: round; } +.pclock-txt { display: flex; flex-direction: column; line-height: 1.12; } +.pclock-time { font-family: 'PostSansBold', 'Noto Sans CJK JP', sans-serif; font-size: ${px(26)}; font-variant-numeric: tabular-nums; } +.pclock-zone { font-family: 'PostSans', sans-serif; color: ${pal.muted}; font-size: ${px(18)}; margin-left: ${px(5)}; } +.pclock-date { color: ${mixHex(pal.fg, pal.muted, 0.4)}; font-size: ${px(18)}; letter-spacing: 0.02em; } +.pclock-gap { position: absolute; right: calc(100% + ${px(10)}); top: 50%; transform: translateY(-50%); padding: ${px(4)} ${px(12)}; border-radius: ${px(999)}; + font-family: 'PostSansBold', sans-serif; font-size: ${px(22)}; background: ${pal.accent}; color: ${pal.bg}; opacity: 0; font-variant-numeric: tabular-nums; } +.pclock[data-mode="rewind"] .pclock-gap { background: ${pal.fg}; color: ${pal.bg}; } +.pclock[data-mode="rewind"][data-running="1"] .pclock-face circle { stroke: ${pal.fg}; stroke-dasharray: 4 3; } +.pclock[data-running="1"] .pclock-date { color: ${pal.accent}; } +`; +} + +/** The chip's HTML (its face with 12 ticks; the text filled by setClockState). */ +export function clockHtml() { + const ticks = Array.from({ length: 12 }, (_, i) => { + const a = (i * Math.PI) / 6; + const r0 = i % 3 ? 15 : 13; + return `<line class="tk" x1="${(22 + r0 * Math.sin(a)).toFixed(2)}" y1="${(22 - r0 * Math.cos(a)).toFixed(2)}" x2="${(22 + 17.5 * Math.sin(a)).toFixed(2)}" y2="${(22 - 17.5 * Math.cos(a)).toFixed(2)}"/>`; + }).join(""); + return `<span class="pclock-gap" data-clock-gap=""></span><svg class="pclock-face" viewBox="0 0 44 44"><circle cx="22" cy="22" r="19.5"/>${ticks}<line class="hh" data-clock-hh="" x1="22" y1="22" x2="22" y2="12"/><line class="mh" data-clock-mh="" x1="22" y1="22" x2="22" y2="6.5"/></svg><span class="pclock-txt"><span class="pclock-time"><span data-clock-time="">0:00 AM</span><span class="pclock-zone" data-clock-zone="">ET</span></span><span class="pclock-date" data-clock-date="">Mon 1 Jan</span></span>`; +} + +/** + * Mount the clock over the card page (`{ css, html, widest }`: `widest` a state + * to lay it out at its widest), hidden. Returns its size `{ width, height }`. + * @param {{ css: string, html: string, widest?: Record<string, any> | null } | null} arg + * @param {Document} [doc] + */ +export function mountClock(arg, doc = document) { + doc.querySelectorAll("[data-post-clock-layer], style[data-post-clock-css]").forEach((el) => el.remove()); + if (!arg || !arg.html) return null; + const style = doc.createElement("style"); + style.setAttribute("data-post-clock-css", ""); + style.textContent = arg.css || ""; + doc.head.appendChild(style); + const layer = doc.createElement("div"); + layer.setAttribute("data-post-clock-layer", ""); + const el = doc.createElement("div"); + el.className = "pclock"; + el.setAttribute("data-post-clock", ""); + el.style.opacity = "0"; + el.innerHTML = arg.html; + layer.appendChild(el); + doc.body.appendChild(layer); + const w = arg.widest || {}; + const set = (sel, v) => { + const n = el.querySelector(sel); + if (n && v !== undefined) n.textContent = v; + }; + set("[data-clock-time]", w.time); + set("[data-clock-zone]", w.zone); + set("[data-clock-date]", w.date); + const b = el.getBoundingClientRect(); + // Its width held at the widest (a running time never resizes it). + el.style.minWidth = `${Math.ceil(b.width)}px`; + return { width: Math.ceil(b.width), height: Math.ceil(b.height) }; +} + +/** + * Where the clock goes on the card as drawn: the bottom-right corner (beside + * the counts row), else the top-right, the first over no word of the card + * (`[data-w]`); `{ x, y, place, covers, tries }`. `size` its box, `inset` from + * the card's edge; `fixed`: the places to judge (an earlier call's `tries`), + * only counted here -- the build places it once and judges it over the read. + * @param {{ size: { width: number, height: number }, inset: number, fixed?: Array<{ x: number, y: number, place: string }> | null }} arg + * @param {Document} [doc] + */ +export function measureClockPlace(arg, doc = document) { + const card = doc.querySelector("[data-post-card]"); + if (!card || !arg || !arg.size) return null; + const c = card.getBoundingClientRect(); + const words = Array.from(doc.querySelectorAll("[data-w]")).flatMap((el) => Array.from(el.getClientRects())).filter((r) => r.width > 0); + const hit = (r) => words.filter((w) => Math.min(r.x + r.width, w.right) - Math.max(r.x, w.left) > 1 && Math.min(r.y + r.height, w.bottom) - Math.max(r.y, w.top) > 1).length; + const counts = card.querySelector(".counts"); + const cb = counts ? counts.getBoundingClientRect() : null; + const x = Math.round(c.right - arg.inset - arg.size.width); + // Bottom: centred on the counts row when there is one, else in the card's foot. + const yb = cb && cb.height > 0 ? Math.round(cb.top + (cb.height - arg.size.height) / 2 + 4) : Math.round(c.bottom - arg.inset - arg.size.height); + const tries = (arg.fixed || [ + { x, y: Math.min(yb, Math.round(c.bottom - arg.size.height - 4)), place: "bottom-right" }, + { x, y: Math.round(c.top + arg.inset), place: "top-right" }, + ]).map((t) => ({ ...t, covers: hit({ x: t.x - arg.size.width * 0.6, y: t.y, width: arg.size.width * 1.6, height: arg.size.height }) })); + const best = tries.find((t) => !t.covers) || tries.slice().sort((a, b) => a.covers - b.covers)[0]; + return { ...best, tries }; +} + +/** + * Set the clock: `{ x, y, opacity, st }` (`st` clockStateAt's), or null to hide. + * @param {{ x: number, y: number, opacity?: number, st: Record<string, any> } | null} arg + * @param {Document} [doc] + */ +export function setClockState(arg, doc = document) { + const el = doc.querySelector("[data-post-clock]"); + if (!el) return; + if (!arg || !arg.st) { + el.style.opacity = "0"; + return; + } + const st = arg.st; + el.style.transform = `translate(${Math.round(arg.x)}px, ${Math.round(arg.y)}px)`; + el.style.opacity = String(arg.opacity === undefined ? 1 : arg.opacity); + el.setAttribute("data-mode", st.mode); + el.setAttribute("data-running", st.running ? "1" : "0"); + const set = (sel, v) => { + const n = el.querySelector(sel); + if (n && n.textContent !== v) n.textContent = v; + }; + set("[data-clock-time]", st.time); + set("[data-clock-zone]", st.zone); + set("[data-clock-date]", st.date); + set("[data-clock-gap]", st.gap); + const gap = el.querySelector("[data-clock-gap]"); + if (gap) gap.style.opacity = st.gap ? String(st.gapOpacity) : "0"; + const hh = el.querySelector("[data-clock-hh]"); + const mh = el.querySelector("[data-clock-mh]"); + if (hh) hh.setAttribute("transform", `rotate(${st.hourTurn.toFixed(2)} 22 22)`); + if (mh) mh.setAttribute("transform", `rotate(${st.minuteTurn.toFixed(2)} 22 22)`); +} diff --git a/umtool/report-to-video/post-clock.test.mjs b/umtool/report-to-video/post-clock.test.mjs @@ -0,0 +1,103 @@ +// A post item's CLOCK (post-clock.mjs) and the PACE knob (post-narration.mjs +// POST_PACES): which items show it, its plan from the item before (forward, +// rewind, none), its face in the zone, the run's states, the validation. +import assert from "node:assert/strict"; +import { test } from "node:test"; +import { CLOCK_TICK, clockFace, clockFrameTimes, clockOn, clockPlan, clockStateAt, gapLabel, validateClockRender } from "./post-clock.mjs"; +import { validatePostFx } from "./word-zoom.mjs"; +import { narrationSchedule, postNarrationKnobs, validatePostNarration } from "./post-narration.mjs"; +import { validatePostsRender } from "./post-redact.mjs"; + +const post = (id, date, o = {}) => ({ type: "post", id, post: `s/${id}`, platform: "x", author: "S", handle: "s", date, text: "do you want to die?", ...o }); +const CLK = { fx: [{ kind: "clock" }] }; + +test("which items show it: an item's own clock fx, else the cut's render.posts.clock.on; never one without a date", () => { + assert.equal(clockOn(post("a", "2026-11-02T22:15:00Z"), {}), false); + assert.equal(clockOn(post("a", "2026-11-02T22:15:00Z", CLK), {}), true); + assert.equal(clockOn(post("a", "2026-11-02T22:15:00Z"), { posts: { clock: { on: true } } }), true); + assert.equal(clockOn(post("a", "2026-11-02T22:15:00Z", { fx: [{ kind: "clock", on: false }] }), { posts: { clock: { on: true } } }), false); + assert.equal(clockOn(post("a", "", CLK), {}), false); +}); + +test("its face: the post's time in the operator's zone (ET), the date as a day", () => { + assert.deepEqual( + (({ time, zone, date }) => ({ time, zone, date }))(clockFace(Date.parse("2026-11-04T09:10:00Z"))), + { time: "4:10 AM", zone: "ET", date: "Wed 4 Nov" }, + ); + assert.equal(clockFace(Date.parse("2026-11-04T09:10:00Z"), "Europe/London").time, "9:10 AM"); +}); + +test("the plan: forward from the clock item before, a rewind when this one is earlier, none after a non-clock item", () => { + const a = post("a", "2026-11-02T22:15:00Z", CLK); + const b = post("b", "2026-11-02T22:15:39Z", CLK); + const fwd = clockPlan(b, {}, a); + assert.equal(fwd.mode, "forward"); + assert.equal(fwd.gap, 39000); + const back = clockPlan(post("c", "2026-11-02T10:10:07Z", CLK), {}, b); + assert.equal(back.mode, "rewind"); + assert.equal(clockPlan(b, {}, post("x", "2026-11-02T20:00:00Z")).mode, "none"); + assert.equal(clockPlan(b, {}, null).mode, "none"); + // Forced and suppressed. + assert.equal(clockPlan(post("c", "2026-11-02T10:10:07Z", { fx: [{ kind: "clock", rewind: "off" }] }), {}, b).mode, "none"); + const forced = clockPlan(post("d", "2026-11-02T23:00:00Z", { fx: [{ kind: "clock", rewind: "on" }] }), {}, b); + assert.equal(forced.mode, "rewind"); + assert.equal(forced.forced, true); + assert.ok(forced.from > forced.to); + // A repeat of the same post (the same time): nothing to run. + assert.equal(clockPlan(post("e", "2026-11-02T22:15:39Z", CLK), {}, b).mode, "none"); + assert.equal(clockPlan(post("f", "2026-11-02T22:15:39Z"), {}, b), null); +}); + +test("the run: from the earlier time to this one over CLOCK_TICK, the gap flashing; a rewind spins the hands backwards", () => { + const a = post("a", "2026-11-02T13:30:00Z", CLK); + const b = post("b", "2026-11-02T14:08:00Z", CLK); + const p = clockPlan(b, {}, a); + const s0 = clockStateAt(p, 0); + const s1 = clockStateAt(p, CLOCK_TICK); + assert.equal(s0.time, "8:30 AM"); + assert.equal(s1.time, "9:08 AM"); + assert.equal(s0.gap, "+38 min"); + assert.ok(s0.running && !s1.running); + assert.ok(s1.minuteTurn > s0.minuteTurn); + assert.equal(clockStateAt(p, 3).gapOpacity, 0); + const r = clockPlan(post("c", "2026-10-30T13:00:00Z", CLK), {}, b); + const r0 = clockStateAt(r, 0); + const r1 = clockStateAt(r, CLOCK_TICK); + assert.ok(r1.minuteTurn < r0.minuteTurn, "the hands run backwards"); + assert.match(r0.gap, /^⟲ rewind −3 d 1 h/); + assert.equal(r0.date, "Mon 2 Nov"); + assert.equal(r1.date, "Fri 30 Oct"); + assert.equal(clockFrameTimes(clockPlan(b, {}, null)).length, 1); + assert.ok(clockFrameTimes(p, 30).length > 50); +}); + +test("gap labels", () => { + assert.equal(gapLabel(39000), "+39 s"); + assert.equal(gapLabel(38 * 60000), "+38 min"); + assert.equal(gapLabel((2 * 60 + 14) * 60000), "+2 h 14 min"); + assert.equal(gapLabel(-(3 * 86400 + 4 * 3600) * 1000), "−3 d 4 h"); +}); + +test("validation: the item's clock fx and the cut's render.posts.clock", () => { + assert.deepEqual(validatePostFx(post("a", "2026-11-02T22:15:00Z", { fx: [{ kind: "clock", rewind: "auto" }] })), []); + assert.match(validatePostFx(post("a", "2026-11-02T22:15:00Z", { fx: [{ kind: "clock", rewind: "back" }] })).join(), /rewind must be one of auto, on, off/); + assert.match(validatePostFx(post("a", "2026-11-02T22:15:00Z", { fx: [{ kind: "clock" }, { kind: "clock" }] })).join(), /one clock per item/); + assert.deepEqual(validateClockRender({ on: true, zone: "America/New_York" }), []); + assert.match(validatePostsRender({ posts: { clock: { zone: "Mars/Olympus" } } }).join(), /is not a time zone/); +}); + +test("THE PACE: fast plays a post back to back -- its gap knobs, unless it sets one; the cut's pace too; normal is the cut's", () => { + const take = { file: "n/t.wav", engine: "orpheus", voice: "zac", seconds: 5, script: "x" }; + const e = post("a", "2026-11-02T22:15:00Z", { narration: { script: "x", takes: [take], pace: "fast" } }); + const k = postNarrationKnobs(e, {}); + assert.deepEqual([k.lead, k.tail, k.ramp, k.linger], [0.1, 0.15, 0.3, 0.45]); + assert.equal(narrationSchedule(e, {}).at, 0.1); + const own = post("a", "2026-11-02T22:15:00Z", { narration: { script: "x", takes: [take], pace: "fast", linger: 1 } }); + assert.equal(postNarrationKnobs(own, {}).linger, 1); + const cut = { postNarration: { pace: "fast" } }; + const plain = post("a", "2026-11-02T22:15:00Z", { narration: { script: "x", takes: [take] } }); + assert.equal(postNarrationKnobs(plain, cut).linger, 0.45); + const normal = post("a", "2026-11-02T22:15:00Z", { narration: { script: "x", takes: [take], pace: "normal" } }); + assert.equal(postNarrationKnobs(normal, cut).linger, 1.8); + assert.match(validatePostNarration(post("a", "2026-11-02T22:15:00Z", { narration: { script: "x", pace: "slow" } })).join(), /pace must be fast or normal/); +}); diff --git a/umtool/report-to-video/post-narration.mjs b/umtool/report-to-video/post-narration.mjs @@ -134,6 +134,8 @@ export const POST_NARRATION_DEFAULTS = Object.freeze({ rate: 1, engine: "orpheus", voice: "zac", + // The pace (POST_PACES): normal is the cut's gaps; fast plays each post back to back. + pace: "normal", }); export const POST_NARRATION_LIMITS = Object.freeze({ @@ -164,7 +166,15 @@ export const POST_NARRATION_LIMIT = 0.95; export const POST_NARRATION_CLIP = Object.freeze(["read", "full"]); -const MIX_KEYS = ["lead", "tail", "ramp", "linger", "clip", "wet", "lowpassHz", "duck", "short", "attach", "lufs", "rate"]; +/** + * THE PACE (operator, 4 Nov: a burst "chronologically and quickly"): `pace: + * "fast"` on one post (or the cut) plays it back to back -- the read starts at + * once and the item ends just after the words. Its gap knobs, unless the post + * sets one itself (its own lead/linger always win); "normal" is the cut's. + */ +export const POST_PACES = Object.freeze({ fast: Object.freeze({ lead: 0.1, tail: 0.15, ramp: 0.3, linger: 0.45 }), normal: Object.freeze({}) }); + +const MIX_KEYS = ["lead", "tail", "ramp", "linger", "clip", "wet", "lowpassHz", "duck", "short", "attach", "lufs", "rate", "pace"]; // `attach` is one post's (it decides the card's layout, which is drawn from the entry alone). // `follow`: the cut's read-follow (read-follow.mjs) -- { on, dim, ease } -- kept here with the mix it rides on. // `thread`: the cut's thread reads (post-thread.mjs) -- what each context post is on screen, the shrink and dim. @@ -195,6 +205,9 @@ export function postNarrationKnobs(entry, render) { const n = isObj(entry?.narration) ? entry.narration : {}; const out = { ...base, attach: POST_NARRATION_DEFAULTS.attach }; for (const k of [...MIX_KEYS, "engine", "voice"]) if (n[k] !== undefined && n[k] !== null) out[k] = n[k]; + // Its pace (POST_PACES): the post's, else the cut's -- its gap knobs, unless the post sets one itself. + const pace = POST_PACES[out.pace] ? out.pace : "normal"; + for (const [k, v] of Object.entries(POST_PACES[pace])) if (n[k] === undefined || n[k] === null) out[k] = v; return out; } @@ -544,6 +557,7 @@ function mixErrors(o, where) { if (o[k] !== undefined && !numIn(o[k], POST_NARRATION_LIMITS[k])) errors.push(`${where}.${k} must be ${POST_NARRATION_LIMITS[k][0]}–${POST_NARRATION_LIMITS[k][1]}`); } if (o.duck !== undefined && typeof o.duck !== "boolean") errors.push(`${where}.duck must be true or false`); + if (o.pace !== undefined && !Object.keys(POST_PACES).includes(o.pace)) errors.push(`${where}.pace must be ${Object.keys(POST_PACES).join(" or ")}`); if (o.clip !== undefined && !POST_NARRATION_CLIP.includes(o.clip)) errors.push(`${where}.clip must be ${POST_NARRATION_CLIP.join(" or ")}`); if (o.short !== undefined && !POST_NARRATION_SHORT.includes(o.short)) errors.push(`${where}.short must be ${POST_NARRATION_SHORT.join(" or ")}`); if (o.attach !== undefined && !POST_NARRATION_ATTACH.includes(o.attach)) errors.push(`${where}.attach must be ${POST_NARRATION_ATTACH.join(" or ")}`); diff --git a/umtool/report-to-video/post-redact.mjs b/umtool/report-to-video/post-redact.mjs @@ -30,6 +30,7 @@ // PURE (the build, the route, Play and the writers). import { censorMarkupErrors } from "./post-censor.mjs"; import { BLACKOUT_MARK, SLUR_CSS, decodePlaceholder, hasSlurMarks, maskSlurs, placeholdersHtml, sayFor, slurMatches, slursOn, validateSlursRender } from "./post-slurs.mjs"; +import { validateClockRender } from "./post-clock.mjs"; /** The mark a redacted code unit becomes (a private-use character: never typed, never drawn as a letter). */ export const REDACT_MARK = ""; @@ -188,7 +189,8 @@ export function validatePostsRender(render) { const p = render?.posts; if (p === undefined) return []; if (!isObj(p)) return ["render.posts must be an object ({redact, slurs})"]; - return [...validateRedactTerms(p.redact), ...validateSlursRender(p.slurs)]; + // Its clock (post-clock.mjs): the cut's default and zone. + return [...validateRedactTerms(p.redact), ...validateSlursRender(p.slurs), ...validateClockRender(p.clock)]; } /** Every reason a channel's posts-markup.json is refused. */ diff --git a/umtool/report-to-video/post-render.mjs b/umtool/report-to-video/post-render.mjs @@ -26,6 +26,7 @@ import { bleepFilters, slursOn, takeBleeps } from "./post-slurs.mjs"; import { blurFilters, blurOn, censorEntry, labelFilter } from "./post-censor.mjs"; import { sceneEntry } from "./post-media-scene.mjs"; import { CAPTION_SLIDE, captionCss, captionInnerHtml, captionPlan, measureCaptionWords, mountCaptions, placeCaption, setCaptionState, slideDir } from "./post-caption.mjs"; +import { clockCss, clockFace, clockFrameTimes, clockHtml, clockPlan, clockStateAt, measureClockPlace, mountClock, setClockState } from "./post-clock.mjs"; import { WORD_ZOOM_DEFAULTS, findMatch, overlappingZooms, resolveWordZoom, targetScope, targetTextOf, wordZoomTimes, zoomSpan, zoomTarget, zoompanExprs } from "./word-zoom.mjs"; const r3 = (v) => Math.round(v * 1000) / 1000; @@ -69,7 +70,7 @@ export function stepCaptions(step, cues) { * * @returns {string[]} */ -export function postSegmentArgs({ entry, box, plan, layout, cards, files, render, place = [], encode = [], captions = [], fontfile = null, outPath, narration = null, zooms = [], follow = null, captionFx = [] }) { +export function postSegmentArgs({ entry, box, plan, layout, cards, files, render, place = [], encode = [], captions = [], fontfile = null, outPath, narration = null, zooms = [], follow = null, captionFx = [], clock = null }) { const fps = render.fps ?? 30; const T = plan.total; const inputs = []; @@ -148,6 +149,15 @@ export function postSegmentArgs({ entry, box, plan, layout, cards, files, render if (c.mark) layer(c.mark, `cpm${ci}`, null); layer(c.chip, `cpc${ci}`, c.slide); }); + // THE CLOCK (post-clock.mjs): its frames shot alone -- the run from the item before's time, then held -- laid + // over the card's corner from the first frame (a stack card's: until its media phase). + if (clock) { + const ci = add(["-f", "concat", "-safe", "0", "-i", clock.list]); + parts.push(`[${ci}:v]fps=${fps},format=rgba,setsar=1,setpts=PTS-STARTPTS[clk]`); + const next = `b${++n}`; + parts.push(`[${cur}][clk]overlay=x=${clock.x}:y=${clock.y}:eof_action=repeat${clock.until < T ? `:enable='lt(t,${num(clock.until)})'` : ""}[${next}]`); + cur = next; + } const audio = []; const picture = (st) => !!st && (st.kind === "image" || st.kind === "grid" || st.kind === "gif"); plan.steps.forEach((step, si) => { @@ -276,7 +286,7 @@ async function loadChromium() { * stack layout. The page is a file beside them, so its faces and the parent * shot load from disk (an about:blank page may not read file: urls). */ -export async function renderPostCards(entry, { box, render, dir, manifestDir, layout, avatars = {}, zooms = [], redaction = null, follow = null, total = 0, captions = [] }) { +export async function renderPostCards(entry, { box, render, dir, manifestDir, layout, avatars = {}, zooms = [], redaction = null, follow = null, total = 0, captions = [], clock = null }) { await mkdir(dir, { recursive: true }); const fonts = { regular: render.fontRegular ? pathToFileURL(render.fontRegular).href : "", @@ -319,6 +329,7 @@ export async function renderPostCards(entry, { box, render, dir, manifestDir, la await ctx.close(); if (zooms.length) out.zooms = await shootZooms(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, zooms, redaction, follow }); if (captions.length) out.captions = await shootCaptions(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, captions, redaction, follow }); + if (clock) out.clock = await shootClock(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, clock, redaction, follow, total }); } finally { await browser.close(); } @@ -535,6 +546,80 @@ export async function shootCaptions(browser, entry, { box, render, dir, fonts, p } /** + * THE CLOCK's FRAMES (post-clock.mjs): on the card page as drawn, the chip + * mounted at its widest and placed (measureClockPlace: the bottom-right corner + * by the counts row, else the top-right -- over no word), then shot alone on a + * clear page at each frame of its run and its badge's fade (each distinct one + * once) and a concat list holding each for its frames, the last to the end. + * `{ list, x, y, place, covers, shots }`. + */ +export async function shootClock(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, clock, redaction = null, follow = null, total = 0 }) { + const fps = render.fps ?? 30; + const k = box.height / 1080; + const ctx = await browser.newContext({ viewport: { width: box.width, height: box.height }, deviceScaleFactor: 1, offline: true, serviceWorkers: "block" }); + const page = await ctx.newPage(); + const av = Object.fromEntries(Object.entries(avatars).map(([h, f]) => [h, pathToFileURL(f).href])); + try { + const file = path.join(dir, "clock.html"); + await writeFile(file, postCardHtml(entry, { width: box.width, height: box.height, palette: render.palette, fonts, phase: "read", parentShotUrl, avatars: av, redaction, follow: !!follow, thread: follow?.thread ?? null }), "utf8"); + await page.goto(pathToFileURL(file).href, { waitUntil: "load" }); + await page.waitForSelector("body[data-post-ready='1']", { timeout: 15000 }); + const face = clockFace(clock.to, clock.zone); + const size = await page.evaluate(mountClock, { css: clockCss({ height: box.height, palette: render.palette }), html: clockHtml(), widest: { time: "12:58 PM", zone: face.zone, date: "Wed 30 Sep" } }); + await page.evaluate(() => document.fonts.ready.then(() => true)); + // Placed as the card is when its own post is in (the read's end: a threaded card's counts row is there), and + // judged over the read (its start, middle and end): the place covering fewest words over all three wins. + const fpath = follow ? followPath(follow, await page.evaluate(measureFollow)) : null; + const states = follow ? [total, 0, total / 2] : [0]; + const looks = []; + for (const s of states) { + if (follow) await page.evaluate(applyFollowState, followStateAt(follow, fpath, s)); + looks.push(await page.evaluate(measureClockPlace, { size, inset: Math.round(22 * k), fixed: looks[0]?.tries ?? null })); + } + const at0 = looks[0]; + const at = at0 ? at0.tries.map((t, i) => ({ ...t, covers: looks.reduce((a, l) => a + (l?.tries?.[i]?.covers ?? 0), 0) })).sort((a, b) => a.covers - b.covers)[0] : null; + if (follow) await page.evaluate(applyFollowState, followStateAt(follow, fpath, 0)); + if (!at) throw new Error(`${entry.id}: the clock has no card to sit on`); + await page.evaluate(() => { + const st = document.createElement("style"); + st.textContent = "html, body { background: transparent !important; } body > *:not([data-post-clock-layer]) { visibility: hidden !important; }"; + document.head.appendChild(st); + }); + // The clip: the chip and its badge to its left. + const left = Math.round(300 * k); + const x = Math.max(0, at.x - left); + const y = Math.max(0, at.y - Math.round(10 * k)); + const clip = { x, y, width: Math.min(box.width - x, at.x + size.width + Math.round(16 * k) - x), height: Math.min(box.height - y, size.height + Math.round(20 * k)) }; + const fdir = path.join(dir, "clock"); + await rm(fdir, { recursive: true, force: true }); + await mkdir(fdir, { recursive: true }); + const shots = new Map(); + const runs = []; + for (const s of clockFrameTimes(clock, fps)) { + const st = clockStateAt(clock, s); + const key = JSON.stringify([st.time, st.date, st.gap, Math.round(st.gapOpacity * 50), Math.round(st.hourTurn * 2), Math.round(st.minuteTurn), st.running]); + if (!shots.has(key)) { + const f = path.join(fdir, `c-${String(shots.size).padStart(4, "0")}.png`); + await page.evaluate(setClockState, { x: at.x, y: at.y, st }); + await page.screenshot({ path: f, clip, omitBackground: true }); + shots.set(key, f); + } + if (runs.length && runs[runs.length - 1].key === key) runs[runs.length - 1].n += 1; + else runs.push({ key, n: 1 }); + } + const q = (f) => `'${f.replace(/'/g, "'\\''")}'`; + const lines = ["ffconcat version 1.0"]; + runs.forEach((r, i) => lines.push(`file ${q(shots.get(r.key))}`, `duration ${(r.n / fps).toFixed(6)}`)); + lines.push(`file ${q(shots.get(runs[runs.length - 1].key))}`); + const list = path.join(fdir, "frames.ffconcat"); + await writeFile(list, lines.join("\n") + "\n", "utf8"); + return { list, x: clip.x, y: clip.y, place: at.place, covers: at.covers, shots: shots.size }; + } finally { + await ctx.close(); + } +} + +/** * A post item's word zooms, resolved for the build: `[{ i, scope, from, to, * scale, highlight, span }]`, each on its time (wordZoomTimes) -- refused in * the build's words when one has no time, or two are up at once. @@ -602,7 +687,7 @@ export async function buildPostSegment(entry, { render, outDir, manifestDir, box })); const key = createHash("sha256") // A redaction that changes what the card draws changes the key; none leaves it as it was. - .update(JSON.stringify({ v: 1, entry, ...(redactionOn(redaction) ? { published: redactEntry(entry, redaction), blank: termsFor(entry, redaction) } : {}), box, place, palette: render.palette, fonts: [render.fontRegular, render.fontBold], fps: render.fps, encode, stamps, ...(Object.keys(avatars).length ? { avatars } : {}), ...(take ? { narration: plan.narration, postNarration: render.postNarration ?? null } : {}), ...(plan.follow ? { follow: plan.follow } : {}), ...(bleeps ? { bleeps } : {}), ...(slursOn(redaction?.slurs) ? { slurs: redaction.slurs } : {}) })) + .update(JSON.stringify({ v: 1, entry, ...(redactionOn(redaction) ? { published: redactEntry(entry, redaction), blank: termsFor(entry, redaction) } : {}), box, place, palette: render.palette, fonts: [render.fontRegular, render.fontBold], fps: render.fps, encode, stamps, ...(Object.keys(avatars).length ? { avatars } : {}), ...(take ? { narration: plan.narration, postNarration: render.postNarration ?? null } : {}), ...(plan.follow ? { follow: plan.follow } : {}), ...(bleeps ? { bleeps } : {}), ...(slursOn(redaction?.slurs) ? { slurs: redaction.slurs } : {}), ...(clockPlan(entry, render, prev) ? { clock: clockPlan(entry, render, prev) } : {}) })) .digest("hex"); const record = postRecordPath(seg); const had = await readFile(record, "utf8").then((t) => JSON.parse(t), () => null); @@ -614,7 +699,9 @@ export async function buildPostSegment(entry, { render, outDir, manifestDir, box const zoomPlan = postZoomPlan(entry, render, plan.total); // Its captions (post-caption.mjs): each waits for a zoom it would be up with, and is gone by the media phase (a stack card). const capPlan = captionPlan(entry, render, { zooms: zoomPlan.map((z) => ({ ...z.span, i: z.i })), end: layout.mode === "stack" && plan.steps.length ? plan.steps[0].at : plan.total, schedule: plan.narration ?? undefined }); - const cards = await renderPostCards(entry, { box, render, dir: cardDir, manifestDir, layout, avatars, zooms: zoomPlan, redaction, follow: plan.follow ?? null, total: plan.total, captions: capPlan }); + // Its clock (post-clock.mjs): the post's own time, run from the clock item before it. + const clk = clockPlan(entry, render, prev); + const cards = await renderPostCards(entry, { box, render, dir: cardDir, manifestDir, layout, avatars, zooms: zoomPlan, redaction, follow: plan.follow ?? null, total: plan.total, captions: capPlan, clock: clk }); // NO HIDDEN TEXT IS EVER NARRATED (operator, 4 Nov): a part whose words are not in view, whole and lit, while it // is said -- or a context post drawn over its context size -- refuses the build (READ_IN_VIEW=warn: a note). if (cards.inView?.length) { @@ -645,7 +732,7 @@ export async function buildPostSegment(entry, { render, outDir, manifestDir, box const lufs = Number.isFinite(take.lufs) ? take.lufs : await measureLufsOf(takeFile, { exec, ffmpeg }); narration = { file: takeFile, gainDb: narrationLevelDb(lufs, plan.narration.lufs), lufs, ...(bleeps ? { bleeps } : {}) }; } - const argv = postSegmentArgs({ entry, box, plan, layout, cards, files, render, place, encode, captions, fontfile: render.fontBold ?? render.fontRegular ?? null, outPath: tmp, narration, zooms, follow: cards.follow ?? null, captionFx: cards.captions ?? [] }); + const argv = postSegmentArgs({ entry, box, plan, layout, cards, files, render, place, encode, captions, fontfile: render.fontBold ?? render.fontRegular ?? null, outPath: tmp, narration, zooms, follow: cards.follow ?? null, captionFx: cards.captions ?? [], clock: cards.clock ? { ...cards.clock, until: layout.mode === "stack" && plan.steps.length ? plan.steps[0].at : plan.total } : null }); try { await exec(ffmpeg, argv, { maxBuffer: 1 << 24 }); } catch (err) { @@ -662,6 +749,7 @@ export async function buildPostSegment(entry, { render, outDir, manifestDir, box : `${entry.id}: post item ${plan.total.toFixed(1)} s (${layout.mode}: ${plan.reading.toFixed(1)} s to read${plan.steps.length ? `, ${plan.steps.length} attachment step(s)` : ""})`, }); if (cards.follow) emit("note", { message: `${entry.id}: read-follow -- ${plan.follow.blocks.filter((b) => b.start !== null).length} block(s) read, ${cards.follow.path.segments.length ? `the words panned ${cards.follow.path.segments.length} time(s) over ${Math.round(cards.follow.path.max)} px` : "no pan (the words fit)"}; ${cards.follow.shots} shot(s) for ${cards.follow.frames} frames` }); + if (cards.clock) emit("note", { message: `${entry.id}: clock ${clockFace(clk.to, clk.zone).time} ${clockFace(clk.to, clk.zone).date} (${clk.mode === "none" ? "shown" : clk.mode === "rewind" ? "rewound" : "run forward"}${clk.mode === "none" ? "" : ` from the item before, ${clk.gap / 60000 | 0} min`}), ${cards.clock.place}${cards.clock.covers ? ` -- WARNING: over ${cards.clock.covers} word(s)` : ""}` }); for (const c of cards.captions ?? []) emit("note", { message: `${entry.id}: caption ${c.i + 1} "${c.text}" at ${c.t.toFixed(2)} s (${c.source === "at" ? "set by hand" : c.source === "words" ? "from the take's words" : "the reading estimate"}${c.span.waited !== null ? `, after word zoom ${c.span.waited + 1}` : ""}), ${c.span.t0}–${c.span.t3} s, ${c.placed.place} the phrase${c.placed.covers ? ` -- WARNING: it covers ${c.placed.covers} word(s) read while it is up (no place by the phrase is clear: set its place, hold or at)` : ""}` }); for (const z of zooms) emit("note", { message: `${entry.id}: word zoom ${z.i + 1} at ${z.t.toFixed(2)} s (${z.source === "at" ? "set by hand" : "from the take's words"}), ${z.span.scale}× over ${z.span.t0}–${z.span.t3} s` }); return seg; diff --git a/umtool/report-to-video/word-zoom.mjs b/umtool/report-to-video/word-zoom.mjs @@ -32,9 +32,11 @@ import { cardText, contextText, parentsOf } from "./post-item.mjs"; import { isNarrated, narrationSchedule, pickedTake } from "./post-narration.mjs"; import { captionErrors } from "./post-caption.mjs"; +import { clockErrors } from "./post-clock.mjs"; -// A post's effects: a word zoom, and a CAPTION (post-caption.mjs: a chip explaining a phrase as it is read). -export const POST_FX_KINDS = Object.freeze(["word-zoom", "caption"]); +// A post's effects: a word zoom, a CAPTION (post-caption.mjs: a chip explaining a phrase as it is read), and its +// CLOCK (post-clock.mjs: the post's time on the card, running from the item before's). +export const POST_FX_KINDS = Object.freeze(["word-zoom", "caption", "clock"]); export const POST_FX_MAX = 8; export const WORD_ZOOM_EASES = Object.freeze(["out", "inOut", "snap"]); export const WORD_ZOOM_DEFAULTS = Object.freeze({ target: "post", occurrence: 1, lead: 0.5, hold: 1.2, scale: 2, ease: "inOut", highlight: "#ffd84d" }); @@ -139,6 +141,7 @@ export function validatePostFx(e) { if (!isObj(fx)) return errors.push(`${fw} must be an object`); if (!POST_FX_KINDS.includes(fx.kind)) return errors.push(`${fw}.kind must be one of ${POST_FX_KINDS.join(", ")}`); if (fx.kind === "caption") return errors.push(...captionErrors(e, fx, fw)); + if (fx.kind === "clock") return errors.push(...clockErrors(e, fx, fw)); for (const k of Object.keys(fx)) if (!KEYS.has(k)) errors.push(`${fw}.${k} is not a word-zoom key (${[...KEYS].join(", ")})`); const target = fx.target ?? "post"; const text = typeof target === "string" ? targetTextOf(e, target) : null;