Archilyzer · Source

archilyzer

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

commit ab3d1cb460938e5d190ab6ea3fb131c9a07470d4
parent 15a057af8feeb28bd8c901a64579414401dae9d1
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed,  4 Nov 2026 21:32:00 -0500

Merge lane/join-continuity: a join morphs from the frame the item before actually ENDED on (its record's joinAnchor, clock, carry), measured against the rendered frames -- 9 of 12 planned joins smooth on the proof against main's 4; an attachment of a post read after its context enters with his post (media.<i>.enter, default post; item opts out); the frames lists no longer drop a frame every 0.2 s (operator, 4 Nov: "If one post is visible in the next scene, there should be a transition"; "the mr. obvious gif should come in when his post does")

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

Diffstat:
Mumtool/app/api/report/post-item/route.ts | 12+++++-------
Mumtool/bin/umtool.mjs | 5+++++
Mumtool/components/projects/review/PlayCut.tsx | 2+-
Mumtool/components/projects/review/PostItemPlayer.tsx | 78++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------
Mumtool/docs/cli.md | 3++-
Mumtool/docs/report-video.md | 55++++++++++++++++++++++++++++++++++++++++++++++---------
Aumtool/lib/report/checkJoinsCli.mjs | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/lib/report/manifest.mjs | 2+-
Mumtool/lib/report/postsCli.mjs | 12++++++++----
Mumtool/report-to-video/build-video.mjs | 10+++++++---
Aumtool/report-to-video/check-joins.mjs | 291++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/report-to-video/check-joins.test.mjs | 51+++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/report-to-video/package.json | 1+
Mumtool/report-to-video/post-item.mjs | 70++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
Aumtool/report-to-video/post-join-continuity.test.mjs | 110+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/report-to-video/post-join.mjs | 63++++++++++++++++++++++++++++++++++++++++++++++++++-------------
Aumtool/report-to-video/post-media-enter.test.mjs | 81+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/report-to-video/post-render.mjs | 180+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------
18 files changed, 982 insertions(+), 106 deletions(-)

diff --git a/umtool/app/api/report/post-item/route.ts b/umtool/app/api/report/post-item/route.ts @@ -1,6 +1,6 @@ import { readFile, realpath, stat } from "node:fs/promises"; import path from "node:path"; -import { cardWordsSize, panelEntry, postCardHtml, postItemPlan } from "umtool-report-to-video/post-item"; +import { joinCarryOf, panelEntry, postCardHtml, postItemPlan } from "umtool-report-to-video/post-item"; import { avatarUrls } from "umtool-report-to-video/post-avatars"; import { jobState, startJob } from "@/lib/research/case-editor"; import { withEditNotes } from "@/lib/report/guard"; @@ -63,12 +63,10 @@ async function itemOf(project: { dir: string }, manifest: Record<string, unknown return { item: at >= 0 ? tl[at] : null, prev: ctx.prev, ctx, prevCtx, manifest: m }; } -/** The size the item before draws its post's words at (post-item.mjs cardWordsSize; threaded when its plan is). */ -function joinWordsSize(prev: Entry, prevCtx: Record<string, unknown> | null, render: Record<string, unknown>, box: { width: number; height: number }) { +/** How the item before draws its post (post-item.mjs joinCarryOf), as the build draws the carried post alike. */ +function joinCarry(prev: Entry, prevCtx: Record<string, unknown> | null, render: Record<string, unknown>, box: { width: number; height: number }) { const pe = panelEntry(prev, render) as Entry; - const follow = followKnobs(pe, render).on; - const plan = postItemPlan(pe, render, (prevCtx ?? {}) as never) as { follow?: { thread?: unknown } }; - return cardWordsSize(pe, box, { follow, threaded: follow && !!plan.follow?.thread }); + return joinCarryOf(pe, postItemPlan(pe, render, (prevCtx ?? {}) as never) as never, box, render); } /** A project file under posts-media/, never outside it (its real path checked). */ @@ -221,7 +219,7 @@ export async function GET(request: Request) { thread: followOn ? (scene ? sceneLayout(isNarrated(item) ? tlayout : null, item, scene) ?? tlayout : tlayout) : null, redaction, // THE JOIN (post-join.mjs): the post the item before ended on drawn as it drew its post (Play lays the morph). - join: followOn && found.ctx.join && found.prev?.type === "post" ? { size: joinWordsSize(found.prev as Entry, found.prevCtx, cutRender, { width: w, height: h }) } : null, + join: followOn && found.ctx.join && found.prev?.type === "post" ? joinCarry(found.prev as Entry, found.prevCtx, cutRender, { width: w, height: h }) : null, }); return new Response(html, { headers: { "content-type": "text/html; charset=utf-8", ...noStore } }); } diff --git a/umtool/bin/umtool.mjs b/umtool/bin/umtool.mjs @@ -16,6 +16,7 @@ // umtool check [<project> | --all] [--json] exit 1 on anything blocking // umtool links <project> [--json] [--fix] do the clip QRs open on their sites (out/links.json) // umtool speaker-check <project> [--clip <id> …] [--set 'Name=…'] [--list] which named voice each clip is (speaker-check.json) +// umtool check-joins <project> --take <id> [--json] [--all] do the post joins of a rendered take carry on, or jump // umtool link-policy <project> [--via <site>] [--direct a,b] [--clear] [--fix] cite via site X; these channels direct // umtool decisions [--json] // umtool inbox [--all] [--json] the decisions grouped as the inbox ranks them @@ -852,6 +853,8 @@ function usage() { " -> the shard's record; polite, cached; out/links.json, which check reads); exit 1 when one is dead", " umtool speaker-check <project> [--clip <id> …] [--json] which of the project's named voices (speakers.json) each", " clip is: TitaNet-small, local -> speaker-check.json; --set 'Name=<clip>,<channel>/<id>,channel:<slug>' / --remove / --list", + " umtool check-joins <project> --take <id> [--json] [--all] [--limit <n>] every boundary of the take's master where the", + " next post item draws a post the one before showed: its join, the SSIM across it, the largest jump", " umtool link-policy <project> [--via <site id|url>] [--direct a,b] [--clear] [--fix] [--json] the link policy", " (provenance.linkPolicy): cite via site X, these channels direct; --fix rewrites the clips that break it", " umtool patch-markers <project> [<file>.patch.json] [--fix] [--json] take patches whose deck markers name a", @@ -1113,6 +1116,8 @@ const COMMANDS = { links: async () => process.exit(await (await import("../lib/report/linksCli.mjs")).linksCommand(argv.slice(argv.indexOf("links") + 1))), // Which named voice each clip is (UI notes #15): lib/report/speakerCheck.mjs. "speaker-check": async () => process.exit(await (await import("../lib/report/speakerCheck.mjs")).speakerCheckCommand(argv.slice(argv.indexOf("speaker-check") + 1))), + // Do a rendered take's post joins carry on (operator, 4 Nov, mid-7): lib/report/checkJoinsCli.mjs. + "check-joins": async () => process.exit(await (await import("../lib/report/checkJoinsCli.mjs")).checkJoinsCommand(argv.slice(argv.indexOf("check-joins") + 1))), // The project's link policy (UI notes #10): lib/report/linksCli.mjs. "link-policy": async () => process.exit(await (await import("../lib/report/linksCli.mjs")).linkPolicyCommand(argv.slice(argv.indexOf("link-policy") + 1))), // A take patch's markers back on the cut (UI notes #6): lib/report/linksCli.mjs. diff --git a/umtool/components/projects/review/PlayCut.tsx b/umtool/components/projects/review/PlayCut.tsx @@ -866,7 +866,7 @@ export default function PlayCut({ joinFrom={(() => { // THE JOIN (post-join.mjs): the item before, so this one opens on it as it ended. const before = ui.cur > 0 ? entryOf.get(plan.items[ui.cur - 1]?.id ?? "") : null; - return postNow.entry.postPlan?.follow?.join && before?.type === "post" && before.post && before.postPlan ? { entry: before.post, plan: before.postPlan } : null; + return postNow.entry.postPlan?.follow?.join && before?.type === "post" && before.post && before.postPlan ? { entry: before.post, plan: before.postPlan, clock: before.postClock ?? null } : null; })()} /> ) : null; diff --git a/umtool/components/projects/review/PostItemPlayer.tsx b/umtool/components/projects/review/PostItemPlayer.tsx @@ -1,8 +1,8 @@ "use client"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; -import { POST_PUSH, mediaTimeAt, postLayout, stepAt, stepBoxes } from "umtool-report-to-video/post-item"; -import { applyJoinState, endMediaOf, joinFrameAt } from "umtool-report-to-video/post-join"; +import { POST_ENTER_FADE, POST_PUSH, mediaTimeAt, postLayout, stepAt, stepBoxes } from "umtool-report-to-video/post-item"; +import { applyJoinState, endMediaOf, joinClockOf, joinEase, joinFrameAt } from "umtool-report-to-video/post-join"; import { applyVisitState } from "umtool-report-to-video/post-link-visit"; import { applyMapState, mapHtml, mapPlace, mapSize } from "umtool-report-to-video/post-branch-map"; import { dryGainAt, mixPhaseAt, pickedTake, wetGainAt } from "umtool-report-to-video/post-narration"; @@ -130,6 +130,8 @@ export type PanelShow = { scope: string; media: Array<Record<string, unknown> & export type PostPlan = { panel?: { fade: number; shows: PanelShow[] }; + /** Its own attachments come in at this item second, with his own post (post-item.mjs ownMediaEnterAt). */ + enter?: number; reading: number; total: number; held: number; @@ -490,6 +492,9 @@ function JoinEnds({ project, ends, layout, box, op }: { project: string; ends: A ); } +/** A clock's plan (post-clock.mjs clockPlan). */ +type ClockPlan = { to: number; from: number | null; mode: "forward" | "rewind" | "none"; zone: string; gap: number; forced: boolean }; + export default function PostItemPlayer({ project, take = null, entry, plan, box, s, playing, cardKey = null, speed = 1, published = false, uncensored = false, scene = null, clock = null, joinFrom = null, progress = null, }: { @@ -512,9 +517,9 @@ export default function PostItemPlayer({ /** 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; - /** THE JOIN (post-join.mjs): the item before (its entry and plan) -- this one opens on it as it ended. */ - joinFrom?: { entry: Record<string, unknown> & { id: string }; plan: PostPlan } | null; + clock?: ClockPlan | null; + /** THE JOIN (post-join.mjs): the item before (its entry, plan and clock) -- this one opens on it as it ended. */ + joinFrom?: { entry: Record<string, unknown> & { id: string }; plan: PostPlan; clock?: ClockPlan | null } | null; /** Its progress bar (post-progress.mjs progressPlan), or none. */ progress?: ProgressPlan | null; }) { @@ -560,7 +565,11 @@ export default function PostItemPlayer({ const reading = s < plan.reading || !plan.steps.length; const current = stepAt(plan, s); // Beside the card, the first attachment is up (its first frame) while the words are read. - const shown = current ?? (layout.mode === "side" && plan.steps.length ? plan.steps[0] : null); + // ...unless it comes in with his own post (post-item.mjs ownMediaEnterAt: `plan.enter`): nothing of his until then. + const enterAt = plan.enter ?? 0; + const shown = current ?? (layout.mode === "side" && plan.steps.length && !(enterAt > 0) ? plan.steps[0] : null); + // Crossfaded in from that moment, as the build fades it (POST_ENTER_FADE). + const enterOp = enterAt > 0 && shown === plan.steps[0] ? Math.min(1, Math.max(0, (s - enterAt) / POST_ENTER_FADE)) : 1; const inStep = !!current && shown === current; const mediaPhase = layout.mode === "stack" && !reading; // A video's words, when it was transcribed (media[i].words): the cue at its source second. @@ -585,10 +594,12 @@ export default function PostItemPlayer({ const readFrame = useRef<HTMLIFrameElement | null>(null); // ---- THE JOIN, live (post-join.mjs): the item before's page in a frame of its own, at its last frame's state ---- const joinFrame = useRef<HTMLIFrameElement | null>(null); - const joinMeasure = useRef<{ A: Rect; anchor: number | null; slotA: Rect | null } | null>(null); + const joinMeasure = useRef<{ A: Rect; anchor: number | null; slotA: Rect | null; clock: { x: number; y: number; st: ReturnType<typeof clockStateAt> } | null } | null>(null); const [joinReady, setJoinReady] = useState(0); const joinSecs = plan.follow?.join?.seconds ?? 0; const joinOn = !!joinFrom && joinSecs > 0; + // It carries the post the item before ended on (post-thread.mjs: a carried parent, or the scene's post). + const carries = !!(plan.follow?.thread as { tiles?: Array<{ mode?: string; wasPost?: boolean }> } | undefined)?.tiles?.some((t) => t.mode === "carry" || (t.mode === "scene" && t.wasPost)); const onJoinLoad = useCallback(() => { let tries = 0; const tick = () => { @@ -598,16 +609,32 @@ export default function PostItemPlayer({ return; } const pf = joinFrom.plan.follow ?? null; - if (pf && doc.querySelector("[data-post-flow]")) { - const g = measureFollow(doc); - applyFollowState(followStateAt(pf, g ? followPath(pf, g) : null, Math.max(0, joinFrom.plan.total - 1 / 30)), doc); + const endS = Math.max(0, joinFrom.plan.total - 1 / 30); + const pl = postLayout(joinFrom.entry, box); + const route = pf && doc.querySelector("[data-post-flow]") ? followPath(pf, measureFollow(doc)) : null; + // ITS CLOCK as it ended (post-clock.mjs), placed as Play places this item's: the card at its read's end -- + // laid on its card when this item's does not carry on from it (joinClockOf), as the build's shot is. + const pc = joinFrom.clock && !(pl.mode === "stack" && joinFrom.plan.steps.length) ? joinFrom.clock : null; + let jclock: { x: number; y: number; st: ReturnType<typeof clockStateAt> } | null = null; + if (pc) { + const face = clockFace(pc.to, pc.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); + if (pf && route) applyFollowState(followStateAt(pf, route, joinFrom.plan.total), doc); + const at = size ? measureClockPlace({ size, inset: Math.round(22 * (box.height / 1080)) }, doc) : null; + if (at) jclock = { x: at.x, y: at.y, st: clockStateAt(pc, endS) }; + } + if (pf && route) { + const st = followStateAt(pf, route, endS); + applyFollowState(st, doc); + // A link visit's pointer, as it ended. + const visits = (pf as unknown as { visits?: unknown[] }).visits; + if (visits?.length) applyVisitState({ visits, st: st.visit ?? null }, doc); } const card = doc.querySelector("[data-post-card]"); if (!card) return; const c = card.getBoundingClientRect(); const post = doc.querySelector('[data-thread-slot="post"] .head') ?? card.querySelector(".head"); - const pl = postLayout(joinFrom.entry, box); - joinMeasure.current = { A: { x: c.left, y: c.top, width: c.width, height: c.height }, anchor: post ? post.getBoundingClientRect().top - c.top : null, slotA: pl.slot && pl.mode === "side" ? pl.slot : null }; + joinMeasure.current = { A: { x: c.left, y: c.top, width: c.width, height: c.height }, anchor: post ? post.getBoundingClientRect().top - c.top : null, slotA: pl.slot && pl.mode === "side" ? pl.slot : null, clock: jclock }; setJoinReady((n) => n + 1); }; tick(); @@ -847,13 +874,24 @@ export default function PostItemPlayer({ const jm = joinMeasure.current; if (!doc?.body || !jm) return; if (!doc.body.getAttribute("data-join")) { - doc.body.setAttribute("data-join", JSON.stringify({ A: jm.A, slotA: jm.slotA, slotB: layout.slot && layout.mode === "side" ? layout.slot : null, same: false })); const c = doc.querySelector("[data-post-card]")?.getBoundingClientRect(); + // The same content (the build's rule): the same width, the post it ended on carried in. + const same = !!c && Math.abs(jm.A.width - c.width) < 2 && carries; + doc.body.setAttribute("data-join", JSON.stringify({ A: jm.A, slotA: jm.slotA, slotB: layout.slot && layout.mode === "side" ? layout.slot : null, same })); if (c) setOwnBox({ x: c.left, y: c.top, width: c.width, height: c.height }); } applyJoinState(jp, doc); - }, [jp, joinReady, layout]); - const jframe = jp !== null && joinMeasure.current && ownBox ? joinFrameAt({ A: joinMeasure.current.A, B: ownBox, slotA: joinMeasure.current.slotA, slotB: layout.slot && layout.mode === "side" ? layout.slot : null, same: false }, jp) : null; + }, [jp, joinReady, layout, carries]); + const jframe = jp !== null && joinMeasure.current && ownBox ? joinFrameAt({ A: joinMeasure.current.A, B: ownBox, slotA: joinMeasure.current.slotA, slotB: layout.slot && layout.mode === "side" ? layout.slot : null, same: Math.abs(joinMeasure.current.A.width - ownBox.width) < 2 && carries }, jp) : null; + // THE CLOCK OVER THE JOIN (post-join.mjs joinClockOf): carried on from the item before's (moved the little way), + // or that one on its card as it ended, dissolving with it, and this one coming in. + const joinClock = useMemo(() => (joinOn && joinReady && joinMeasure.current ? joinClockOf({ from: joinMeasure.current.clock, own: clock ? clockAt : null, k: box.height / 1080 }) : null), [joinOn, joinReady, clock, clockAt, box.height]); + useEffect(() => { + const doc = joinFrame.current?.contentDocument; + const jm = joinMeasure.current; + if (!doc || !jm) return; + setClockState(joinClock?.bake && jm.clock?.st ? { x: jm.clock.x, y: jm.clock.y, st: jm.clock.st } : null, doc); + }, [joinClock, joinReady]); // THE BRANCH MAP (post-branch-map.mjs): its own layer over the attachments, where the build lays it. const branchMap = (follow?.thread as { map?: Record<string, unknown> } | undefined)?.map ?? null; const mapRef = useRef<HTMLDivElement | null>(null); @@ -931,8 +969,12 @@ export default function PostItemPlayer({ 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]); + // Over the join: from the item before's place (eased as the card is), or coming in (as the build's fade). + const jc = joinClock && s < joinSecs ? joinClock : null; + const left = jc?.move ? 1 - joinEase(s / joinSecs) : 0; + const at = clockAt && jc?.move ? { x: clockAt.x + jc.move.dx * left, y: clockAt.y + jc.move.dy * left } : clockAt; + setClockState(clockSt && at && s < until ? { ...at, st: clockSt, ...(jc?.fadeIn ? { opacity: Math.max(0, s / joinSecs) } : {}) } : null, doc); + }, [clockSt, clockAt, s, layout.mode, plan.steps, joinClock, joinSecs]); // The bar's fill: the read's real seconds (a part read faster moves it faster), gone in a stack card's media phase. const progFrac = progress ? progressAt(progress, s) : null; useEffect(() => { @@ -1041,7 +1083,7 @@ export default function PostItemPlayer({ {shown && layout.slot && (layout.mode === "side" || mediaPhase) && ( <> {stepBoxes(shown, layout.slot).map((b: { x: number; y: number; width: number; height: number }, j: number) => ( - <MediaEl key={`${plan.steps.indexOf(shown)}:${j}`} joinOp={jframe && !(joinEnds.length === 1 && joinEnds[0].m.src === shown.items[j]?.src) ? Math.min(1, Math.max(0, (jframe.e - 0.35) / 0.65)) : 1} project={project} m={shown.items[j]} box={box} b={b} step={shown} s={s} playing={playing} inStep={inStep} mix={mix} speed={speed} /> + <MediaEl key={`${plan.steps.indexOf(shown)}:${j}`} joinOp={Math.min(enterOp, jframe && !(enterAt > 0) && !(joinEnds.length === 1 && joinEnds[0].m.src === shown.items[j]?.src) ? Math.min(1, Math.max(0, (jframe.e - 0.35) / 0.65)) : 1)} project={project} m={shown.items[j]} box={box} b={b} step={shown} s={s} playing={playing} inStep={inStep} mix={mix} speed={speed} /> ))} {cue && ( <div diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md @@ -72,6 +72,7 @@ Inbox cannot disagree about what is wrong with one. | `phrases "<phrase>" ["<phrase>" …] --channels a,b [--prefer c] [--exclude RE] [--words \| --regex] [--samples N] [--no-cache] [--json \| --full]` | the phrase finder's search ([tools.md](tools.md#the-phrase-finder-toolsphrases)): every phrase in one pass, each with its count once folded, by year, the preferred channel's share or Rumble's, speaker changes, sample contexts. Plain words become a tolerant pattern unless the phrase holds a regular expression's characters. `--json` the numbers, `--full` every instance; `--spec FILE --out FILE --progress` is the page's job form. **Exit 1** on a bad phrase | | `voice-match <project> [--reference auto\|rulings\|recordings] [--reference-video <channel>/<id> …] [--reference-channel <slug> …] [--instances FILE] [--span phrase\|cut] [--pad S] [--likely X --unlikely Y] [--out FILE] [--dry] [--json] [--progress ndjson]` | who is speaking, per montage clip: a local speaker-similarity score (TitaNet-small) against the host's voice → `<project>/voice-match.json` (the Cut tab's **Score the voices**); `--instances` also scores a phrase scan's instances not in the manifest; `--dry` prints the plan ([report-video.md](report-video.md#who-is-speaking-the-voice-match)) | | `speaker-check <project> [--clip <id> …] [--json] [--progress ndjson]` · `--set 'Name=<clip>,<channel>/<id>,channel:<slug>'` · `--remove <name>` · `--list` | which of the project's **named voices** (`speakers.json`) each clip is: TitaNet-small, local, against each voice's robust centroid → `<project>/speaker-check.json` (merged); the walk's **Speaker:** badge and **Check speaker** ([report-video.md](report-video.md#the-speaker-check-on-the-walk-which-of-several-voices)) | +| `check-joins <project> --take <id> [--json] [--all] [--limit <n>]` | do a rendered take's **post joins carry on**: every boundary of its master where the next post item draws a post the one before showed, its planned join, the SSIM across it and the largest frame-to-frame step (read-only, ffmpeg) -- worst first ([report-video.md](report-video.md#thread-scenes-whole-threads-the-join-manual-threads-wide-attachments-context-media-link-visits-the-branch-map)) | | `clips analyze <project> [--from <channel>/<id>] [--rescan] [--no-laughs] [--no-voices] [params] [--words FILE] [--progress ndjson] [--json]` · `clips propose <project> [--from <channel>/<id>] [--host N] [params] [--words FILE] [--dry] [--json]` · `clips show <project> [--json]` · `clips segments <project> [--json]` | the **clip finder** on a long recording ([report-video.md](report-video.md#highlights-the-clip-finder)): `analyze` runs the laugh scan (CED-mini) and a voice centroid per speaker on the recording's sound (cached in `<project>/scans/`), then proposes; `propose` proposes again from what is there (after a role flip, a param change, new words); `show` prints the speakers, laughs and the cut. Params `--target S` (600) `--laugh-min X` (0.25) `--merge-gap S` (6) `--setup-max S` (20) `--clip-max S` (75) and the scope `--scope FROM:TO` (either side may be empty; `all` clears it) or `--from S --to S` with numbers (a `--from` that is a `<channel>/<id>` names the recording), kept in `reactions.json`; `--host N` is your word on the host, kept. `--keep-cut` proposes without touching the cut (nothing moved, removed or added; the proposals are listed). **`--scope auto`** reads the narrated video auto-scope finds in the speaker turns (`--segment sN` names one, else the longest); `segments` lists them. A chat replay beside the recording (`live_chat.cues.json`) adds chat-burst moments and the log names the chat's lag. A channel on no site gets each clip linked to its platform page (`citeUrl`). A clip you edited, ruled, locked or added is never moved. **Exit 2** with no `diarization.json` (the message names the `archilyzer diarize backfill` to run) | | `timeline <project> [ls] [--json]` · `timeline <project> insert --after <id\|-> <channel>/<video>@<start>-<end> [--id ID] [--section N] [--lock] [--lock-end] [--title T] [--stream-title T] [--date YYYY-MM-DD] [--quote Q] [--cite S] [--cite-url U]` · `timeline <project> move <id> --to <index>` · `place <id>… --before <id\|-> [--section N]` · `remove <id>` · `reject <id> <why> [--note T]` · `wrong-speaker <id> [--correction T]` · `duplicate <id>` (`--at <index>` names one of an id's twins) · `post <json\|@file>` · `post-remove <id>` · `teaser <id> <patch-json\|@file>` · `undo` | the **structure** of the cut (the Cut tab's timeline, the On-screen section's teasers and posts) through the writers `POST /api/report/timeline` runs: `ls` prints index, id, type, video, start–end, date and title (`--json` adds the token and the posts); an insert's attribution is a second write through `window`'s writer, its date checked before anything is written; it is written in the manifest's own convention — under the deck `--title` is the deck's title (`onscreen.title`, `--stream-title` the stream's), a cut whose deck titles are dates gets `--date` as one in their format, and the clip takes the section of the clip it goes after (`--section N` names another) and, from the same recording, its deck title and its citation link. `place` is Play's drag on the reel strip: the entries land before that entry (`-`: the end), their clips joining section N (default: the section of the clip they land after), every other clip keeping its own and the markers following, an emptied section refused, each place its own undo point ([knobs.md](knobs.md#the-reel-strip-zoom-and-reorder)). A removal re-anchors what named the clip (a marker to the clip before, a chapter to the next in its section; a pair, a status reference or a deck claim dropped) and prints each `re-anchored:` line; `reject` rejects the clip for `<why>` — `not-matching` or `wrong-speaker` (fact errors: `incorrect`, the note its correction) or `irrelevant`, `repeats`, `weak`, `privacy`, `other` (`rejected`, never a correction) — and removes it, on record in `removed.json` with the reason and the note; `wrong-speaker <id>` is `reject <id> wrong-speaker`; `ls` marks a clip rejected but still in the cut (`[rejected — irrelevant]`) ([report-video.md](report-video.md#verdict--what-the-walk-said)). Every write snapshots the manifest first (`revisions/…-auto-before-<op>`), is refused only for what it breaks in the build's own words (**exit 1**), and on a generated manifest leaves an `edit` note ([report-video.md](report-video.md#structural-edits)) | | `timeline <project> insert (--to-section N \| --group G) <channel>/<video>@<start>-<end> [--id ID] [--lock] [--title T] [--stream-title T] [--date YYYY-MM-DD] [--quote Q] [--cite S] [--cite-url U]` | a clip at the **end of section N**, or **after group G's last clip and one of its clips** (the run stays together): one write, the marker that followed that last clip re-anchored after the new one, so the clip lands in the section and every other clip keeps its own; the attribution as `insert --after`'s. The Candidates panel's Insert is this ([knobs.md](knobs.md#the-candidates-inbox-proposed-clips-picked-by-a-press)) | @@ -83,7 +84,7 @@ Inbox cannot disagree about what is wrong with one. | `posts set <project> <post> thread=on\|off [hide=on\|off] [attach=<clipId>\|auto] [crop=<px>\|off] [--json]` | the Posts table's writer (`updatePosts`, `PUT /api/report/posts`) from a terminal: `<post>` is the manifest's id (`x-<postId>`) or the bare `<postId>`; `thread=on` draws a reply with the post it answers above it (`shot-thread.png` beside its `shot`, taken by `capture-posts` `"thread": true`; its own shot while there is none), `off` removes the key.; `crop=<px>` the post's own crop of its screenshot (`shotMaxHeight`, 120–1080: its top that tall, never panned; `off` removes it) ([knobs.md](knobs.md#add-post-a-post-card-from-play-the-cut)). Refused in the build's words (a post with no `shot`, an `attach` that is not a clip) — **exit 1** | | `posts add <project> <archive-channel>/<postId> [--attach <clipId>] [--flag F] [--author A] [--id ID] [--thread] [--crop <px>] [--dry-run] [--json]` | a **post card** from the corpus's posts archive (`channels/<slug>/posts/*.jsonl`): its words, date, link and handle; id `x-<postId>` (`bsky-`, `post-`); the author an earlier post by the same handle carries in the cut, else the archive's. Its capture (`posts-media/<postId>/`: `shot.png`, `capture.json`, the post's pictures) is copied to the project's `posts-media/<slug>/<postId>/` — or used where it is, when that folder links the channel's captures; never copied through a link anywhere else. Then `upsertPost` (a post with the id is replaced, its `attachTo` kept). **Exit 1** with no screenshot, naming the `pnpm ops capture-posts` to run. `--thread`: the entry gets `thread: true` (a reply drawn with the post it answers; `shot-thread.png` is copied with the rest, and with none yet it prints the `"thread": true` capture to run). `--crop <px>`: the post's own crop (`shotMaxHeight`). A post that quotes another, reposts one or carries media is added with a `WARNING:` line (`--json`: `warnings`) — its screenshot shows them, by the post's own data. Play the cut's **Add post** runs this same write ([knobs.md](knobs.md#add-post-a-post-card-from-play-the-cut)) | | `posts reel <project> --channel <slug> [--channel <slug> …] [--since YYYY-MM-DD] [--until YYYY-MM-DD] [--own] [--with-media] [--replies include\|only\|exclude] [--order chrono\|reverse] [--limit N] [--after <id\|->] [--dry-run] [--json]` | **POST ITEMS** ([report-video.md](report-video.md#post-items-a-post-as-an-entry-of-the-cut)): each archived post an entry of the cut -- its card drawn from the archive row (snapshotted), its attachments copied into `posts-media/` and played in it. The channels are read as one archive, merged in time order, de-duplicated by post id (`--channel ObviousRises-x --channel ObviousRises-x-replies`); `--own` the accounts' own posts (their config's `socialHandle`, no reposts); `--with-media` only posts whose capture holds an attachment; `--replies` keeps, keeps only or drops replies (a reply carries the posts it answers from the archive, else the capture's thread shot, else a "Replying to" line; the quoted post and the parent the archive lacks come from the capture's `context`, as `posts context` fills them). A post the cut already plays (by its id, a repost's original, a repost of it) is skipped, so a **re-run adds only what is new**; the rest goes in in ONE write (one undo point: `timeline <p> undo`), at the end unless `--after` | -| `posts set-item <project> <item> [hold=<s>\|off] [layout=sequence\|grid] [redact=on\|off\|auto] [fit=read[:<linger>]] [media.<i>.start=<s>] [media.<i>.end=<s>] [media.<i>.trim=off] [media.<i>.mute=on\|off] [media.<i>.crop=x,y,w,h\|off] [media.<i>.push=on\|off] [media.<i>.blur=on\|off] [media.<i>.blur.strength=1–10] [media.<i>.blur.label="…"\|off] [media.<i>.blur.boxes=x,y,w,h;…\|off] [quoted.paraphrase="…"\|off] [parent.<i>.paraphrase="…"\|off] [follow=on\|off\|auto] [follow.dim=<0.2-1>] [follow.ease=<s>] [thread.parent[.<i>]=auto\|full\|excerpt\|context\|carry\|hidden] [thread.quoted=…] [thread.carry=auto\|on\|off] [thread.reveal=on\|off] [thread.shrink=<0.3-1>] [thread.dim=<0.15-1>] [thread.seconds=<s>] [thread.pan=<s>] [thread=auto] [thread.group=<name>\|off] [thread.map=auto\|on\|off\|map\|label\|both] [panel=auto\|side\|top\|bottom] [media.add=<file>] [media.<i>=off] [parent.<i>=<json ref>\|@<file>\|off] [parent.<i>.media=<file>[,…]\|off] [link.add=<json ref>] [link.<i>=<json ref>\|off] [link.<i>.media=<file>\|off] [link.<i>.transcript="…"\|off] [--json]` | a **post item's knobs** (the post bench's writer, `updatePostItem`; [knobs.md](knobs.md#a-post-item-a-post-as-an-entry-of-the-cut)): `<item>` is its id or the post's id; refused in the build's words. `quoted.paraphrase` / `parent.<i>.paraphrase`: your retelling of a long context post (≤ 600 characters), drawn in place of its words with a "paraphrased" label (its text kept); `off` or empty clears it. `follow=`: its read-follow ([knobs.md](knobs.md#read-follow-the-block-being-read-lit-the-card-panned-to-it)) -- `off`, `on`, `auto` (the cut's); `follow.dim=` / `follow.ease=` over the cut's. `thread.*`: its THREAD READ ([knobs.md](knobs.md#thread-reads-every-part-of-a-read-on-screen-while-it-is-said)) -- what each context post is on screen (`thread.parent.<i>` one parent, nearest first), the shrink, dim and their seconds, the pan's; `thread=auto` the cut's; a setting that would narrate a post the card hides is refused (**exit 1**). `media.<i>.blur…` CENSORS the attachment in the render (a real blur of the whole frame or of its boxes, labelled "Censored"; the file untouched; merged key by key, `blur=off` keeps the settings). THREAD SCENES ([knobs.md](knobs.md#thread-scenes-the-join-whole-threads-manual-threads-wide-attachments-context-media-link-visits-the-branch-map)): `parent.<i>=` an ancestor added / replaced / dropped (a whole-thread read), `parent.<i>.media=` its attachments, `media.add=` / `media.<i>=off` an attachment from a project file (measured), `link.add=` a post its words link to (a link visit) with its picture and transcript, `thread.group=` a manual thread, `thread.map=` the branch map, `panel=` where its attachments sit | +| `posts set-item <project> <item> [hold=<s>\|off] [layout=sequence\|grid] [redact=on\|off\|auto] [fit=read[:<linger>]] [media.<i>.start=<s>] [media.<i>.end=<s>] [media.<i>.trim=off] [media.<i>.mute=on\|off] [media.<i>.crop=x,y,w,h\|off] [media.<i>.push=on\|off] [media.<i>.enter=post\|item] [media.<i>.blur=on\|off] [media.<i>.blur.strength=1–10] [media.<i>.blur.label="…"\|off] [media.<i>.blur.boxes=x,y,w,h;…\|off] [quoted.paraphrase="…"\|off] [parent.<i>.paraphrase="…"\|off] [follow=on\|off\|auto] [follow.dim=<0.2-1>] [follow.ease=<s>] [thread.parent[.<i>]=auto\|full\|excerpt\|context\|carry\|hidden] [thread.quoted=…] [thread.carry=auto\|on\|off] [thread.reveal=on\|off] [thread.shrink=<0.3-1>] [thread.dim=<0.15-1>] [thread.seconds=<s>] [thread.pan=<s>] [thread=auto] [thread.group=<name>\|off] [thread.map=auto\|on\|off\|map\|label\|both] [panel=auto\|side\|top\|bottom] [media.add=<file>] [media.<i>=off] [parent.<i>=<json ref>\|@<file>\|off] [parent.<i>.media=<file>[,…]\|off] [link.add=<json ref>] [link.<i>=<json ref>\|off] [link.<i>.media=<file>\|off] [link.<i>.transcript="…"\|off] [--json]` | a **post item's knobs** (the post bench's writer, `updatePostItem`; [knobs.md](knobs.md#a-post-item-a-post-as-an-entry-of-the-cut)): `<item>` is its id or the post's id; refused in the build's words. `quoted.paraphrase` / `parent.<i>.paraphrase`: your retelling of a long context post (≤ 600 characters), drawn in place of its words with a "paraphrased" label (its text kept); `off` or empty clears it. `follow=`: its read-follow ([knobs.md](knobs.md#read-follow-the-block-being-read-lit-the-card-panned-to-it)) -- `off`, `on`, `auto` (the cut's); `follow.dim=` / `follow.ease=` over the cut's. `thread.*`: its THREAD READ ([knobs.md](knobs.md#thread-reads-every-part-of-a-read-on-screen-while-it-is-said)) -- what each context post is on screen (`thread.parent.<i>` one parent, nearest first), the shrink, dim and their seconds, the pan's; `thread=auto` the cut's; a setting that would narrate a post the card hides is refused (**exit 1**). `media.<i>.blur…` CENSORS the attachment in the render (a real blur of the whole frame or of its boxes, labelled "Censored"; the file untouched; merged key by key, `blur=off` keeps the settings). THREAD SCENES ([knobs.md](knobs.md#thread-scenes-the-join-whole-threads-manual-threads-wide-attachments-context-media-link-visits-the-branch-map)): `parent.<i>=` an ancestor added / replaced / dropped (a whole-thread read), `parent.<i>.media=` its attachments, `media.add=` / `media.<i>=off` an attachment from a project file (measured), `link.add=` a post its words link to (a link visit) with its picture and transcript, `thread.group=` a manual thread, `thread.map=` the branch map, `panel=` where its attachments sit; `media.<i>.enter=` when its own attachment comes in -- with his own post's read (`post`, the default: a parent or a quote read first shows none of it) or with the item (`item`) | | `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) | | `posts reread <project> <item> --tempo-for "4-16=1.35,21-25=1.3" \| --tempo <x> --parts <runs> [--stretch atempo\|rubberband] [--dry-run] [--json]` | a narrated read's **parts re-timed**, 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#a-long-read-sped-up-and-its-caps-yelled)): the parts named time-stretched (1–1.6, pitch kept), the rest untouched, joined with the read's pauses (each stretched part padded and trimmed to its length, sample-exact), its words scaled with their part, a derived take (`steps: [{op: "tempo", tempo, params: {stretch}}]`) picked in ONE write. A tempo is absolute: on a re-timed take it re-cuts from the take before. `posts set-item <p> <item> narration.tempo="4-16=1.35"` runs the same. A part outside the take, a tempo outside 1–1.6, nothing changed: **exit 1** | | `posts reread <project> <item> --yell-caps [--yell-gain 5.5] [--yell-style raise\|shout\|loud] [--dry-run] [--json]` · `posts yell <project> --all \| <item …> [--yell-gain …] [--yell-style …] [--dry-run] [--json]` | a narrated read's **caps yelled**, no TTS ([report-video.md](report-video.md#a-long-read-sped-up-and-its-caps-yelled), `lib/report/postYell.mjs`): his ALL-CAPS words found in the take's word timings and raised (the lift measured, its loudness within 1 LU), acronyms and masked slurs left flat, a derived take (`steps: [{op: "yell", spans, params}]`) picked (one undo point per item). No word timings: **exit 1** naming `posts narrate --words`; `posts yell --dry-run` lists every item's caps, the flat ones and why, and which need word timings | diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md @@ -1194,16 +1194,53 @@ Kirsche 17:45, his reply 19:03). A tile that does not answer the one drawn just **The join** (`report-to-video/post-join.mjs`; "I'd like a thread-like smooth transition here rather than a cut"). An item of a conversation run (or a manual thread) opens on the item before AS IT ENDED and morphs into its own -layout over its first `seconds` (0.6; the same content at the same width -- a carried post drawn alike -- switches -at the first frame, never a double image) -- a card beside an attachment to a card alone, another attachment, another +layout over its first `seconds` (0.6) -- a card beside an attachment to a card alone, another attachment, another width: the card's container eases from that item's box to its own (the words scaled with it, never re-flowed), that -item's card -- shot at its last frame in the build, its page in a second frame in Play -- rides the container and -fades as this one's comes in, the post it ended on (carried in, or the scene's) is drawn as that item drew its post -(its head, its words at their size) and framed where it sat (the anchor measured on both pages), the slot's well -fades in or out, and the attachment it ended on (its last frame) cross-fades into this one's -- the same one (a media -scene) is held. The read starts AFTER the join (`narrationSchedule`'s `pre`): an item in a run is the join longer. -`render.posts.join = { on, seconds }`; an item's `join: false` cuts. The build shoots the whole box while it joins -(the card and the slot's well move); `readInViewErrors` checks every read from its settle, after the join. +item's card -- shot at its last frame in the build, its page in a second frame in Play -- rides the container ON TOP +and dissolves into this one's, which is whole under it before it starts to go (`joinOpacities`: what both draw never +dims; the same content at the same width -- a carried post drawn alike -- is this card's from the first frame), the +post it ended on (carried in, or the scene's) is drawn as that item drew its post (its head -- a plain card's head at +the card's size, a threaded card's at its words box's, never this card's -- its words at their size and gap) and framed where it sat (the anchor measured on +both pages), the slot's well fades in or out, and the attachment it ended on (its last frame) cross-fades into this +one's -- the same one (a media scene) is held. The read starts AFTER the join (`narrationSchedule`'s `pre`): an item +in a run is the join longer. `render.posts.join = { on, seconds }`; an item's `join: false` cuts. The build shoots the +whole box while it joins (the card and the slot's well move); `readInViewErrors` checks every read from its settle, +after the join. + +**The join opens EXACTLY on the item before's last frame** (operator, 4 Nov, on mid-7 at 2357 s: "the transition from +some posts hard cutting into the same post with children should be addressed. If one post is visible in the next +scene, there should be a transition"). Its shot is that item's page in its read-follow's LAST state, with what its +segment lays over the card: its parent's shot, a link visit's pointer, and its CLOCK, placed as its own segment placed +it. The clock (`joinClockOf`): within 24 px (at 1080) of where this item's sits, this one opens there and moves the +little way with the card; further apart a move would cross the card's words, so the item before's is laid in its shot +(dissolving with it) and this one comes in over the join; none before, this one comes in; none now, that one dissolves. +Before this, a carried post switched to this card at the second frame and everything only the item before drew -- its +counts, its quote, its clock -- vanished at once, and the carried head (the words' size, not a card's) moved the words +down 12-18 px. A joined segment's key carries `jv` (the join's drawing, `POST_JOIN_DRAW_V`) and the clock the item +before ran, so a changed join rebuilds; an item with no join keeps its key. + +**His own attachment comes in with his own post** (`ownMediaEnterAt`, post-item.mjs; operator, 4 Nov, mid-11 at +~15:58: "I think the mr. obvious gif should come in when his post does rather than during the strawb megathread +reading"). In a threaded read that reads a parent, a quote or a linked post BEFORE his words, the item's own +attachments enter at his post's first part: until then the slot shows the piece being read's context media +(`panelSchedule`) or nothing; there his attachment crossfades in (`POST_ENTER_FADE`, 0.3 s) -- a video STARTS there +(its offset and its sound counted from that moment), its trim fitted to what is left of the read, pictures sharing +what is left. An item that reads only its post, and one past the first of a media scene (the item before ended on the +same attachment: held through), is as before. `posts set-item … media.<i>.enter=item` (the first attachment's) puts it +back with the item. Only an item that enters later carries `enter` in its segment key; Play and the bench lay it the +same (`plan.enter`). + +**Checking it** (`umtool check-joins <project> --take <id> [--json] [--all] [--limit <n>]`, +`report-to-video/check-joins.mjs`, read-only): every boundary of a rendered take's master where the next post item +draws a post the one before showed (its post, a parent, the quote, a linked post, a scene tile), its relation +(self-reply, reply to it, quotes it, manual thread, same thread…), its planned join, and over the post box (the deck +strip left out) its EDGE -- the largest frame-to-frame change (mean absolute difference, 0-255, grey) into the item +before's last frame and this one's first two, over what was already moving in the item before's six frames before +them (a video playing): a join's ease starts flat, so anything there is a cut -- with the SSIM +across the boundary and the largest step of the join after it shown beside; worst first. `JUMPS` is a planned join +whose edge is over 2.5 (`JOIN_CHECK`): mid-7's 2357 s boundary is 10.4 on main, 0.1 with the dissolve. The boundary is +found where the concat put it: the segments' file lengths as the concat demuxer reads them (a file's longest stream: +an audio a few ms longer than its video moves every later segment -- 0.33 s by the end of mid-7), not the schedule's. **A manual thread** (`thread.group`; "basically do all of them chronologically as if a thread, maybe subtly indicate the original relations"). Consecutive items with the same `thread.group` are one run even when X does not link them diff --git a/umtool/lib/report/checkJoinsCli.mjs b/umtool/lib/report/checkJoinsCli.mjs @@ -0,0 +1,62 @@ +// `umtool check-joins <project> --take <id> [--json] [--all] [--limit <n>]` -- the measured check of a rendered +// take's joins (report-to-video/check-joins.mjs): every boundary where the next post item draws a post the one before +// showed, its planned join, and how alike the master's frames are across it. Read-only. + +import { existsSync } from "node:fs"; +import path from "node:path"; + +import { checkJoins, joinsTable } from "umtool-report-to-video/check-joins"; +import { REPORTS_ROOT, resolveProject } from "../projects/core.mjs"; +import { takesDirOf } from "./takes.mjs"; + +class CliError extends Error {} + +export const CHECK_JOINS_USAGE = [ + "usage: umtool check-joins <project> --take <id> [--json] [--all] [--limit <n>]", + " Every boundary of the take's master where the next post item draws a post the one before showed (its post, a", + " parent, the quote, a scene tile, a manual thread's stack): its planned join, the SSIM of the last frame before", + " against the first after (over the post box), and the largest frame-to-frame change across it and its join.", + " Worst first. --all: every post-to-post boundary. Read-only (ffmpeg reads the master).", +].join("\n"); + +export async function checkJoinsCommand(args, { reportsRoot = REPORTS_ROOT, log = console.log, err = console.error } = {}) { + try { + const words = []; + const flags = {}; + for (let i = 0; i < args.length; i += 1) { + const a = args[i]; + if (["--take", "--limit"].includes(a)) { + if (i + 1 >= args.length) throw new CliError(`${a} needs a value`); + flags[a] = args[++i]; + } else if (["--json", "--all", "--help"].includes(a)) flags[a] = true; + else if (a.startsWith("--")) throw new CliError(`unknown flag ${a}`); + else words.push(a); + } + if (flags["--help"] || !words.length || !flags["--take"]) { + log(CHECK_JOINS_USAGE); + return flags["--help"] ? 0 : 2; + } + const r = await resolveProject(words[0], reportsRoot); + if (r.ambiguous) throw new CliError(`"${words[0]}" is the name of ${r.ambiguous.length} projects — pass its id`); + if (!r.project) throw new CliError(`no project matches "${words[0]}"`); + const takeDir = path.join(takesDirOf(r.project.dir), String(flags["--take"])); + if (!existsSync(path.join(takeDir, "out", "sourced", "schedule.json"))) throw new CliError(`${flags["--take"]}: no rendered take at ${takeDir} (out/sourced/schedule.json)`); + const limit = flags["--limit"] ? Number(flags["--limit"]) : Infinity; + if (!(limit > 0)) throw new CliError("--limit takes a positive number"); + const got = await checkJoins(takeDir, { all: !!flags["--all"], onRow: flags["--json"] ? () => {} : (row) => err(` ${row.t.toFixed(2)} ${row.from} → ${row.to}: ssim ${row.ssim?.toFixed(3) ?? "-"}, jump ${row.jump}`) }); + const rows = got.rows.slice(0, limit); + if (flags["--json"]) { + log(JSON.stringify({ take: flags["--take"], master: got.master, drift: got.offsets, rows }, null, 2)); + return 0; + } + log(`${flags["--take"]}: ${got.rows.length} boundar${got.rows.length === 1 ? "y" : "ies"} where the next post item draws a post the one before showed${flags["--all"] ? " (--all: every post-to-post boundary)" : ""}, worst first`); + if (got.offsets) log(` (the master's segments sit ${got.offsets.toFixed(3)} s after the schedule's by the end: the concat demuxer's file lengths)`); + log(joinsTable(rows)); + const bad = got.rows.filter((x) => x.verdict === "JUMPS" || x.verdict === "cut"); + log(`${bad.length} jump or cut where a post stays on screen`); + return 0; + } catch (e) { + err(e instanceof CliError ? `umtool check-joins: ${e.message}` : `umtool check-joins: ${e?.stack ?? e}`); + return 1; + } +} diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs @@ -2358,7 +2358,7 @@ export async function insertEntries(dir, afterId, specs, { token = null, op = "i /** The knobs of a post item a write may set (post-item.mjs; knobs.md, "A post item"). */ export const POST_ITEM_KNOBS = Object.freeze(["hold", "mediaLayout", "panel", "redact", "follow", "thread", "scene", "progress"]); /** A post item attachment's knobs: its trim, its sound, its crop, the push-in, its transcript, its censoring blur. */ -export const POST_MEDIA_KNOBS = Object.freeze(["start", "end", "mute", "crop", "push", "words", "blur"]); +export const POST_MEDIA_KNOBS = Object.freeze(["start", "end", "mute", "crop", "push", "words", "blur", "enter"]); /** A context post's knobs (`quoted`, `parents[i]`): the operator's paraphrase of its words. */ export const POST_CONTEXT_KNOBS = Object.freeze(["paraphrase", "ref", "media", "transcript"]); /** The fields a context post (a parent, a linked post) is given by hand (`parent.<i>=<ref>`, post-item.mjs refErrors). */ diff --git a/umtool/lib/report/postsCli.mjs b/umtool/lib/report/postsCli.mjs @@ -91,7 +91,7 @@ export const POSTS_USAGE = [ " [thread.carry=auto|on|off] [thread.reveal=on|off] [thread.shrink=<0.3-1>] [thread.dim=<0.15-1>]", " [thread.seconds=<0-3>] [thread.pan=<0.1-3>] [thread=auto]", " [media.<i>.start=<s>] [media.<i>.end=<s>] [media.<i>.mute=on|off] [media.<i>.crop=x,y,w,h|off]", - " [media.<i>.push=on|off] [media.<i>.trim=off] [quoted.paraphrase=\"…\"|off]", + " [media.<i>.push=on|off] [media.<i>.trim=off] [media.<i>.enter=post|item] [quoted.paraphrase=\"…\"|off]", " [media.<i>.blur=on|off] [media.<i>.blur.strength=1–10] [media.<i>.blur.label=\"…\"|off]", " [media.<i>.blur.boxes=x,y,w,h;…|off] [media.<i>.blur.band=below:<f>|above:<f>|between:<a>,<b>[:left:<f>|:right:<f>]|off]", " [media.<i>.blur.style=blur|black|pixelate|off] [media.<i>.censor=<edge>:<f>[:<style>][:<strength>]|off]", @@ -841,13 +841,17 @@ export function postItemPatchOf(pairs) { Object.assign(blur, { on: true, ...c }); } } else { - const m = /^media\.(\d+)\.(start|end|mute|crop|push|trim)$/.exec(k); - if (!m) throw new CliError(`${pair}: not a post item knob (hold=, layout=, panel=, redact=, scene=, follow=, follow.dim|ease=, thread=, thread.parent|quoted|carry|reveal|shrink|dim|seconds|pan|group|map=, media.add=, media.<i>=off, media.<i>.start|end|mute|crop|push|trim=, media.<i>.blur[.strength|.label|.boxes|.band|.style]=, media.<i>.censor=, quoted.paraphrase=, parent.<i>=<ref>|off, parent.<i>.media=, parent.<i>.paraphrase=, link.add=, link.<i>=<ref>|off, link.<i>.media=, link.<i>.transcript=)`); + const m = /^media\.(\d+)\.(start|end|mute|crop|push|trim|enter)$/.exec(k); + if (!m) throw new CliError(`${pair}: not a post item knob (hold=, layout=, panel=, redact=, scene=, follow=, follow.dim|ease=, thread=, thread.parent|quoted|carry|reveal|shrink|dim|seconds|pan|group|map=, media.add=, media.<i>=off, media.<i>.start|end|mute|crop|push|trim|enter=, media.<i>.blur[.strength|.label|.boxes|.band|.style]=, media.<i>.censor=, quoted.paraphrase=, parent.<i>=<ref>|off, parent.<i>.media=, parent.<i>.paraphrase=, link.add=, link.<i>=<ref>|off, link.<i>.media=, link.<i>.transcript=)`); const media = (out.media ??= {}); const one = (media[m[1]] ??= {}); if (m[2] === "start" || m[2] === "end") one[m[2]] = OFF.has(v) || v === "" ? null : Number(raw); else if (m[2] === "mute" || m[2] === "push") one[m[2]] = onOff(v, k) || null; - else if (m[2] === "trim") { + else if (m[2] === "enter") { + // When it comes in (post-item.mjs ownMediaEnterAt): with his own post (the default) or with the item. + if (!["post", "item", ...OFF].includes(v)) throw new CliError(`${k}= takes post (with his own post's read, the default), item (with the item) or off`); + one.enter = v === "item" ? "item" : v === "post" ? "post" : null; + } else if (m[2] === "trim") { if (!OFF.has(v)) throw new CliError(`${k}= takes off (the whole attachment)`); one.start = null; one.end = null; diff --git a/umtool/report-to-video/build-video.mjs b/umtool/report-to-video/build-video.mjs @@ -219,13 +219,17 @@ import { buildPostSegment } from "./post-render.mjs"; import { TRAILER_AUDIO, trailerHitsGraph } from "./trailer-hits.mjs"; import { planContext, planContextOf } from "./post-conversation.mjs"; -/** The item before post item `id` with its own context (post-join.mjs: what the item opens on), or null. */ -function postJoinFrom(timeline, id, render, groups) { +/** + * The item before post item `id` with its own context (post-join.mjs: what the item opens on), or null -- and, when + * that one joins the item before IT, that item too (`before`: how its segment drew the post it carried in). + */ +function postJoinFrom(timeline, id, render, groups, depth = 0) { const tl = Array.isArray(timeline) ? timeline : []; const i = tl.findIndex((e) => e?.id === id); const prev = i > 0 ? tl[i - 1] : null; if (prev?.type !== "post") return null; - return { entry: prev, ...planContext(tl, i - 1, render), mediaScene: mediaSceneById(tl, prev.id, groups, render) }; + const ctx = planContext(tl, i - 1, render); + return { entry: prev, ...ctx, mediaScene: mediaSceneById(tl, prev.id, groups, render), ...(depth === 0 && ctx.join ? { before: postJoinFrom(tl, prev.id, render, groups, 1) } : {}) }; } import { readPostRedaction } from "./post-redact-files.mjs"; import { dropMarks, redactEntry } from "./post-redact.mjs"; diff --git a/umtool/report-to-video/check-joins.mjs b/umtool/report-to-video/check-joins.mjs @@ -0,0 +1,291 @@ +// CHECK JOINS (umtool/docs/report-video.md, "The join"; operator, 4 Nov, on mid-7: "the transition from some posts +// hard cutting into the same post with children should be addressed. If one post is visible in the next scene, +// there should be a transition"). A MEASURED check of a rendered take: for every boundary between two post items +// where the next one draws a post the one before showed (its post, a parent, the quote, a scene tile, a manual +// thread's stack), the master's last frame of the item before and the first frames of the next are read back +// (ffmpeg, read-only) and scored over the two items' CARDS as laid out (cardRegion) -- the deck strip, the chrome and +// the attachments' slots left out: +// +// edge THE VERDICT: the largest frame-to-frame change (the mean absolute difference, 0-255, of the box in +// grey) into the frames around the boundary (the item before's last, this one's first and second) -- a +// join's first frames barely move (its ease starts flat: 0.07 % of the way at its second frame), so +// anything seen there over what was already moving (the item before's last frames: a video playing) is +// a cut +// ssim the item before's last frame against the next item's second (1: the same picture; dark flat cards make +// it touchy -- a clock coming in faintly costs 0.07 -- so it is shown, not judged) +// jump how far the largest frame-to-frame change across the boundary and the join after it (the mean +// absolute difference, 0-255, of the box in grey) stands above its neighbours: a cut is one big step +// alone, a morph or a dissolve many small ones alike +// +// The boundary's place in the master is where the concat put it: each segment starts at the sum of the files +// before it AS THE CONCAT DEMUXER READS THEM (a file's length is its longest stream's: an audio stream a few ms +// longer than the video moves every later segment, measured 0.33 s by the end of mid-7), else the schedule's. +// +// umtool check-joins <project> --take <id> [--json] [--all] [--limit <n>] +// +// Pure helpers first (tested), then the ffmpeg reads. + +import { execFile } from "node:child_process"; +import { readFile } from "node:fs/promises"; +import path from "node:path"; +import { promisify } from "node:util"; + +import { chainOf, planContext } from "./post-conversation.mjs"; +import { linksOf, panelEntry, parentsOf, postLayout } from "./post-item.mjs"; +import { groupOf, shownIdOf } from "./post-thread.mjs"; + +const execFileP = promisify(execFile); +const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v); +const str = (v) => (typeof v === "string" ? v : ""); +const fin = (v) => typeof v === "number" && Number.isFinite(v); +const r3 = (v) => Math.round(v * 1000) / 1000; + +/** A cut whose boundary scores below this SSIM, or jumps above this, is called a CUT (a join's frames move little). */ +export const JOIN_CHECK = Object.freeze({ edge: 2.5 }); + +/** + * The posts item `e` draws (its own, the posts it answers, its quote, the posts it links, the scene its run left on + * screen): `Map<id, what>` -- `what` "post", "parent", "quoted", "linked", "scene". + * @param {Record<string, any>} e + * @param {{ scene?: { tiles?: Array<Record<string, any>> } | null }} [ctx] + */ +export function postsDrawnBy(e, { scene = null } = {}) { + const out = new Map(); + const add = (id, what) => { + if (str(id) && !out.has(str(id))) out.set(str(id), what); + }; + add(shownIdOf(e), "post"); + for (const p of parentsOf(e)) add(p?.id, "parent"); + if (isObj(e?.quoted)) add(e.quoted.id, "quoted"); + for (const l of linksOf(e)) add(l?.id, "linked"); + for (const t of Array.isArray(scene?.tiles) ? scene.tiles : []) add(t?.id, "scene"); + return out; +} + +/** How item `b` relates to `a`, the item before it (the check's words). */ +export function joinRelation(a, b) { + const ida = shownIdOf(a); + const pb = parentsOf(b); + if (groupOf(a) && groupOf(a) === groupOf(b)) return "manual thread"; + if (ida && str(pb[0]?.id) === ida) return str(a?.handle) && str(a?.handle).toLowerCase() === str(b?.handle).toLowerCase() ? "self-reply" : "reply to it"; + if (ida && isObj(b?.quoted) && str(b.quoted.id) === ida) return "quotes it"; + if (ida && pb.some((p) => str(p?.id) === ida)) return "a later reply"; + if (ida && ida === shownIdOf(b)) return "the same post"; + const ca = new Set(chainOf(a).filter(Boolean)); + if (chainOf(b).some((id) => id && ca.has(id))) return "same thread"; + return "shares a post"; +} + +/** + * THE BOUNDARIES, pure: each post-to-post boundary of the schedule (`schedule.segments`, by id into the timeline) + * with what the two items share -- `{ i, from, to, at, shared: [id], relation, join, seconds }` (`join` the + * planned join's seconds, or null: a cut). `all`: every post-to-post boundary, sharing or not. + */ +export function joinBoundaries(timeline, schedule, render = undefined, { all = false } = {}) { + const tl = Array.isArray(timeline) ? timeline : []; + const byId = new Map(tl.map((e, k) => [str(e?.id), k])); + const segs = Array.isArray(schedule?.segments) ? schedule.segments : []; + const out = []; + for (let i = 1; i < segs.length; i += 1) { + const sa = segs[i - 1]; + const sb = segs[i]; + if (sa?.type !== "post" || sb?.type !== "post") continue; + const ka = byId.get(str(sa.id)); + const kb = byId.get(str(sb.id)); + if (ka === undefined || kb === undefined) continue; + const a = tl[ka]; + const b = tl[kb]; + const ctxA = planContext(tl, ka, render); + const ctxB = planContext(tl, kb, render); + const drawnA = postsDrawnBy(a, ctxA); + const drawnB = postsDrawnBy(b, ctxB); + const shared = [...drawnB.keys()].filter((id) => drawnA.has(id)); + if (!shared.length && !all) continue; + out.push({ + i, from: str(a.id), to: str(b.id), at: fin(sb.start) ? sb.start : null, + shared, relation: shared.length ? joinRelation(a, b) : "none", + join: ctxB.join && fin(ctxB.join.seconds) && kb === ka + 1 ? ctxB.join.seconds : null, + }); + } + return out; +} + +/** + * Where each segment starts in the master: the sum of the files before it as the concat demuxer reads them + * (`durations[i]`: segment i's file length, its longest stream's), else the schedule's start. + * @param {{ segments: Array<{ start?: number }> }} schedule + * @param {Array<number | null>} [durations] + */ +export function masterStarts(schedule, durations = []) { + const segs = schedule?.segments ?? []; + const usable = durations.length === segs.length && durations.every(fin); + let acc = 0; + return segs.map((s, i) => { + const t = usable ? acc : fin(s.start) ? s.start : acc; + if (usable) acc += durations[i]; + return r3(t); + }); +} + +/** ffmpeg's `metadata=print:file=-` lines → `[{ t, v }]` (the frame's pts time, the key's value). */ +export function parseFrameMeta(text, key) { + const out = []; + let t = null; + for (const line of String(text).split(/\r?\n/)) { + const m = /pts_time:([-\d.]+)/.exec(line); + if (m) t = Number(m[1]); + const v = new RegExp(`${key.replace(/\./g, "\\.")}=([-\\d.e]+)`).exec(line); + if (v && t !== null) out.push({ t, v: Number(v[1]) }); + } + return out; +} + +/** The verdict of one measured boundary: "join" (it moved on smoothly), "cut" (a step), "planned cut". */ +export function joinVerdict(row) { + const bad = fin(row.edge) && row.edge > JOIN_CHECK.edge; + if (!bad) return row.join ? "join" : "smooth"; + return row.join ? "JUMPS" : "cut"; +} + +/** Worst first: the biggest edge, then the lowest SSIM. */ +export function rankJoins(rows) { + const score = (r) => -(fin(r.edge) ? r.edge : 0) + (fin(r.ssim) ? r.ssim : 1) / 1000; + return [...rows].sort((a, b) => score(a) - score(b)); +} + +/** The table a person reads. */ +export function joinsTable(rows) { + const head = ["at (master)", "from → to", "relation", "shared", "join", "edge", "ssim", "jump", "verdict"]; + const lines = rows.map((r) => [ + fin(r.t) ? r.t.toFixed(2) : "?", + `${r.from} → ${r.to}`, + r.relation, + String(r.shared.length), + r.join ? `${r.join}s` : "cut", + fin(r.edge) ? r.edge.toFixed(1) : "-", + fin(r.ssim) ? r.ssim.toFixed(3) : "-", + fin(r.jump) ? r.jump.toFixed(1) : "-", + joinVerdict(r), + ]); + const w = head.map((h, k) => Math.max(h.length, ...lines.map((l) => l[k].length))); + const fmt = (l) => l.map((c, k) => c.padEnd(w[k])).join(" ").trimEnd(); + return [fmt(head), fmt(w.map((n) => "-".repeat(n))), ...lines.map(fmt)].join("\n"); +} + +// --------------------------------------------------------------------------- +// The reads (ffmpeg / ffprobe, read-only). +// --------------------------------------------------------------------------- + +/** + * THE CARDS' REGION in the master, pure: the union of the items' cards as laid out (post-item.mjs postLayout, the + * cut's panel rule on) in the post box `box` (the deck's, where the segment lays its box), even-sized for ffmpeg. + */ +export function cardRegion(entries, box, render = undefined) { + const cards = entries.filter(Boolean).map((e) => postLayout(panelEntry(e, render), { width: box.width, height: box.height }).card).filter((c) => c && [c.x, c.y, c.width, c.height].every(fin)); + if (!cards.length) return box; + const x0 = Math.max(0, Math.floor(Math.min(...cards.map((c) => c.x)))); + const y0 = Math.max(0, Math.floor(Math.min(...cards.map((c) => c.y)))); + const x1 = Math.min(box.width, Math.ceil(Math.max(...cards.map((c) => c.x + c.width)))); + const y1 = Math.min(box.height, Math.ceil(Math.max(...cards.map((c) => c.y + c.height)))); + const w = x1 - x0 - ((x1 - x0) % 2); + const h = y1 - y0 - ((y1 - y0) % 2); + return w > 8 && h > 8 ? { x: box.x + x0, y: box.y + y0, width: w, height: h } : box; +} + +/** A file's length as the concat demuxer reads it (its format duration), or null. */ +async function fileSeconds(file, ffprobe) { + try { + const { stdout } = await execFileP(ffprobe, ["-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0", file]); + const v = Number(String(stdout).trim()); + return fin(v) ? v : null; + } catch { + return null; + } +} + +/** The files concat.txt lists, in order. */ +export function concatFiles(text) { + return String(text).split(/\r?\n/).map((l) => /^file\s+'(.*)'\s*$/.exec(l.trim())).filter(Boolean).map((m) => m[1].replace(/'\\''/g, "'")); +} + +/** + * Measure boundary `row` in `master` at `t` (where segment `to` starts): the SSIM of the frame 1.5 frames before + * against the one 1.5 frames after, and the largest frame-to-frame change from 3 frames before to the join's end + * (+0.4 s), over `box` scaled to half, in grey. + */ +export async function measureBoundary(master, t, { box, fps = 30, join = null, ffmpeg = "ffmpeg" }) { + const crop = `crop=${box.width}:${box.height}:${box.x}:${box.y},scale=${Math.round(box.width / 2)}:-2,format=gray`; + const ta = Math.max(0, t - 1.5 / fps); + const tb = t + 1.5 / fps; + const ss = await execFileP(ffmpeg, ["-nostdin", "-v", "info", "-ss", ta.toFixed(4), "-i", master, "-ss", tb.toFixed(4), "-i", master, "-frames:v", "1", "-lavfi", `[0:v]${crop}[a];[1:v]${crop}[b];[a][b]ssim`, "-f", "null", "-"], { maxBuffer: 1 << 24 }); + const m = /All:([\d.]+)/.exec(String(ss.stderr)); + const from = Math.max(0, t - 3 / fps); + const span = (fin(join) ? join : 0) + 0.4 + 3 / fps; + const d = await execFileP(ffmpeg, ["-nostdin", "-v", "error", "-ss", from.toFixed(4), "-i", master, "-t", span.toFixed(4), "-vf", `${crop},tblend=all_mode=difference,signalstats,metadata=print:key=lavfi.signalstats.YAVG:file=-`, "-f", "null", "-"], { maxBuffer: 1 << 24 }); + const diffs = parseFrameMeta(String(d.stdout) + String(d.stderr), "lavfi.signalstats.YAVG"); + const j = jumpOf(diffs); + return { edge: r3(edgeOf(diffs.map((x) => ({ t: from + x.t, v: x.v })), t, fps)), ssim: m ? Number(m[1]) : null, jump: r3(j.jump), jumpAt: r3(from + j.t), peak: r3(j.peak) }; +} + +/** + * THE EDGE, pure: the largest change into the frames around the boundary -- the item before's last, this one's first + * and second -- over the largest among the item before's six frames before them (what was already moving: a video + * playing, a pan) (`diffs` on + * the master's clock, each the change INTO its frame; `t` where this item starts). + */ +export function edgeOf(diffs, t, fps = 30) { + const max = (a, b) => diffs.filter((x) => x.t > a && x.t <= b).reduce((m, x) => Math.max(m, x.v), 0); + // Over what was already moving: a video playing in the slot, a pan -- the item before's last frames' own change. + return Math.max(0, max(t - 1.5 / fps, t + 1.5 / fps) - max(t - 7.5 / fps, t - 1.5 / fps)); +} + +/** + * THE JUMP in a run of frame-to-frame changes (`[{ t, v }]`), pure: how far one step stands above the larger of its + * neighbours -- a cut is one step (big, its neighbours still), a morph or a dissolve many alike (small) -- `{ jump, + * t, peak }` (`peak` the largest step itself). + */ +export function jumpOf(diffs) { + let out = { jump: 0, t: 0, peak: 0 }; + diffs.forEach((x, i) => { + const near = Math.max(diffs[i - 1]?.v ?? 0, diffs[i + 1]?.v ?? 0); + const j = Math.max(0, x.v - near); + if (j > out.jump) out = { ...out, jump: j, t: x.t }; + if (x.v > out.peak) out.peak = x.v; + }); + return out; +} + +/** + * CHECK A TAKE: `{ rows, master, offsets }` -- each boundary (joinBoundaries) measured in the take's master. + * `takeDir` the take's folder (its video.manifest.json, out/<slug>.mp4, out/sourced/{schedule.json,concat.txt}). + */ +export async function checkJoins(takeDir, { all = false, ffmpeg = "ffmpeg", ffprobe = "ffprobe", onRow = () => {} } = {}) { + const manifest = JSON.parse(await readFile(path.join(takeDir, "video.manifest.json"), "utf8")); + const out = path.join(takeDir, "out"); + const sourced = path.join(out, "sourced"); + const schedule = JSON.parse(await readFile(path.join(sourced, "schedule.json"), "utf8")); + const master = path.join(out, `${str(manifest.slug)}.mp4`); + const fps = fin(schedule.fps) ? schedule.fps : manifest.render?.fps ?? 30; + const files = concatFiles(await readFile(path.join(sourced, "concat.txt"), "utf8").catch(() => "")); + const durations = files.length === schedule.segments.length ? await Promise.all(files.map((f) => fileSeconds(f, ffprobe))) : []; + const starts = masterStarts(schedule, durations); + const rows = joinBoundaries(manifest.timeline, schedule, manifest.render, { all }); + const measured = []; + for (const r of rows) { + const seg = schedule.segments[r.i]; + const cut = JSON.parse(await readFile(path.join(sourced, "segments", `${seg.id}.cut.json`), "utf8").catch(() => "null")); + const fb = cut?.framing?.box; + const box = isObj(fb) && [fb.x, fb.y, fb.width, fb.height].every(fin) ? { x: Math.round(fb.x), y: Math.round(fb.y), width: Math.round(fb.width) - (Math.round(fb.width) % 2), height: Math.round(fb.height) - (Math.round(fb.height) % 2) } : { x: 0, y: 0, width: 1920, height: 880 }; + const t = starts[r.i]; + // Over the CARDS (the item before's and this one's, as laid out), never their attachments' slots: a video playing + // through the boundary, or one cross-fading into another, is not the join's step. + const byId = new Map(manifest.timeline.map((e) => [e?.id, e])); + const region = cardRegion([byId.get(r.from), byId.get(r.to)], box, manifest.render); + const m = await measureBoundary(master, t, { box: region, fps, join: r.join, ffmpeg }); + const row = { ...r, t, box: region, ...m }; + row.verdict = joinVerdict(row); + measured.push(row); + onRow(row); + } + return { rows: rankJoins(measured), master, offsets: durations.length ? r3(starts[starts.length - 1] - (schedule.segments.at(-1)?.start ?? 0)) : 0 }; +} diff --git a/umtool/report-to-video/check-joins.test.mjs b/umtool/report-to-video/check-joins.test.mjs @@ -0,0 +1,51 @@ +// CHECK JOINS (check-joins.mjs): the measured check of a rendered take's joins -- its pure parts. +import assert from "node:assert/strict"; +import { test } from "node:test"; + +import { cardRegion, concatFiles, edgeOf, joinBoundaries, jumpOf, joinRelation, joinVerdict, joinsTable, masterStarts, parseFrameMeta, postsDrawnBy, rankJoins } from "./check-joins.mjs"; + +const at = (h) => `2026-11-04T${String(h).padStart(2, "0")}:00:00.000Z`; +const narrate = (e, parts) => ({ ...e, narration: { takes: [{ file: `narration/${e.id}.wav`, seconds: 6, parts: parts.map((p) => ({ text: p.join(" ") })) }], picked: 0 } }); +const post = (id, text, h, extra = {}) => ({ type: "post", id: `p-${id}`, post: `ObviousRises-x/${id}`, platform: "x", author: "MR. OBVIOUS", handle: "ObviousRises", date: at(h), text, url: `https://x.com/ObviousRises/status/${id}`, ...extra }); +const ref = (id, text, h) => ({ id, author: "MR. OBVIOUS", handle: "ObviousRises", date: at(h), text }); + +test("CHECK JOINS: the boundaries where the next item draws a post the one before showed, their relation and planned join; the master's starts from the files as the concat reads them; worst first", () => { + const a = narrate(post("10", "mercy", 7), [["mercy"]]); + const b = narrate(post("11", "notice", 8, { parents: [ref("10", "mercy", 7)] }), [["notice"]]); + const c = narrate(post("99", "unrelated", 9), [["unrelated"]]); + const tl = [a, b, c]; + assert.deepEqual([...postsDrawnBy(b).entries()], [["11", "post"], ["10", "parent"]]); + assert.equal(joinRelation(a, b), "self-reply"); + assert.equal(joinRelation(a, { ...b, handle: "Other" }), "reply to it"); + assert.equal(joinRelation(a, { ...c, quoted: { id: "10", text: "mercy" } }), "quotes it"); + const schedule = { fps: 30, segments: [{ id: "p-10", type: "post", start: 0, duration: 15.9 }, { id: "p-11", type: "post", start: 15.9, duration: 10 }, { id: "p-99", type: "post", start: 25.9, duration: 5 }] }; + const rows = joinBoundaries(tl, schedule); + assert.deepEqual(rows.map((r) => [r.from, r.to, r.shared, r.relation, r.join]), [["p-10", "p-11", ["10"], "self-reply", 0.6]]); + assert.equal(joinBoundaries(tl, schedule, undefined, { all: true }).length, 2); + // The audio a few ms longer than the video: every later segment later than the schedule says. + assert.deepEqual(masterStarts(schedule, [15.905, 10.003, 5]), [0, 15.905, 25.908]); + assert.deepEqual(masterStarts(schedule, []), [0, 15.9, 25.9]); + assert.deepEqual(concatFiles("ffconcat version 1.0\nfile '/a/b.mp4'\nfile '/a/it'\\''s.mp4'\n"), ["/a/b.mp4", "/a/it's.mp4"]); + assert.deepEqual(parseFrameMeta("frame:0 pts:512 pts_time:0.0333\nlavfi.signalstats.YAVG=0.5\nframe:1 pts:1024 pts_time:0.0667\nlavfi.signalstats.YAVG=9.25\n", "lavfi.signalstats.YAVG"), [{ t: 0.0333, v: 0.5 }, { t: 0.0667, v: 9.25 }]); + // A cut: one step alone; a dissolve: many alike. + assert.equal(jumpOf([{ t: 0, v: 0 }, { t: 1, v: 9 }, { t: 2, v: 0.2 }]).jump, 8.8); + assert.ok(jumpOf([{ t: 0, v: 2 }, { t: 1, v: 2.5 }, { t: 2, v: 2.2 }, { t: 3, v: 1.9 }]).jump < 0.5); + // Over the cards, not the slots: a card beside a video is its own column. + const box = { x: 173, y: 2, width: 1574, height: 886 }; + const withVideo = { ...a, media: [{ src: "v.mp4", kind: "video", width: 1280, height: 720, seconds: 10 }] }; + const reg = cardRegion([withVideo], box); + assert.ok(reg.width < box.width * 0.6 && reg.x >= box.x && reg.width % 2 === 0 && reg.height % 2 === 0); + assert.deepEqual(cardRegion([], box), box); + // THE EDGE: mid-7's 2357 boundary on main (the carried post switching at frame 1) against the lane's dissolve. + const series = (vals, t0 = 692.1) => vals.map((v, k) => ({ t: t0 + k / 30, v })); + assert.equal(edgeOf(series([0, 0, 0.4, 10.4, 3.6, 0, 4.7]), 692.153), 10.4); + assert.equal(edgeOf(series([0, 0, 0.1, 0, 3.9, 0, 5.3]), 692.153), 0.1); + // A video playing across the boundary: its own change is not the join's. + assert.ok(edgeOf(series([4, 3.8, 0, 4.1, 3.9, 4.2, 0, 4.0, 4.1], 692.0), 692.153) < 0.5); + const measured = [{ from: "a", to: "b", shared: ["1"], relation: "self-reply", join: 0.6, t: 1, edge: 10.4, ssim: 0.79, jump: 10.7 }, { from: "c", to: "d", shared: ["2"], relation: "manual thread", join: 0.6, t: 2, edge: 0.1, ssim: 0.998, jump: 1.2 }]; + assert.deepEqual(rankJoins(measured).map((r) => r.from), ["a", "c"]); + assert.equal(joinVerdict(measured[0]), "JUMPS"); + assert.equal(joinVerdict(measured[1]), "join"); + assert.equal(joinVerdict({ ...measured[0], join: null }), "cut"); + assert.match(joinsTable(measured), /a → b\s+self-reply\s+1\s+0\.6s\s+10\.4\s+0\.790\s+10\.7\s+JUMPS/); +}); diff --git a/umtool/report-to-video/package.json b/umtool/report-to-video/package.json @@ -23,6 +23,7 @@ "./brand-ids": "./brand-ids.mjs", "./build-video": "./build-video.mjs", "./check-availability": "./check-availability.mjs", + "./check-joins": "./check-joins.mjs", "./chunked-encode": "./chunked-encode.mjs", "./claims": "./claims.mjs", "./clip-audio": "./clip-audio.mjs", diff --git a/umtool/report-to-video/post-item.mjs b/umtool/report-to-video/post-item.mjs @@ -35,7 +35,7 @@ import { import { BAR_CSS, barsHtml, hasMarks, projectRedactOf, redactEntry, redactSceneRef, redactionOn, validatePostsRender } from "./post-redact.mjs"; import { blurErrors } from "./post-censor.mjs"; import { WORD_ZOOM_HIGHLIGHT_ALPHA, cardTokens, cardWordsOf, findMatch, targetTextOf, validatePostFx } from "./word-zoom.mjs"; -import { FOLLOW_MIN_SIZE, followBlocks, followSchedule, scopeBlocks, validatePostFollow } from "./read-follow.mjs"; +import { FOLLOW_MIN_SIZE, followBlocks, followKnobs, followSchedule, scopeBlocks, validatePostFollow } from "./read-follow.mjs"; import { panelSchedule, validatePostThread } from "./post-thread.mjs"; import { joinLayerHtml, validatePostJoin, validatePostJoinRender } from "./post-join.mjs"; import { validatePostLinkVisit, validatePostLinkVisitRender, visitsEnd } from "./post-link-visit.mjs"; @@ -292,6 +292,10 @@ function planOf(entry, render, hold, prev = null, scene = null, mediaScene = nul return { ...plan, reading: round3(Math.min(voiceOnly, total)), total, ...extra, ...(panel ? { panel } : {}) }; } const span = sch ? round3(sch.at + sch.seconds + k.tail + k.linger) : readingSeconds(entry); + // ITS OWN ATTACHMENTS come in with ITS OWN POST (ownMediaEnterAt): a thread read's parents and quotes first, his + // attachment when his words begin -- a video starts there, its sound too, its trim fitted to what is left. + const enter = ownMediaEnterAt(entry, follow, { mediaScene }); + const avail = round3(Math.max(0, span - enter)); const all = mediaSteps(entry).map((s) => { if (s.kind !== "video" || k.clip === "full") return s; // An out point the operator set is kept: that span is the choice. One `posts fit` set (it is the @@ -299,16 +303,16 @@ function planOf(entry, render, hold, prev = null, scene = null, mediaScene = nul const m = s.items[0]; const w = entry?.narration?.window; const fitEnd = sch && isObj(w) && w.media === m.i && fin(w.end) && Math.abs(w.end - m.end) < 0.011; - return fin(m.end) && !fitEnd ? s : { ...s, seconds: round3(Math.min(s.seconds, span)) }; + return fin(m.end) && !fitEnd ? s : { ...s, seconds: round3(Math.min(s.seconds, avail)) }; }); const videos = all.filter((s) => s.kind === "video").reduce((n, s) => n + s.seconds, 0); const pics = all.filter((s) => s.kind !== "video"); - const share = pics.length ? Math.max(POST_PICTURE_MIN, (span - videos) / pics.length) : 0; + const share = pics.length ? Math.max(POST_PICTURE_MIN, (avail - videos) / pics.length) : 0; const steps = all.map((s) => (s.kind === "video" ? s : { ...s, seconds: round3(share) })); const media = round3(steps.reduce((n, s) => n + s.seconds, 0)); // A LINK VISIT (post-link-visit.mjs) lit after the read runs on its hold: the item holds it. - const total = hold ?? round3(Math.max(span, media, follow?.visits ? visitsEnd(follow.visits) : 0)); - const plan = planSteps(steps, 0, total); + const total = hold ?? round3(Math.max(span, enter + media, follow?.visits ? visitsEnd(follow.visits) : 0)); + const plan = planSteps(steps, enter, total); // A video shorter than the read: looped to the end, or (the default) its last frame held. const last = plan.steps[plan.steps.length - 1]; if (k.short === "loop" && last?.kind === "video" && plan.held > 0.05) { @@ -318,7 +322,35 @@ function planOf(entry, render, hold, prev = null, scene = null, mediaScene = nul } // A CONTEXT POST's attachment (post-thread.mjs panelSchedule): over the slot while it is on screen. const panel = follow ? panelSchedule(entry, follow, total) : null; - return { ...plan, reading: 0, total, ...extra, ...(panel ? { panel } : {}) }; + return { ...plan, reading: 0, total, ...extra, ...(panel ? { panel } : {}), ...(enter > 0 && plan.steps.length ? { enter } : {}) }; +} + +/** Where an item's own attachments may come in (`media[0].enter`): with its own post (the default), or with the item. */ +export const POST_MEDIA_ENTERS = Object.freeze(["post", "item"]); +/** Their crossfade in, seconds, from the moment his own words begin. */ +export const POST_ENTER_FADE = 0.3; + +/** + * WHEN AN ITEM's OWN ATTACHMENTS COME IN, pure (operator, 4 Nov, mid-11 at ~15:58: "the mr. obvious gif should come in + * when his post does rather than during the strawb megathread reading"): the item second its OWN POST's read begins + * (its first block of scope `post`) when a threaded read reads something else before it (a parent, a quote, a linked + * post) -- else 0, as before: an item that reads only its post, one not threaded, one in a media scene after its + * first (the item before ended on the same attachment: held through), or one whose first attachment says + * `enter: "item"`. Until then the slot shows that + * piece's context media (panelSchedule), or nothing. + * @param {Record<string, any>} entry + * @param {{ thread?: any, blocks?: Array<{ scope?: string, start: number | null }> } | null} follow + */ +export function ownMediaEnterAt(entry, follow, { mediaScene = null } = {}) { + const media = Array.isArray(entry?.media) ? entry.media : []; + // In a media scene past its first item the item before ended on this same attachment: held through, as before. + if (!media.length || !follow?.thread || (mediaScene && (mediaScene.n ?? 0) > 0)) return 0; + if (media[0]?.enter === "item") return 0; + const blocks = (follow.blocks ?? []).filter((b) => fin(b.start)); + const post = blocks.filter((b) => b.scope === "post"); + if (!post.length) return 0; + const at = Math.min(...post.map((b) => b.start)); + return blocks.some((b) => b.scope !== "post" && b.start < at - 1e-6) ? round3(at) : 0; } /** Steps placed from `at0`, cut at `total` (postItemPlan's walk). */ @@ -576,6 +608,7 @@ function mediaErrors(m, where) { } if (timed && fin(m.start) && fin(m.end) && m.end - m.start < POST_MEDIA_MIN_SPAN) errors.push(`${where}: end must be at least ${POST_MEDIA_MIN_SPAN} s after start`); for (const k of ["mute", "push", "audio"]) if (m[k] !== undefined && typeof m[k] !== "boolean") errors.push(`${where}.${k} must be true or false`); + if (m.enter !== undefined && !POST_MEDIA_ENTERS.includes(m.enter)) errors.push(`${where}.enter must be ${POST_MEDIA_ENTERS.join(" or ")} (when it comes in: with his own post, or with the item)`); if (m.push !== undefined && m.kind !== "image") errors.push(`${where}.push: only an image is pushed in on`); if (m.crop !== undefined) { const c = m.crop; @@ -973,7 +1006,7 @@ export function nameHtml(who, { redact, cls = "" }) { * highlight?: { scope: string, from: number, to: number, color: string } | null, * redaction?: { terms: Array<{term: string, wholeWord?: boolean}>, markup?: Record<string, any> } | null, follow?: boolean, * thread?: { tiles?: Array<{ scope: string, mode: string }> } | null, - * join?: { A?: { x: number, y: number, width: number, height: number }, slotA?: Record<string, number> | null, fromUrl?: string | null, size?: number | null, same?: boolean } | null }} o + * join?: { A?: { x: number, y: number, width: number, height: number }, slotA?: Record<string, number> | null, fromUrl?: string | null, size?: number | null, same?: boolean, plain?: boolean, headSize?: number | null } | null }} o */ export function postCardHtml(entry, { width, height, palette = {}, fonts = {}, phase = "read", parentShotUrl = null, transparent = false, avatars = {}, highlight = null, redaction = null, follow = false, thread = null, join = null }) { const hlOf = (scope) => (highlight && highlight.scope === scope ? highlight : null); @@ -1075,10 +1108,12 @@ export function postCardHtml(entry, { width, height, palette = {}, fonts = {}, p // THE JOIN (post-join.mjs): the post the item before ended on -- carried in, or the scene's -- drawn as that item // drew its post (its head, its words at their size), so the item opens on it exactly as it ended. const asPost = (scope, p, r, attr, mode, slotAttr = "") => { + // A PLAIN card before (no thread): its head is the card's (not the words' size) and its words a card's gap below; + // a THREADED one: its head at ITS words' box size (`headSize`), not this card's. const sz = fin(join?.size) ? join.size : sizeFor(contextText(p) || " ", innerW, innerH - 170 * k); const own2 = { author: p.author, handle: p.handle }; const headP = `<div class="head"${r ? ' data-redacted=""' : ""}>${avatarHtml(own2, { redact: r, size: Math.round(64 * k), accent: r ? undefined : pal.accent, img: r ? null : pic(p) })}<div class="hwho">${nameHtml(own2, { redact: r, cls: "big" })}<div class="date">${esc(cardDate(p.date))}</div></div><div class="mark">${esc(PLATFORM_NAME[entry.platform] ?? "")}</div></div>`; - tileHtml.push(`<div class="tslot" data-thread-slot="${esc(scope)}"${slotAttr}><div class="tile tpost tcarry" data-thread-tile="${esc(scope)}" data-thread-mode="${mode}" ${attr} data-join-anchor="">${relationHtml(t0(scope))}${headP}<div class="twords" style="font-size:${sz}px">${wordsHtml(contextText(p), r && p.handle ? [...blurred, p.handle] : blurred)}</div></div></div>`); + tileHtml.push(`<div class="tslot" data-thread-slot="${esc(scope)}"${slotAttr}><div class="tile tpost tcarry${join?.plain ? " tplain" : ""}" data-thread-tile="${esc(scope)}" data-thread-mode="${mode}" ${attr} data-join-anchor="">${relationHtml(t0(scope))}${!join?.plain && fin(join?.headSize) ? headP.replace('<div class="head"', `<div class="head" style="font-size:${join.headSize}px"`) : headP}<div class="twords" style="font-size:${sz}px">${wordsHtml(contextText(p), r && p.handle ? [...blurred, p.handle] : blurred)}</div></div></div>`); }; const refTile = (scope, p, where, attr) => { const mode = tmode(scope); @@ -1210,6 +1245,8 @@ b, .name, .mark { font-family: 'PostSansBold', sans-serif; font-weight: 400; } .tparent { display: flex; gap: ${Math.round(16 * k)}px; position: relative; } .tparent::after { content: ""; position: absolute; left: ${Math.round(27 * k)}px; top: ${Math.round(64 * k)}px; bottom: -${Math.round(20 * k)}px; width: 2px; background: ${line}; } .tpost { display: flex; flex-direction: column; gap: ${Math.round(16 * k)}px; } +.tplain { gap: ${Math.round(18 * k)}px; } +.tplain > .head { font-size: 16px; line-height: normal; } ${tiles?.some((t) => t?.rel) ? `.rel { color: ${pal.muted}; font-size: ${Math.round(18 * k)}px; margin-bottom: ${Math.round(4 * k)}px; letter-spacing: 0.01em; } .rel::before { content: "\\21b3 "; } ` : ""}.tile .tt { display: block; -webkit-line-clamp: none; overflow: visible; line-height: ${LINE}; color: ${pal.fg}; margin-top: ${Math.round(6 * k)}px; } @@ -1266,6 +1303,23 @@ export function cardWordsSize(entry, { width, height }, { follow = false, thread } /** + * HOW AN ITEM DRAWS ITS POST, for the join (post-join.mjs) -- what the item after it carries in is drawn alike, pure: + * `{ size, plain, headSize }` -- its words' size (cardWordsSize; threaded when its plan is), whether its card is PLAIN + * (no thread: its head the card's), else the size its head is drawn at (its words box's, cardWordsSize unthreaded). + * `entry` as its segment draws it (its markup, its media scene, the panel rule laid on), `plan` its postItemPlan. + * The build draws the item before's page with its OWN join this way (as its segment drew it); Play's route the same. + * @param {Record<string, any>} entry + * @param {{ follow?: { thread?: any } | null }} plan + * @param {{ width: number, height: number }} box + * @param {Record<string, any>} [render] + */ +export function joinCarryOf(entry, plan, box, render = undefined) { + const follow = followKnobs(entry, render).on; + const threaded = follow && !!plan?.follow?.thread; + return { size: cardWordsSize(entry, box, { follow, threaded }), plain: !threaded, headSize: threaded ? cardWordsSize(entry, box, { follow }) : null }; +} + +/** * A MEDIA SCENE's earlier message as a tile of a later item's column * (post-media-scene.mjs; postCardHtml's threaded card): drawn as its own post * tile was while it was read -- the repost line, its author (under its own diff --git a/umtool/report-to-video/post-join-continuity.test.mjs b/umtool/report-to-video/post-join-continuity.test.mjs @@ -0,0 +1,110 @@ +// THE JOIN's continuity (operator, 4 Nov, on mid-7 at 2357 s: "the transition from some posts hard cutting into the +// same post with children should be addressed. If one post is visible in the next scene, there should be a +// transition"): the item opens EXACTLY as the item before ended -- its card, what only it drew (its counts, its quote, +// its clock) dissolving rather than gone at the second frame -- and the check that measures it (check-joins.mjs). +import assert from "node:assert/strict"; +import { test } from "node:test"; + +import { JOIN_CLOCK_NEAR, joinClockOf, joinFrameAt, joinOpacities } from "./post-join.mjs"; +import { clockJoinExpr, concatRate, postSegmentArgs, postSegmentKey, postSegmentKeyOf, POST_JOIN_DRAW_V } from "./post-render.mjs"; +import { joinCarryOf, postCardHtml, postItemPlan } from "./post-item.mjs"; +import { planContext } from "./post-conversation.mjs"; + +const at = (h) => `2026-11-04T${String(h).padStart(2, "0")}:00:00.000Z`; +const narrate = (e, parts) => ({ ...e, narration: { takes: [{ file: `narration/${e.id}.wav`, seconds: 6, parts: parts.map((p) => ({ text: p.join(" ") })) }], picked: 0 } }); +const post = (id, text, h, extra = {}) => ({ type: "post", id: `p-${id}`, post: `ObviousRises-x/${id}`, platform: "x", author: "MR. OBVIOUS", handle: "ObviousRises", date: at(h), text, url: `https://x.com/ObviousRises/status/${id}`, ...extra }); +const ref = (id, text, h) => ({ id, author: "MR. OBVIOUS", handle: "ObviousRises", date: at(h), text }); + +test("THE DISSOLVE: at the boundary the item before's card is whole and on top; this one is in under it before it starts to go; what both draw never dims", () => { + // The first frames (e ~ 0): the item before, exactly. + assert.deepEqual(joinOpacities(0, true), { own: 1, from: 1 }); + assert.deepEqual(joinOpacities(0, false), { own: 0, from: 1 }); + // Never a frame where the item before's card is gone at once (main's `same` dropped it after the first frame). + const g = { A: { x: 100, y: 100, width: 968, height: 554 }, B: { x: 100, y: 0, width: 968, height: 787 }, slotA: null, slotB: null, same: true }; + assert.equal(joinFrameAt(g, 1 / 18).from.op, 1, "the second frame still shows what the item before showed"); + // This card is whole before the item before's starts to fade: over it, the shared post is lit throughout. + for (let e = 0; e <= 1.0001; e += 0.05) { + const o = joinOpacities(e, false); + if (o.from < 1) assert.equal(o.own, 1, `at e ${e.toFixed(2)} this card is in before that one fades`); + } + assert.deepEqual(joinOpacities(1, false), { own: 1, from: 0 }); + assert.ok(joinFrameAt(g, 0.9).from.op === 0, "gone well before the join ends"); +}); + +test("THE CLOCK OVER A JOIN: near, it carries on (moved the little way); apart, the item before's is laid in its shot and dissolves, this one comes in -- never across the card's words", () => { + assert.deepEqual(joinClockOf({ from: { x: 100, y: 200 }, own: { x: 110, y: 190 }, k: 1 }), { bake: false, move: { dx: -10, dy: 10 }, fadeIn: false }); + // mid-7 at 2357 s: the card's foot (bottom-right) to above the card (top-right). + assert.deepEqual(joinClockOf({ from: { x: 1050, y: 620 }, own: { x: 1050, y: 20 }, k: 886 / 1080 }), { bake: true, move: null, fadeIn: true }); + assert.deepEqual(joinClockOf({ from: null, own: { x: 1, y: 1 } }), { bake: false, move: null, fadeIn: true }); + assert.deepEqual(joinClockOf({ from: { x: 1, y: 1 }, own: null }), { bake: true, move: null, fadeIn: false }); + assert.deepEqual(joinClockOf({ from: null, own: null }), { bake: false, move: null, fadeIn: false }); + assert.ok(JOIN_CLOCK_NEAR > 0); + // The move's expression: base + d at the start, base from the join's end. + const ex = clockJoinExpr(900, -12, 0.6); + // ffmpeg's expression, evaluated as ffmpeg would (if, lt, min, pow). + const ev = (t) => Function("t", "min", "pow", "lt", "iff", `return ${ex.replace(/\bif\(/g, "iff(")};`)(t, Math.min, Math.pow, (a, b) => a < b, (c, a, b) => (c ? a : b)); + assert.equal(ev(0), 888); + assert.equal(ev(0.6), 900); + assert.equal(ev(2), 900); +}); + +test("THE SEGMENT's CLOCK over a join: moved from the item before's place (an expression on t), or faded in -- a clock with no join drawn as before", () => { + const plan = { total: 10, steps: [], reading: 10 }; + const base = { entry: { id: "p-1", media: [] }, box: { width: 1574, height: 886 }, plan, layout: { mode: "text", slot: null }, cards: { read: "read.png" }, files: [], render: { fps: 30 }, outPath: "out.mp4" }; + const graph = (clock) => postSegmentArgs({ ...base, clock }).find((a) => String(a).includes("[clk]overlay")); + const plain = graph({ list: "c.ffconcat", x: 900, y: 600, until: 10 }); + assert.match(plain, /\[clk\]overlay=x=900:y=600:eof_action=repeat/); + assert.doesNotMatch(plain, /fade=t=in/); + const moved = graph({ list: "c.ffconcat", x: 900, y: 600, until: 10, join: { seconds: 0.6, from: { dx: 0, dy: 14 }, fadeIn: false } }); + assert.match(moved, /overlay=x=900:y='600\+14\*\(1-if\(lt\(min\(1,t\/0\.6\),0\.5\)/); + const faded = graph({ list: "c.ffconcat", x: 900, y: 20, until: 10, join: { seconds: 0.6, from: null, fadeIn: true } }); + assert.match(faded, /fade=t=in:st=0:d=0\.6:alpha=1\[clk\]/); + assert.match(faded, /overlay=x=900:y=20:/); +}); + +test("THE CARRIED POST drawn as a PLAIN card drew it: its head at the card's size (not the words'), its words a card's gap below; after a threaded card, its head at that card's words box size", () => { + const before = post("10", "I'm only giving mercy because I'm concerned for my moms.", 7); + const reply = narrate(post("11", "notice how thats the exact character limit", 8, { parents: [ref("10", before.text, 7)], thread: { group: "limit" } }), [["notice how thats the exact character limit"]]); + const tl = [narrate(before, [[before.text]]), reply]; + const ctx = planContext(tl, 1); + const plan = postItemPlan(reply, undefined, ctx); + const html = (plain, headSize = null) => postCardHtml(reply, { width: 1574, height: 886, follow: true, thread: plan.follow.thread, join: { A: { x: 10, y: 10, width: 800, height: 500 }, size: 38, plain, headSize } }); + assert.match(html(true), /class="tile tpost tcarry tplain"/); + assert.match(html(true), /\.tplain > \.head \{ font-size: 16px; line-height: normal; \}/); + assert.match(html(false), /class="tile tpost tcarry" /); + // A threaded card before: its head at its own words box's size, not this card's. + assert.match(html(false, 41), /data-join-anchor=""><div class="head" style="font-size:41px">/); + assert.doesNotMatch(html(true, 41), /font-size:41px/); +}); + +test("THE KEY: a joined item's key carries the join's drawing and the clock the item before ran -- its key changes; an item with no join keeps the key it had", () => { + const entry = post("11", "notice how", 8); + const plan = { narration: null, follow: null, total: 5, steps: [] }; + const common = { entry, box: { width: 1574, height: 886 }, render: { fps: 30, palette: {} }, plan }; + const none = postSegmentKeyOf(common); + assert.equal(none.joinFrom, undefined); + const from = { entry: post("10", "mercy", 7), plan: { follow: null, total: 15.9 }, media: [], fadeIn: false, clock: { to: 1, from: null, mode: "none", zone: "America/New_York", gap: 0, forced: false } }; + const joined = postSegmentKeyOf({ ...common, from }); + assert.equal(joined.joinFrom.jv, POST_JOIN_DRAW_V); + assert.deepEqual(joined.joinFrom.clock, from.clock); + const other = postSegmentKeyOf({ ...common, from: { ...from, clock: { ...from.clock, to: 2 } } }); + assert.notEqual(postSegmentKey(joined), postSegmentKey(other), "the item before's clock is in the key"); + assert.notEqual(postSegmentKey(joined), postSegmentKey(none)); +}); + +test("A FRAMES LIST reads each shot at the item's rate (ffconcat `option framerate`): no shot in six dropped and its neighbour held", () => { + assert.deepEqual(concatRate(30), ["option framerate 30"]); +}); + +test("HOW AN ITEM DRAWS ITS POST (joinCarryOf): a plain card's words and head; a threaded card's post tile size and its words box's head -- the build draws the item before's page with its own join this way, as its segment drew it", () => { + const box = { width: 1574, height: 886 }; + const before = narrate(post("10", "I'm only giving mercy because I'm concerned for my moms.", 7), [["I'm only giving mercy because I'm concerned for my moms."]]); + const reply = narrate(post("11", "notice how thats the exact character limit", 8, { parents: [ref("10", before.text, 7)], thread: { group: "limit" } }), [["notice how thats the exact character limit"]]); + const plain = joinCarryOf(before, postItemPlan(before), box); + assert.equal(plain.plain, true); + assert.equal(plain.headSize, null); + const tl = [before, reply]; + const threaded = joinCarryOf(reply, postItemPlan(reply, undefined, planContext(tl, 1)), box); + assert.equal(threaded.plain, false); + assert.ok(threaded.size > 0 && threaded.headSize > 0); +}); diff --git a/umtool/report-to-video/post-join.mjs b/umtool/report-to-video/post-join.mjs @@ -6,8 +6,11 @@ // // the CARD its container morphs from the item before's box (as it ended) to its own -- position, // width and height eased; the words inside scaled with its width, never re-flowed -// what it SHOWED the item before's card as it ended (the build: a shot of its page at its last frame; -// Play: its page in a second frame) rides the container and fades out as this one's fades in +// what it SHOWED the item before's card as it ended (the build: a shot of its page at its last frame -- its +// clock, its parent's shot, a visit's pointer on it; Play: its page in a second frame) rides +// the container on top and dissolves into this one's, whole under it first (joinOpacities) +// the CLOCK carried on from the item before's when near, else that one dissolves and this comes in +// (joinClockOf) -- never moved across the card's words // the COLUMN the post the item before ended on (carried, or the scene's) is drawn as that item drew it // -- its head, its words at their size -- and the column opens framed where it was // the SLOT a slot that appears fades in, one that goes fades out; another attachment cross-fades @@ -60,6 +63,17 @@ const lerpRect = (a, b, f) => ({ x: lerp(a.x, b.x, f), y: lerp(a.y, b.y, f), wid const sameRect = (a, b) => !!a && !!b && ["x", "y", "width", "height"].every((k) => Math.abs(a[k] - b[k]) < 1.5); /** + * THE DISSOLVE's strengths at eased progress `e`, pure: `{ own, from }` -- this card's (under) in by e 0.3 (from the + * first frame when the content is the same), the item before's (over it) out from e 0.25 to 0.75. Both are whole + * across the boundary (e 0: the item before as it ended) and the item before's is gone well before the join ends. + */ +export function joinOpacities(e, same = false) { + const own = same ? 1 : Math.min(1, Math.max(0, e / 0.3)); + const from = 1 - Math.min(1, Math.max(0, (e - 0.25) / 0.5)); + return { own, from }; +} + +/** * THE JOIN's FRAME at progress `p` (0: the item before as it ended, 1: this item's own), pure: `{ e, R, own, from, * slotFrom, slotTo }` -- `R` the container's box; `own` this card's transform (`tx`, `ty`, `s`: its top-left moved to * R's, scaled by R's width over its own; `clipH` the height of it that shows; `op`); `from` the item before's card @@ -73,22 +87,44 @@ export function joinFrameAt(g, p) { const B = g.B; const R = lerpRect(A, B, e); const s = R.width / Math.max(1, B.width); - // The content cross-fades over the middle half of the join; the same content (sameRect, a carry alike) shows - // this card's from the first frame -- the item before's drawn under it only as long as the box moves. - const x = Math.min(1, Math.max(0, (e - 0.4) / 0.4)); - const y = Math.min(1, Math.max(0, (e - 0.1) / 0.4)); - const opOwn = g.same ? 1 : x; + // The item before's card (on top) dissolves into this one's, which is in UNDER it before it starts to go -- so + // what both draw (the post carried in) never dims, and what only the item before drew (its counts, its quote, its + // clock) fades out; never a frame where it is all gone at once (operator, 4 Nov, mid-7: "if one post is visible + // in the next scene, there should be a transition"). The same content (a carry alike) is this card's from the + // first frame, under the item before's. + const { own: opOwn, from: opFrom } = joinOpacities(e, !!g.same); const sameSlot = sameRect(g.slotA, g.slotB); return { e: r2(e), R: { x: r2(R.x), y: r2(R.y), width: r2(R.width), height: r2(R.height) }, own: { tx: r2(R.x - B.x), ty: r2(R.y - B.y), s: Math.round(s * 10000) / 10000, clipH: r2(R.height / Math.max(1e-6, s)), op: r2(opOwn) }, - from: { x: r2(R.x), y: r2(R.y), s: Math.round((R.width / Math.max(1, A.width)) * 10000) / 10000, op: r2(g.same ? (p <= 0 ? 1 : 0) : 1 - y) }, + from: { x: r2(R.x), y: r2(R.y), s: Math.round((R.width / Math.max(1, A.width)) * 10000) / 10000, op: r2(opFrom) }, slotFrom: g.slotA && !sameSlot ? r2(1 - e) : g.slotA ? 1 : 0, slotTo: g.slotB && !sameSlot ? r2(e) : g.slotB ? 1 : 0, }; } +/** How far (px at 1080) the clock may carry on from the item before's place by moving: never across the card's words. */ +export const JOIN_CLOCK_NEAR = 24; + +/** + * THE CLOCK OVER A JOIN, pure (post-clock.mjs): `{ bake, move, fadeIn }` -- `from` where the item before's clock sat + * as it ended (or null: it showed none), `own` where this item's sits (or null), `k` the box's height over 1080. + * Near (within JOIN_CLOCK_NEAR): this one opens on that one's place and moves the little way (`move` its offset + * there), nothing faded. Apart: a move would cross the card's words -- that one is laid in the item before's shot + * (`bake`) and dissolves with it, this one comes in over the join (`fadeIn`). None before: this one comes in; none + * now: that one is laid in the shot. + * @param {{ from: { x: number, y: number } | null, own: { x: number, y: number } | null, k?: number }} o + */ +export function joinClockOf({ from, own, k = 1 }) { + if (!own) return { bake: !!from, move: null, fadeIn: false }; + if (!from) return { bake: false, move: null, fadeIn: true }; + const dx = from.x - own.x; + const dy = from.y - own.y; + if (Math.hypot(dx, dy) <= JOIN_CLOCK_NEAR * k) return { bake: false, move: { dx: r2(dx), dy: r2(dy) }, fadeIn: false }; + return { bake: true, move: null, fadeIn: true }; +} + /** The join's progress at item second `s` (null: over, or none). */ export const joinProgressAt = (join, s) => (join && fin(join.seconds) && s < join.seconds - 1e-6 ? Math.max(0, s / join.seconds) : null); @@ -171,8 +207,9 @@ export function applyJoinState(p, doc = document) { const L = (a, b2) => a + (b2 - a) * e; const R = { x: L(A.x, B.x), y: L(A.y, B.y), width: L(A.width, B.width), height: L(A.height, B.height) }; const s = R.width / Math.max(1, B.width); - const x = Math.min(1, Math.max(0, (e - 0.4) / 0.4)); - const y = Math.min(1, Math.max(0, (e - 0.1) / 0.4)); + // joinOpacities, inlined. + const x = g.same ? 1 : Math.min(1, Math.max(0, e / 0.3)); + const y = 1 - Math.min(1, Math.max(0, (e - 0.25) / 0.5)); const same = (a, b2) => !!a && !!b2 && ["x", "y", "width", "height"].every((k) => Math.abs(a[k] - b2[k]) < 1.5); const sameSlot = same(g.slotA, g.slotB); card.style.transformOrigin = "0 0"; @@ -180,7 +217,7 @@ export function applyJoinState(p, doc = document) { card.style.clipPath = `inset(0 0 ${Math.max(0, B.height - R.height / s)}px 0)`; card.style.background = "transparent"; card.style.borderColor = "transparent"; - card.style.opacity = String(g.same ? 1 : x); + card.style.opacity = String(x); if (bg) { bg.style.display = "block"; bg.style.left = `${R.x}px`; @@ -195,8 +232,8 @@ export function applyJoinState(p, doc = document) { from.style.width = `${A.width}px`; from.style.transform = `scale(${R.width / Math.max(1, A.width)})`; from.style.clipPath = `inset(0 0 ${Math.max(0, A.height - R.height / (R.width / Math.max(1, A.width)))}px 0)`; - // The same content drawn alike: the item before's card is the first frame only (never a double image). - from.style.opacity = String(g.same ? (v <= 0 ? 1 : 0) : 1 - y); + // Over this card, dissolving into it (the same content drawn alike: identical where they overlap). + from.style.opacity = String(y); } if (slotFrom) { slotFrom.style.display = g.slotA && !sameSlot ? "block" : "none"; diff --git a/umtool/report-to-video/post-media-enter.test.mjs b/umtool/report-to-video/post-media-enter.test.mjs @@ -0,0 +1,81 @@ +// ITS OWN ATTACHMENTS COME IN WITH ITS OWN POST (post-item.mjs ownMediaEnterAt; operator, 4 Nov, mid-11 at ~15:58: +// "the mr. obvious gif should come in when his post does rather than during the strawb megathread reading"). +import assert from "node:assert/strict"; +import { test } from "node:test"; + +import { ownMediaEnterAt, postItemPlan, stepAt, validatePostItem } from "./post-item.mjs"; +import { postSegmentArgs, postSegmentKey, postSegmentKeyOf } from "./post-render.mjs"; + +const at = (h) => `2026-11-04T${String(h).padStart(2, "0")}:00:00.000Z`; +/** A take of [text, role] pieces, each one part with its role set (as `umtool posts roles` sets them). */ +const narrate = (e, pieces) => { + let t = 0; + const parts = pieces.map(([text, role], n) => { + const seconds = Math.round((text.split(/\s+/).length / 3) * 100) / 100; + t += n ? 0.8 : 0; + const p = { n: n + 1, para: n * 100, text, start: Math.round(t * 100) / 100, seconds, ...(role ? { role } : {}) }; + t += seconds; + return p; + }); + return { ...e, narration: { script: e.text, takes: [{ file: `narration/posts/${e.id}/take-1.wav`, engine: "orpheus", voice: "leo+zac", seconds: Math.round(t * 100) / 100, script: pieces.map((p) => p[0]).join("\n\n"), parts }], pick: 0 } }; +}; +const gif = { src: "posts-media/ObviousRises-x/11/11_1.mp4", kind: "gif", width: 480, height: 270, seconds: 3 }; +const video = { src: "posts-media/ObviousRises-x/11/11_2.mp4", kind: "video", width: 1280, height: 720, seconds: 30, audio: true }; +const mega = "STRAWB MEGATHREAD: everything she said, in order, with the receipts for each part of it."; +const his = "this is what happens when you push people, they push back."; +const base = (extra = {}) => ({ type: "post", id: "p-11", post: "ObviousRises-x/11", platform: "x", author: "MR. OBVIOUS", handle: "ObviousRises", date: at(9), text: his, url: "https://x.com/ObviousRises/status/11", ...extra }); +const quoting = (media) => narrate(base({ media, quoted: { id: "5", author: "Strawb", handle: "strawb", date: at(7), text: mega } }), [[mega, "quoted"], [his, "post"]]); + +test("the item's own GIF comes in when his post's read begins -- the megathread read first shows none of it; crossfaded in from there", () => { + const e = quoting([gif]); + const plan = postItemPlan(e); + assert.ok(plan.follow?.thread, "a threaded read"); + const postStart = Math.min(...plan.follow.blocks.filter((b) => b.scope === "post" && b.start !== null).map((b) => b.start)); + const quoteStart = Math.min(...plan.follow.blocks.filter((b) => b.scope === "quoted" && b.start !== null).map((b) => b.start)); + assert.ok(quoteStart < postStart, "the quote is read first"); + assert.equal(plan.enter, postStart); + assert.equal(plan.steps[0].at, postStart, "its first step starts with his words"); + assert.equal(stepAt(plan, quoteStart + 0.5), null, "nothing of his while the megathread is read"); + assert.equal(stepAt(plan, postStart + 0.1)?.items[0].src, gif.src); + // The build: the GIF's layer is laid from that moment and faded in there, never from the first frame. + const args = postSegmentArgs({ entry: e, box: { width: 1574, height: 886 }, plan, layout: { mode: "side", slot: { x: 900, y: 0, width: 674, height: 886 }, card: { x: 0, y: 0, width: 880, height: 886 } }, cards: { read: "read.png" }, files: ["gif.mp4"], render: { fps: 30 }, outPath: "o.mp4" }); + const graph = args[args.indexOf("-filter_complex") + 1]; + assert.match(graph, new RegExp(`fade=t=in:st=${postStart}:d=0\\.3:alpha=1\\[m0_0\\]`)); + assert.match(graph, new RegExp(`\\[m0_0\\]overlay=x=900:y=\\d+:enable='between\\(t,${postStart},`)); +}); + +test("a video entering with his post starts there -- its offset counted from that moment, its sound too, its trim fitted to what is left", () => { + const e = quoting([video]); + const plan = postItemPlan(e); + const st = plan.steps[0]; + assert.equal(st.at, plan.enter); + assert.equal(st.srcFrom, 0, "from its own start at that moment"); + assert.ok(st.at + st.seconds <= plan.total + 1e-6); + const args = postSegmentArgs({ entry: e, box: { width: 1574, height: 886 }, plan, layout: { mode: "side", slot: { x: 900, y: 0, width: 674, height: 886 }, card: { x: 0, y: 0, width: 880, height: 886 } }, cards: { read: "read.png" }, files: ["v.mp4"], render: { fps: 30 }, outPath: "o.mp4" }); + const graph = args[args.indexOf("-filter_complex") + 1]; + const ms = Math.round(plan.enter * 1000); + assert.match(graph, new RegExp(`adelay=${ms}\\|${ms}`), "its sound delayed to his words"); +}); + +test("nothing changes for an item that reads only its post, one with enter: item, or one past the first of a media scene; the key changes only where it enters later", () => { + const only = narrate(base({ media: [gif] }), [[his, "post"]]); + const p0 = postItemPlan(only); + assert.equal(ownMediaEnterAt(only, p0.follow), 0); + assert.equal(p0.enter, undefined); + assert.equal(p0.steps[0].at, 0); + const item = quoting([{ ...gif, enter: "item" }]); + assert.equal(postItemPlan(item).enter, undefined); + assert.equal(postItemPlan(item).steps[0].at, 0); + const e = quoting([gif]); + const plan = postItemPlan(e); + assert.equal(ownMediaEnterAt(e, plan.follow, { mediaScene: { n: 1 } }), 0, "held through from the item before"); + assert.ok(ownMediaEnterAt(e, plan.follow, { mediaScene: { n: 0 } }) > 0, "the first of a media scene still waits"); + // The key: `enter` only on the item that enters later. + const box = { width: 1574, height: 886 }; + const render = { fps: 30, palette: {} }; + assert.equal(postSegmentKeyOf({ entry: only, box, render, plan: p0 }).enter, undefined); + assert.deepEqual(postSegmentKeyOf({ entry: e, box, render, plan }).enter, { at: plan.enter, fade: 0.3 }); + assert.notEqual(postSegmentKey(postSegmentKeyOf({ entry: e, box, render, plan })), postSegmentKey(postSegmentKeyOf({ entry: e, box, render, plan: { ...plan, enter: undefined } }))); + // The knob is checked. + assert.deepEqual(validatePostItem(quoting([{ ...gif, enter: "later" }])).filter((x) => x.includes("enter")).length, 1); +}); diff --git a/umtool/report-to-video/post-render.mjs b/umtool/report-to-video/post-render.mjs @@ -18,7 +18,7 @@ import { createHash } from "node:crypto"; import { mkdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises"; import path from "node:path"; import { pathToFileURL } from "node:url"; -import { POST_PICTURE_XFADE, POST_PUSH, cardAuthors, fxRedactionErrors, mediaTimeAt, panelEntry, postCardHtml, postItemPlan, postLayout, stepAt, stepBoxes } from "./post-item.mjs"; +import { POST_ENTER_FADE, POST_PICTURE_XFADE, POST_PUSH, cardAuthors, fxRedactionErrors, joinCarryOf, mediaTimeAt, panelEntry, postCardHtml, postItemPlan, postLayout, stepAt, stepBoxes } from "./post-item.mjs"; import { isNarrated, narrationLevelDb, pickedTake, postNarrationFilters, postNarrationKnobs, rootTakeOf } from "./post-narration.mjs"; import { applyFollowState, followPath, followRuns, followStateAt, isDrawnState, measureFollow, readInViewErrors, shotStateAt } from "./read-follow.mjs"; import { redactEntry, redactionOn, shownLine, termsFor } from "./post-redact.mjs"; @@ -31,7 +31,7 @@ import { POST_PROGRESS_DRAW_V, measureProgressPlace, mountProgress, progressCss, import { SLAM_BAR, SLAM_DUST, SLAM_FACE_STACK, SLAM_MOTION, mountSlams, slamBarOf, setSlamState, slamCss, slamCoverErrors, slamHits, slamLayout, slamListAt, slamPlan, slamShakeExpr, slamSize, slamVars } from "./post-slam.mjs"; import { TRAILER_AUDIO, TRAILER_HIT_TIERS, trailerHitsGraph } from "./trailer-hits.mjs"; import { panelReadErrors } from "./post-thread.mjs"; -import { applyJoinState, endMediaOf } from "./post-join.mjs"; +import { applyJoinState, endMediaOf, joinClockOf } from "./post-join.mjs"; import { applyVisitState } from "./post-link-visit.mjs"; import { applyMapState, mapPageHtml, mapPlace, mapSize, mapStateAt } from "./post-branch-map.mjs"; import { WORD_ZOOM_DEFAULTS, findMatch, overlappingZooms, resolveWordZoom, targetScope, targetTextOf, wordZoomTimes, zoomSpan, zoomTarget, zoompanExprs } from "./word-zoom.mjs"; @@ -91,6 +91,16 @@ export function scrollExpr(keys) { * * @returns {string[]} */ +/** + * The clock's place over a join, an ffmpeg expression on `t`: `base + d` at the join's start, `base` from its end, + * eased between as the card is (post-join.mjs joinEase, in-out cubic). + */ +export function clockJoinExpr(base, d, seconds) { + const p = `min(1,t/${num(seconds)})`; + const e = `if(lt(${p},0.5),4*pow(${p},3),1-pow(2-2*${p},3)/2)`; + return `${num(base)}+${num(d)}*(1-${e})`; +} + export function postSegmentArgs({ entry, box, plan, layout, cards, files, render, place = [], encode = [], captions = [], fontfile = null, outPath, narration = null, zooms = [], follow = null, panelFiles = [], join = null, map = null, captionFx = [], clock = null, slams = [], slamHitList = [], progress = null }) { const fps = render.fps ?? 30; const T = plan.total; @@ -184,9 +194,14 @@ export function postSegmentArgs({ entry, box, plan, layout, cards, files, render // 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]`); + // THE JOIN (post-join.mjs): it opens where the item before's clock sat and moves with the card (its ease), or, + // the item before showing none, comes in over the join. + const cj = clock.join && clock.join.seconds > 0 ? clock.join : null; + const fadeIn = cj?.fadeIn ? `,fade=t=in:st=0:d=${num(cj.seconds)}:alpha=1` : ""; + parts.push(`[${ci}:v]fps=${fps},format=rgba,setsar=1,setpts=PTS-STARTPTS${fadeIn}[clk]`); + const pos = (base, d) => (cj?.from && Math.abs(d) >= 0.5 ? `'${clockJoinExpr(base, d, cj.seconds)}'` : String(base)); 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}]`); + parts.push(`[${cur}][clk]overlay=x=${pos(clock.x, cj?.from?.dx ?? 0)}:y=${pos(clock.y, cj?.from?.dy ?? 0)}:eof_action=repeat${clock.until < T ? `:enable='lt(t,${num(clock.until)})'` : ""}[${next}]`); cur = next; } const audio = []; @@ -197,9 +212,12 @@ export function postSegmentArgs({ entry, box, plan, layout, cards, files, render const xfIn = si > 0 && picture(step) && picture(plan.steps[si - 1]) ? POST_PICTURE_XFADE : 0; const xfOut = !last && picture(step) && picture(plan.steps[si + 1]) ? POST_PICTURE_XFADE : 0; const until = last ? T : Math.min(T, step.at + step.seconds + xfOut); - const fadeIn = (from) => (xfIn ? `,format=rgba,fade=t=in:st=${num(from)}:d=${num(xfIn)}:alpha=1` : ""); - // Beside the card, the first attachment is up from the first frame (its first frame while the words are read). - const shownFrom = si === 0 && layout.mode === "side" ? 0 : step.at; + // ITS OWN ATTACHMENT entering with his own post (post-item.mjs ownMediaEnterAt): crossfaded in from that moment. + const enterIn = si === 0 && plan.enter > 0 ? POST_ENTER_FADE : 0; + const fadeIn = (from) => (xfIn ? `,format=rgba,fade=t=in:st=${num(from)}:d=${num(xfIn)}:alpha=1` : enterIn ? `,format=rgba,fade=t=in:st=${num(from)}:d=${num(enterIn)}:alpha=1` : ""); + // Beside the card, the first attachment is up from the first frame (its first frame while the words are read) -- + // unless it enters with his own post. + const shownFrom = si === 0 && layout.mode === "side" && !(plan.enter > 0) ? 0 : step.at; const boxes = stepBoxes(step, layout.slot); step.items.forEach((m, j) => { const b = boxes[j]; @@ -227,7 +245,7 @@ export function postSegmentArgs({ entry, box, plan, layout, cards, files, render const k = add([...(step.loop ? ["-stream_loop", "-1"] : []), "-ss", num(step.srcFrom), "-t", num(len), "-i", file]); parts.push( `[${k}:v]${crop}scale=${b.width}:${b.height},setsar=1,fps=${fps},setpts=PTS-STARTPTS,` + - `tpad=start_duration=${num(step.at)}:start_mode=clone:stop_mode=clone:stop_duration=${num(T)}[${raw}]`, + `tpad=start_duration=${num(step.at)}:start_mode=clone:stop_mode=clone:stop_duration=${num(T)}${fadeIn(shownFrom)}[${raw}]`, ); if (step.sound) { const ms = Math.round(step.at * 1000); @@ -422,19 +440,41 @@ export async function renderPostCards(entry, { box, render, dir, manifestDir, la const av = Object.fromEntries(Object.entries(avatars).map(([h, f]) => [h, pathToFileURL(f).href])); // THE JOIN (post-join.mjs): the item before's card as it ENDED -- its page drawn, its last frame's state set, its // card shot -- and where its post's words sat; this card opens on it and morphs into its own. + // The shot is the item before's LAST FRAME as its segment draws it (check-joins.mjs measures it): its page (its + // parent's shot too), its read-follow's last state, a link visit's pointer, and its clock -- in the shot when + // this item has none (it fades with the card), else this item's clock starts where that one sat and moves. let join = null; if (follow?.join && joinFrom?.entry) { const fps = render.fps ?? 30; const pe = joinFrom.entry; const pf = joinFrom.plan?.follow ?? null; - const ph = postCardHtml(pe, { width: box.width, height: box.height, palette: render.palette, fonts, phase: "read", avatars: av, follow: !!pf, thread: pf?.thread ?? null, redaction }); + const pShot = typeof pe.parentShot === "string" ? pathToFileURL(path.resolve(manifestDir, pe.parentShot)).href : null; + const ph = postCardHtml(pe, { width: box.width, height: box.height, palette: render.palette, fonts, phase: "read", parentShotUrl: pShot, avatars: av, follow: !!pf, thread: pf?.thread ?? null, redaction, join: joinFrom.carry ?? null }); const pfile = path.join(dir, "join-from.html"); await writeFile(pfile, ph, "utf8"); await page.goto(pathToFileURL(pfile).href, { waitUntil: "load" }); await page.waitForSelector("body[data-post-ready='1']", { timeout: 15000 }); + const endS = Math.max(0, joinFrom.plan.total - 1 / fps); + const pl0 = postLayout(pe, box); + // Its clock, placed as its own segment placed it (clockPlaceOn), shown at its end unless a stack card's media + // phase hid it. + const pClock = joinFrom.clock && !(pl0.mode === "stack" && joinFrom.plan.steps?.length) ? joinFrom.clock : null; + let clockFrom = null; + if (pClock) { + const k = box.height / 1080; + const face = clockFace(pClock.to, pClock.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)); + const at = size ? await clockPlaceOn(page, { follow: pf, total: joinFrom.plan.total, size, k }) : null; + if (at) clockFrom = { x: at.x, y: at.y, st: clockStateAt(pClock, endS) }; + } if (pf) { const pgeo = await page.evaluate(measureFollow); - await page.evaluate(applyFollowState, followStateAt(pf, followPath(pf, pgeo), Math.max(0, joinFrom.plan.total - 1 / fps))); + // Its own join's opening frame (its record's `joinAnchor`): a read that never pans again ends where it opened. + if (pgeo && Number.isFinite(joinFrom.anchorY)) pgeo.joinAnchor = { y: joinFrom.anchorY }; + const st = followStateAt(pf, followPath(pf, pgeo), endS); + await page.evaluate(applyFollowState, st); + if (pf.visits?.length) await page.evaluate(applyVisitState, { visits: pf.visits, st: st.visit ?? null }); } const m = await page.evaluate(() => { const card = document.querySelector("[data-post-card]"); @@ -445,19 +485,36 @@ export async function renderPostCards(entry, { box, render, dir, manifestDir, la const post = document.querySelector('[data-thread-slot="post"] .head') ?? card.querySelector(".head"); const words = document.querySelector('[data-thread-slot="post"] .twords') ?? document.querySelector("[data-post-words]"); const pr = post ? post.getBoundingClientRect() : null; - return { A: { x: c.left, y: c.top, width: c.width, height: c.height }, anchor: pr ? pr.top - c.top : null, size: words ? parseFloat(getComputedStyle(words).fontSize) : null }; + return { A: { x: c.left, y: c.top, width: c.width, height: c.height }, anchor: pr ? pr.top - c.top : null, size: words ? parseFloat(getComputedStyle(words).fontSize) : null, plain: !document.querySelector('[data-thread-slot="post"]'), headSize: post ? parseFloat(getComputedStyle(post).fontSize) : null }; }); if (m) { const png = path.join(dir, "join-from.png"); const x = Math.max(0, Math.floor(m.A.x)); const y = Math.max(0, Math.floor(m.A.y)); - await page.screenshot({ path: png, clip: { x, y, width: Math.min(box.width - x, Math.ceil(m.A.width)), height: Math.min(box.height - y, Math.ceil(m.A.height)) } }); + const clip = { x, y, width: Math.min(box.width - x, Math.ceil(m.A.width)), height: Math.min(box.height - y, Math.ceil(m.A.height)) }; + await page.screenshot({ path: png, clip }); + // And with its clock on it, as it ended (laid in the shot when this item's clock does not carry on from it). + let pngClock = null; + if (clockFrom) { + pngClock = path.join(dir, "join-from-clock.png"); + await page.evaluate(setClockState, clockFrom); + await page.screenshot({ path: pngClock, clip }); + await page.evaluate(setClockState, null); + } const pl = postLayout(pe, box); const same = Math.abs(m.A.width - layout.card.width) < 2 && !!(follow.thread?.tiles ?? []).some((t) => t.mode === "carry" || (t.mode === "scene" && t.wasPost)); - join = { A: { x, y, width: Math.ceil(m.A.width), height: Math.ceil(m.A.height) }, slotA: pl.slot && pl.mode === "side" ? pl.slot : null, fromUrl: pathToFileURL(png).href, size: m.size, same, anchor: m.anchor }; - out.joinFrom = { A: join.A, layout: pl }; + join = { A: { x, y, width: Math.ceil(m.A.width), height: Math.ceil(m.A.height) }, slotA: pl.slot && pl.mode === "side" ? pl.slot : null, fromUrl: pathToFileURL(png).href, size: m.size, same, anchor: m.anchor, plain: m.plain, headSize: m.headSize }; + out.joinFrom = { A: join.A, layout: pl, clock: clockFrom ? { x: clockFrom.x, y: clockFrom.y } : null, pngClock }; } } + // THE CLOCK (post-clock.mjs), shot before the read's frames: over a join, where it opens decides the shot the + // card opens on (joinClockOf: carried on from the item before's clock, or that one laid in the shot, fading). + if (clock) out.clock = await shootClock(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, clock, redaction, follow, total }); + if (join) { + const jc = joinClockOf({ from: out.joinFrom?.clock ?? null, own: out.clock?.at ?? null, k: box.height / 1080 }); + if (jc.bake && out.joinFrom?.pngClock) join.fromUrl = pathToFileURL(out.joinFrom.pngClock).href; + if (out.clock) out.clock.join = { seconds: follow.join.seconds, from: jc.move, fadeIn: jc.fadeIn }; + } for (const phase of phases) { const html = postCardHtml(entry, { width: box.width, height: box.height, palette: render.palette, fonts, phase, parentShotUrl, @@ -489,6 +546,7 @@ export async function renderPostCards(entry, { box, render, dir, manifestDir, la return c && w ? { win: w.top - c.top, width: c.width, head: head && slot ? head.top - slot.top : 0 } : null; }); if (own) geo.joinAnchor = { y: Math.round((join.anchor / (join.A.width / own.width) - own.win - own.head) * 100) / 100 }; + if (geo.joinAnchor) out.joinAnchor = geo.joinAnchor.y; } out.follow = await shootFollow(page, { follow, total, fps, box, dir, geo }); // THE BRANCH MAP (post-branch-map.mjs): its own layer, shot on a transparent page, laid over the attachments. @@ -501,7 +559,6 @@ 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 (clock) out.clock = await shootClock(browser, entry, { box, render, dir, fonts, parentShotUrl, avatars, clock, redaction, follow, total }); // The progress bar (post-progress.mjs): along the card's foot, short of the clock on its line. if (progress) { const k = box.height / 1080; @@ -518,6 +575,13 @@ export async function renderPostCards(entry, { box, render, dir, manifestDir, la } /** + * A shot's line in a frames list (ffconcat): its image read at the item's rate. Without it each PNG is read on the + * image demuxer's 1/25 s clock, its start rounded to a 40 ms step, and the 30 fps output drops one shot in six and + * holds its neighbour -- every pan, join and clock run juddered (measured: a held frame every 0.2 s in mid-7's joins). + */ +export const concatRate = (fps) => [`option framerate ${fps}`]; + +/** * READ-FOLLOW's FRAMES (read-follow.mjs): on the drawn card page, the pan's * path from its geometry (`geo`, measureFollow's: measured here when not * given), then every frame's state (followStateAt at frame i / fps); each @@ -563,8 +627,8 @@ export async function shootFollow(page, { follow, total, fps, box, dir, geo = nu if (follow.visits?.length) await page.evaluate(applyVisitState, { visits: follow.visits, st: null }); const q = (f) => `'${f.replace(/'/g, "'\\''")}'`; const lines = ["ffconcat version 1.0"]; - for (const run of runs) lines.push(`file ${q(shots.get(run.key))}`, `duration ${(run.n / fps).toFixed(6)}`); - lines.push(`file ${q(shots.get(runs[runs.length - 1].key))}`); + for (const run of runs) lines.push(`file ${q(shots.get(run.key))}`, ...concatRate(fps), `duration ${(run.n / fps).toFixed(6)}`); + lines.push(`file ${q(shots.get(runs[runs.length - 1].key))}`, ...concatRate(fps)); const list = path.join(fdir, "frames.ffconcat"); await writeFile(list, lines.join("\n") + "\n", "utf8"); return { list, clip, shots: shots.size, frames, geo, path: path0 }; @@ -618,8 +682,8 @@ async function shootMap(ctx, { map, layout, box, fps, dir, render, fonts, entry } const q = (f) => `'${f.replace(/'/g, "'\\''")}'`; const lines = ["ffconcat version 1.0"]; - for (const run of runs) lines.push(`file ${q(shots.get(run.key))}`, `duration ${(run.n / fps).toFixed(6)}`); - lines.push(`file ${q(shots.get(runs[runs.length - 1].key))}`); + for (const run of runs) lines.push(`file ${q(shots.get(run.key))}`, ...concatRate(fps), `duration ${(run.n / fps).toFixed(6)}`); + lines.push(`file ${q(shots.get(runs[runs.length - 1].key))}`, ...concatRate(fps)); const list = path.join(mdir, "frames.ffconcat"); await writeFile(list, lines.join("\n") + "\n", "utf8"); return { list, x: Math.round(at.x), y: Math.round(at.y), t0, t3 }; @@ -813,6 +877,26 @@ export async function shootCaptions(browser, entry, { box, render, dir, fonts, p } /** + * WHERE THE CLOCK SITS on a card page with the clock mounted (`size` its box): 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; the follow put back at its start. Null: no card. + * The item's own shot (shootClock) and the join's (the item before's clock, where it sat) place it alike. + */ +async function clockPlaceOn(page, { follow, total, size, k }) { + 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)); + return at; +} + +/** * Each SLAM's FRAMES (post-slam.mjs): on the card page as it is drawn at its * first hit (read-follow's state then), its words measured -- the matched * words' lines and the words read at a hit, which it may not cover, and the @@ -924,8 +1008,8 @@ export async function shootSlams(browser, entry, { box, render, dir, fonts, pare await stateAt(0); const qq = (f) => `'${f.replace(/'/g, "'\\''")}'`; const lines = ["ffconcat version 1.0"]; - for (const r of runs) lines.push(`file ${qq(shots.get(r.key))}`, `duration ${(r.n / fps).toFixed(6)}`); - lines.push(`file ${qq(shots.get(runs[runs.length - 1].key))}`); + for (const r of runs) lines.push(`file ${qq(shots.get(r.key))}`, ...concatRate(fps), `duration ${(r.n / fps).toFixed(6)}`); + lines.push(`file ${qq(shots.get(runs[runs.length - 1].key))}`, ...concatRate(fps)); const list = path.join(sdir, "frames.ffconcat"); await writeFile(list, lines.join("\n") + "\n", "utf8"); out.push({ ...q, list, t0: f0 / fps, t3: f1 / fps, landings: p.span.landings, layout, size, shots: shots.size }); @@ -1007,18 +1091,7 @@ export async function shootClock(browser, entry, { box, render, dir, fonts, pare 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)); + const at = await clockPlaceOn(page, { follow, total, size, k }); if (!at) throw new Error(`${entry.id}: the clock has no card to sit on`); await page.evaluate(() => { const st = document.createElement("style"); @@ -1049,11 +1122,11 @@ export async function shootClock(browser, entry, { box, render, dir, fonts, pare } 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))}`); + runs.forEach((r, i) => lines.push(`file ${q(shots.get(r.key))}`, ...concatRate(fps), `duration ${(r.n / fps).toFixed(6)}`)); + lines.push(`file ${q(shots.get(runs[runs.length - 1].key))}`, ...concatRate(fps)); 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, box: { x: at.x - Math.round(240 * k), y: at.y, width: size.width + Math.round(240 * k), height: size.height } }; + return { list, x: clip.x, y: clip.y, at: { x: at.x, y: at.y }, place: at.place, covers: at.covers, shots: shots.size, box: { x: at.x - Math.round(240 * k), y: at.y, width: size.width + Math.round(240 * k), height: size.height } }; } finally { await ctx.close(); } @@ -1099,6 +1172,12 @@ export function postZoomPlan(entry, render, total = Infinity, schedule = undefin * a cut-level pace changes them without touching the entry) */ export const POST_CAPTION_DRAW_V = 2; +/** + * The join's drawing (in a joined item's key only: an item with no join keeps its key). 2: the item before's card + * dissolves into this one's (never gone at the first frame), its last frame shot whole (its clock, its parent's shot, + * a visit's pointer), the carried post's head drawn as a plain card drew it, this item's clock moving from that one's. + */ +export const POST_JOIN_DRAW_V = 2; export const POST_CLOCK_DRAW_V = 1; /** * A SLAM's drawing and sound (post-slam.mjs): bumped when its look changes. Its @@ -1155,8 +1234,13 @@ export function postSegmentKeyOf({ entry, redaction = null, box, place = [], ren ...(plan.follow ? { follow: plan.follow } : {}), ...(bleeps ? { bleeps } : {}), ...(slursOn(redaction?.slurs) ? { slurs: redaction.slurs } : {}), - ...(from ? { joinFrom: { entry: from.entry, follow: from.plan.follow ?? null, total: from.plan.total, media: from.media.map((x) => [x.m.src, x.t, x.box]), fadeIn: from.fadeIn } } : {}), + // `jv`: the join's drawing (POST_JOIN_DRAW_V) and what the item before showed as it ended beyond its card -- its + // clock (where this one's starts) and its parent's shot. + ...(from ? { joinFrom: { entry: from.entry, follow: from.plan.follow ?? null, total: from.plan.total, media: from.media.map((x) => [x.m.src, x.t, x.box]), fadeIn: from.fadeIn, jv: POST_JOIN_DRAW_V, clock: from.clock ?? null, ...(from.carry ? { carry: from.carry } : {}), ...(Number.isFinite(from.anchorY) ? { anchorY: from.anchorY } : {}) } } : {}), ...(plan.panel ? { panel: plan.panel } : {}), + // Its own attachment entering with his own post (post-item.mjs ownMediaEnterAt): only an item that reads + // something before its post carries it -- every other keeps its key. + ...(plan.enter > 0 ? { enter: { at: plan.enter, fade: POST_ENTER_FADE } } : {}), ...(layout?.panel === "top" || layout?.panel === "bottom" ? { layout: { panel: layout.panel, card: layout.card, slot: layout.slot } } : {}), // A caption, the clock, the pace (post-caption.mjs, post-clock.mjs): nothing for an item with none of them. ...postFxKeyFields(entry, render, prev, { plan, layout }), @@ -1214,10 +1298,24 @@ export async function buildPostSegment(entry, { render, outDir, manifestDir, box const ownBox = firstOwn && layout.slot && layout.mode === "side" ? stepBoxes(plan.steps[0], layout.slot)[0] : null; // The same attachment in the same box (a media scene): held, neither faded. const held = !!firstOwn && ends.length === 1 && ends[0].m.src === firstOwn.src && !!ownBox && Math.abs(ownBox.x - eb[0].x) < 2 && Math.abs(ownBox.y - eb[0].y) < 2 && Math.abs(ownBox.width - eb[0].width) < 2; + // How ITS segment drew the post it carried in (its own join: post-item.mjs joinCarryOf of the item before it) -- + // its page here drawn as it was, never with a carried post of another size (a re-wrapped tile at the first frame). + let carry = null; + const bf = joinFrom.join ? joinFrom.before : null; + if (bf?.entry?.type === "post") { + const be = panelEntry(sceneEntry(censorEntry(bf.entry, redaction), bf.mediaScene ?? null, { censor: (e) => censorEntry(e, redaction) }), render); + carry = joinCarryOf(be, postItemPlan(be, render, { prev: bf.prev ?? null, scene: bf.scene ?? null, mediaScene: bf.scene ? null : bf.mediaScene ?? null, join: bf.join ?? null }), box, render); + } + // Where ITS read opened (its own join's anchor, in its record): its last frame is drawn from the same path. + const prevRec = joinFrom.join ? await readFile(postRecordPath(path.join(outDir, "segments", `${joinFrom.entry.id}.mp4`)), "utf8").then((t) => JSON.parse(t), () => null) : null; from = { - entry: pe, plan: pp, + entry: pe, plan: pp, carry, + anchorY: Number.isFinite(prevRec?.joinAnchor) ? prevRec.joinAnchor : null, + // Its clock (post-clock.mjs) as its own segment runs it: from the clock item before IT. + clock: clockPlan(pe, render, joinFrom.prev ?? null), media: held ? [] : ends.map((x, j) => ({ file: path.resolve(manifestDir, x.m.src), m: x.m, t: x.t, box: eb[j] })), - fadeIn: !held && !!firstOwn, + // Entering with his own post (plan.enter): not faded in over the join -- the item before's goes, the slot waits. + fadeIn: !held && !!firstOwn && !(plan.enter > 0), }; } const files = (entry.media ?? []).map((m) => path.resolve(manifestDir, m.src)); @@ -1236,7 +1334,7 @@ export async function buildPostSegment(entry, { render, outDir, manifestDir, box if (takeFile && !(await stat(takeFile).catch(() => null))) throw new Error(`${entry.id}: its narration take is not on disk: ${takeFile} (${take.file})`); // The slurs its take SAYS, covered (post-slurs.mjs): a public render never plays one -- without word timings it is refused. const bleeps = take ? takeSlurBleeps(entry, take, redaction) : null; - const stamps = await Promise.all([...files, ...panelFiles.flat(), ...(from?.media ?? []).map((x) => x.file), ...wordFiles.filter(Boolean), ...Object.values(avatars), ...(takeFile ? [takeFile] : []), ...(entry.parentShot ? [path.resolve(manifestDir, entry.parentShot)] : [])].map(async (f) => { + const stamps = await Promise.all([...files, ...panelFiles.flat(), ...(from?.media ?? []).map((x) => x.file), ...wordFiles.filter(Boolean), ...Object.values(avatars), ...(takeFile ? [takeFile] : []), ...(entry.parentShot ? [path.resolve(manifestDir, entry.parentShot)] : []), ...(typeof from?.entry?.parentShot === "string" ? [path.resolve(manifestDir, from.entry.parentShot)] : [])].map(async (f) => { const st = await stat(f).catch(() => null); return st ? `${f}:${st.size}:${Math.round(st.mtimeMs)}` : `${f}:-`; })); @@ -1318,7 +1416,7 @@ export async function buildPostSegment(entry, { render, outDir, manifestDir, box // The follow frames are in the segment now: a rebuild shoots them again (they are many, and the key decides). if (cards.follow) await rm(path.dirname(cards.follow.list), { recursive: true, force: true }); // Through a rename: a record `--from` linked in (another take's) is replaced, never written through. - await writeFile(`${record}.tmp`, JSON.stringify({ version: 1, id: entry.id, key, layout: layout.mode, total: plan.total, steps: plan.steps.length, ...(zooms.length ? { zooms: zooms.map((z) => ({ i: z.i, at: z.t, source: z.source, span: z.span, region: z.region, word: z.word })) } : {}), ...(cards.captions?.length ? { captions: cards.captions.map((c) => ({ i: c.i, at: c.t, source: c.source, span: c.span, place: c.placed.place, rel: c.placed.rel, box: { x: c.placed.x, y: c.placed.y, width: c.placed.width, height: c.placed.height }, word: c.placed.word, covers: c.placed.covers, leader: c.placed.leader, ...(c.cutByPan ? { cutByPan: c.cutByPan } : {}) })) } : {}), ...(cards.slams?.length ? { slams: cards.slams.map((sl) => ({ i: sl.i, text: sl.fx.text, at: sl.t, end: sl.end, source: sl.source, landings: sl.landings, span: { t0: sl.span.t0, t2: sl.span.t2, t3: sl.span.t3 }, where: sl.layout.where, box: { x: sl.layout.x, y: sl.layout.y, width: sl.layout.width, height: sl.layout.height }, ...(sl.layout.bar ? { bar: { text: sl.fx.bar, style: sl.fx.barStyle, x: sl.layout.bar.x, y: sl.layout.bar.y, width: sl.layout.bar.width, height: sl.layout.bar.height } } : {}), size: sl.size, covers: sl.layout.covers, sfx: sl.fx.sfx, shots: sl.shots })) } : {}), ...(narration ? { narration: { take: take.file, ...plan.narration, gainDb: narration.gainDb, measured: narration.lufs, ...(bleeps ? { slurs: { mode: bleeps.mode, spans: bleeps.spans } } : {}) } } : {}), ...(cards.follow ? { follow: { blocks: plan.follow.blocks.length, shots: cards.follow.shots, frames: cards.follow.frames, pan: cards.follow.path.segments.length, max: cards.follow.path.max } } : {}) }, null, 2) + "\n", "utf8"); + await writeFile(`${record}.tmp`, JSON.stringify({ version: 1, id: entry.id, key, layout: layout.mode, total: plan.total, steps: plan.steps.length, ...(zooms.length ? { zooms: zooms.map((z) => ({ i: z.i, at: z.t, source: z.source, span: z.span, region: z.region, word: z.word })) } : {}), ...(cards.captions?.length ? { captions: cards.captions.map((c) => ({ i: c.i, at: c.t, source: c.source, span: c.span, place: c.placed.place, rel: c.placed.rel, box: { x: c.placed.x, y: c.placed.y, width: c.placed.width, height: c.placed.height }, word: c.placed.word, covers: c.placed.covers, leader: c.placed.leader, ...(c.cutByPan ? { cutByPan: c.cutByPan } : {}) })) } : {}), ...(cards.slams?.length ? { slams: cards.slams.map((sl) => ({ i: sl.i, text: sl.fx.text, at: sl.t, end: sl.end, source: sl.source, landings: sl.landings, span: { t0: sl.span.t0, t2: sl.span.t2, t3: sl.span.t3 }, where: sl.layout.where, box: { x: sl.layout.x, y: sl.layout.y, width: sl.layout.width, height: sl.layout.height }, ...(sl.layout.bar ? { bar: { text: sl.fx.bar, style: sl.fx.barStyle, x: sl.layout.bar.x, y: sl.layout.bar.y, width: sl.layout.bar.width, height: sl.layout.bar.height } } : {}), size: sl.size, covers: sl.layout.covers, sfx: sl.fx.sfx, shots: sl.shots })) } : {}), ...(narration ? { narration: { take: take.file, ...plan.narration, gainDb: narration.gainDb, measured: narration.lufs, ...(bleeps ? { slurs: { mode: bleeps.mode, spans: bleeps.spans } } : {}) } } : {}), ...(cards.follow ? { follow: { blocks: plan.follow.blocks.length, shots: cards.follow.shots, frames: cards.follow.frames, pan: cards.follow.path.segments.length, max: cards.follow.path.max } } : {}), ...(Number.isFinite(cards.joinAnchor) ? { joinAnchor: cards.joinAnchor } : {}) }, null, 2) + "\n", "utf8"); await rename(`${record}.tmp`, record); if (pool) await poolPut(pool, "post", key, { "seg.mp4": seg, "post.json": record }); emit("note", {