Archilyzer · Source

archilyzer

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

commit bf7e2880d9b0d341d3aa7ea5609b47286441924c
parent 551612ddad997e8a93036d0519261e516e13fcb2
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed,  4 Nov 2026 19:56:43 -0500

umtool: the item before's page in a join's shot is drawn with ITS own join (joinCarryOf: how its segment drew the post it carried in -- shared with Play's route), never with a carried post of another size (mid-7's thread joins opened on a re-wrapped tile); frames lists read each shot at the item's rate (ffconcat `option framerate`: the image demuxer's 1/25 s clock dropped one shot in six and held its neighbour -- every pan, join and clock run juddered); check-joins judges the EDGE over the two cards only (the frames around the boundary, over what the item before was already moving: a video playing), the SSIM shown, not judged

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

Diffstat:
Mumtool/app/api/report/post-item/route.ts | 14+++-----------
Mumtool/docs/report-video.md | 9++++++---
Mumtool/report-to-video/build-video.mjs | 10+++++++---
Mumtool/report-to-video/check-joins.mjs | 62+++++++++++++++++++++++++++++++++++++++++++++++++++-----------
Mumtool/report-to-video/check-joins.test.mjs | 18+++++++++++++++---
Mumtool/report-to-video/post-item.mjs | 19++++++++++++++++++-
Mumtool/report-to-video/post-join-continuity.test.mjs | 21+++++++++++++++++++--
Mumtool/report-to-video/post-render.mjs | 35+++++++++++++++++++++++++----------
8 files changed, 144 insertions(+), 44 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,18 +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 }; } -/** - * How the item before draws its post: its words' size (post-item.mjs cardWordsSize; threaded when its plan is) and - * whether its card is PLAIN (no thread: its head the card's, the carried post drawn with it -- the build's measure), - * else the size its head is drawn at (its words box's). - */ +/** 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 } }; - const threaded = follow && !!plan.follow?.thread; - // A threaded card's head is at its words box's size (cardWordsSize unthreaded: the box, not the post's tile). - return { size: cardWordsSize(pe, box, { follow, threaded }), plain: !threaded, headSize: threaded ? cardWordsSize(pe, box, { follow }) : null }; + 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). */ diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md @@ -1064,9 +1064,12 @@ before ran, so a changed join rebuilds; an item with no join keeps its key. **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, the SSIM of the last frame before -against the first after over the post box (the deck strip left out), and the largest frame-to-frame step across it and -its join -- worst first; `JUMPS` is a planned join whose frames still jump (SSIM < 0.97, or one frame-to-frame step 3 above its neighbours). The boundary is +(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. diff --git a/umtool/report-to-video/build-video.mjs b/umtool/report-to-video/build-video.mjs @@ -218,13 +218,17 @@ import { snap } from "./snap.mjs"; import { buildPostSegment } from "./post-render.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 @@ -3,9 +3,16 @@ // 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 post box -- the deck strip and the rest of the chrome left out: +// (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: // -// ssim the item before's last frame against the next item's first (1: the same picture) +// 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 @@ -24,7 +31,7 @@ import path from "node:path"; import { promisify } from "node:util"; import { chainOf, planContext } from "./post-conversation.mjs"; -import { linksOf, parentsOf } from "./post-item.mjs"; +import { linksOf, panelEntry, parentsOf, postLayout } from "./post-item.mjs"; import { groupOf, shownIdOf } from "./post-thread.mjs"; const execFileP = promisify(execFile); @@ -34,7 +41,7 @@ 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({ ssim: 0.97, jump: 3 }); +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 @@ -135,26 +142,27 @@ export function parseFrameMeta(text, key) { /** The verdict of one measured boundary: "join" (it moved on smoothly), "cut" (a step), "planned cut". */ export function joinVerdict(row) { - const bad = (fin(row.ssim) && row.ssim < JOIN_CHECK.ssim) || (fin(row.jump) && row.jump > JOIN_CHECK.jump); + 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 lowest SSIM, then the biggest jump. */ +/** Worst first: the biggest edge, then the lowest SSIM. */ export function rankJoins(rows) { - const score = (r) => (fin(r.ssim) ? r.ssim : 1) - (fin(r.jump) ? r.jump / 255 : 0); + 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", "ssim", "jump", "verdict"]; + 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), @@ -168,6 +176,22 @@ export function joinsTable(rows) { // 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 { @@ -200,7 +224,19 @@ export async function measureBoundary(master, t, { box, fps = 30, join = null, f 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 { ssim: m ? Number(m[1]) : null, jump: r3(j.jump), jumpAt: r3(from + j.t), peak: r3(j.peak) }; + 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)); } /** @@ -241,8 +277,12 @@ export async function checkJoins(takeDir, { all = false, ffmpeg = "ffmpeg", ffpr 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]; - const m = await measureBoundary(master, t, { box, fps, join: r.join, ffmpeg }); - const row = { ...r, t, box, ...m }; + // 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); diff --git a/umtool/report-to-video/check-joins.test.mjs b/umtool/report-to-video/check-joins.test.mjs @@ -2,7 +2,7 @@ import assert from "node:assert/strict"; import { test } from "node:test"; -import { concatFiles, joinBoundaries, jumpOf, joinRelation, joinVerdict, joinsTable, masterStarts, parseFrameMeta, postsDrawnBy, rankJoins } from "./check-joins.mjs"; +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 } }); @@ -30,10 +30,22 @@ test("CHECK JOINS: the boundaries where the next item draws a post the one befor // 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); - const measured = [{ from: "a", to: "b", shared: ["1"], relation: "self-reply", join: 0.6, t: 1, ssim: 0.79, jump: 10.7 }, { from: "c", to: "d", shared: ["2"], relation: "manual thread", join: 0.6, t: 2, ssim: 0.998, jump: 1.2 }]; + // 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+0\.790\s+10\.7\s+JUMPS/); + 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/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"; @@ -1267,6 +1267,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 @@ -6,8 +6,8 @@ import assert from "node:assert/strict"; import { test } from "node:test"; import { JOIN_CLOCK_NEAR, joinClockOf, joinFrameAt, joinOpacities } from "./post-join.mjs"; -import { clockJoinExpr, postSegmentArgs, postSegmentKey, postSegmentKeyOf, POST_JOIN_DRAW_V } from "./post-render.mjs"; -import { postCardHtml, postItemPlan } from "./post-item.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`; @@ -91,3 +91,20 @@ test("THE KEY: a joined item's key carries the join's drawing and the clock the 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-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_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"; @@ -408,7 +408,7 @@ export async function renderPostCards(entry, { box, render, dir, manifestDir, la const pe = joinFrom.entry; const pf = joinFrom.plan?.follow ?? null; 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 }); + 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" }); @@ -524,6 +524,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 @@ -569,8 +576,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 }; @@ -624,8 +631,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 }; @@ -891,8 +898,8 @@ 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, 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 } }; @@ -988,7 +995,7 @@ export function postSegmentKeyOf({ entry, redaction = null, box, place = [], ren ...(slursOn(redaction?.slurs) ? { slurs: redaction.slurs } : {}), // `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 ? { 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 } : {}) } } : {}), ...(plan.panel ? { panel: plan.panel } : {}), ...(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. @@ -1047,8 +1054,16 @@ 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); + } from = { - entry: pe, plan: pp, + entry: pe, plan: pp, carry, // 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] })),