Archilyzer · Source

archilyzer

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

commit eccf6e1358fa7f9c94cf1df6bba18b41ddfbb992
parent 031df858f4f77d9d8a1c2ab272200ce303f9f171
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed,  4 Nov 2026 20:17:34 -0500

umtool: an item's own attachments come in with its own post -- in a threaded read that reads a parent, a quote or a linked post first, they enter at his post's first part (ownMediaEnterAt): the slot shows that piece's context media or nothing until then, his attachment crossfades in there (0.3 s), a video starts there (its offset and sound from that moment, its trim fitted to what is left); an item that reads only its post, or past the first of a media scene, is as before; posts set-item media.<i>.enter=post|item; only an item that enters later carries `enter` in its key; Play and the bench lay it the same (operator, 4 Nov, mid-11 ~15:58: "the mr. obvious gif should come in when his post does rather than during the strawb megathread reading")

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

Diffstat:
Mumtool/components/projects/review/PostItemPlayer.tsx | 12+++++++++---
Mumtool/docs/cli.md | 2+-
Mumtool/docs/report-video.md | 11+++++++++++
Mumtool/lib/report/manifest.mjs | 2+-
Mumtool/lib/report/postsCli.mjs | 12++++++++----
Mumtool/report-to-video/post-item.mjs | 43++++++++++++++++++++++++++++++++++++++-----
Aumtool/report-to-video/post-media-enter.test.mjs | 81+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/report-to-video/post-render.mjs | 19+++++++++++++------
8 files changed, 162 insertions(+), 20 deletions(-)

diff --git a/umtool/components/projects/review/PostItemPlayer.tsx b/umtool/components/projects/review/PostItemPlayer.tsx @@ -1,7 +1,7 @@ "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 { 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"; @@ -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; @@ -563,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. @@ -1075,7 +1081,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 @@ -84,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 @@ -1206,6 +1206,17 @@ counts, its quote, its clock -- vanished at once, and the carried head (the word 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 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/post-item.mjs b/umtool/report-to-video/post-item.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; 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, joinCarryOf, 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"; @@ -212,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]; @@ -242,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); @@ -1228,6 +1231,9 @@ export function postSegmentKeyOf({ entry, redaction = null, box, place = [], ren // 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 }), @@ -1301,7 +1307,8 @@ export async function buildPostSegment(entry, { render, outDir, manifestDir, box // 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));