Archilyzer · Source

archilyzer

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

commit d1a8d207d1c03b4dc81606171893f19db54dbfa0
parent 7d16b6689bb5c0653fcf5ab6c261127b426e1d29
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Mon,  9 Nov 2026 23:28:10 -0500

umtool: the 9:16 end card, a vertical take's preview 9:16, stacked shorts cut from the built cut, Play lays a post as its hero card

- outro.mjs: a vertical outro with somewhere to go is the end card (EndCard.dc.html) -- "EVERY CLIP, IN FULL" over
  the title, the archive's link as a large QR with "Scan or search", its host and the call to action, the short's
  sources (date, channel, time; three, then "+ N more in the archive"), the site's name at the foot of the safe
  area. umtool vertical passes it the take's qrLink/siteOrigin and its sources (the stacked schedule's vsource).
- takePreview previewKnobs: a vertical cut previews 720x1280, never squashed into the 16:9 tier.
- reframe assembleShort: a stacked deck's pieces are cut from the built cut at the build's places (its segments
  are the picture alone); a bare short is joined from its segments as before.
- Play the cut: a post item of a stacked deck in its hero box (deckGeometry `post`).
- e2e: vertical-deck-fixture (the measured Play cut, format vertical) and vertical-deck.spec.ts.

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

Diffstat:
Mumtool/components/projects/OnscreenSection.tsx | 2+-
Mumtool/components/projects/review/PlayCut.tsx | 17+++++++++++------
Mumtool/docs/knobs.md | 8+++++++-
Mumtool/e2e/fixtures/make-fixture.mjs | 10++++++++++
Mumtool/e2e/fixtures/measure-extras-fixture.mjs | 6++++--
Aumtool/e2e/vertical-deck.spec.ts | 113+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/lib/report/takePreview.mjs | 9++++++---
Mumtool/lib/report/takePreview.test.mjs | 2++
Mumtool/lib/report/verticalCli.mjs | 14+++++++++++++-
Mumtool/report-to-video/deck.mjs | 2++
Mumtool/report-to-video/outro.mjs | 195++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
Mumtool/report-to-video/outro.test.mjs | 63+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/report-to-video/reel-intro.mjs | 10+++++++---
Mumtool/report-to-video/reframe.mjs | 14++++++++++----
14 files changed, 437 insertions(+), 28 deletions(-)

diff --git a/umtool/components/projects/OnscreenSection.tsx b/umtool/components/projects/OnscreenSection.tsx @@ -51,7 +51,7 @@ import { deckChrome } from "@/lib/report/chain-draft.mjs"; // ---- the composition's contract, as this page reads it -------------------- export type Rect = { x: number; y: number; width: number; height: number }; -export type DeckGeometry = { W: number; H: number; footage: Rect; deck: Rect }; +export type DeckGeometry = { W: number; H: number; footage: Rect; deck: Rect; post?: Rect }; export type DeckSegment = { id: string; type: string; diff --git a/umtool/components/projects/review/PlayCut.tsx b/umtool/components/projects/review/PlayCut.tsx @@ -1246,12 +1246,17 @@ export default function PlayCut({ <div className="absolute inset-0" style={{ background: bg }} /> {footageCanvas(rect ? { left: pct(rect.x, g.W), top: pct(rect.y, g.H), width: pct(rect.width, g.W), height: pct(rect.height, g.H) } : undefined, box.width, box.height)} {videoUnder} - {postNow && rect && ( - <div className="absolute" style={{ left: pct(rect.x, g.W), top: pct(rect.y, g.H), width: pct(rect.width, g.W), height: pct(rect.height, g.H), background: bg }}> - {postPlayer({ width: box.width, height: box.height })} - {comboBadge({ width: box.width, height: box.height })} - </div> - )} + {postNow && (g.post ?? rect) && (() => { + // The stacked vertical deck lays a post item as its hero card (deck.mjs deckGeometry `post`). + const pr = g.post ?? rect!; + const pb = g.post ?? box; + return ( + <div className="absolute" style={{ left: pct(pr.x, g.W), top: pct(pr.y, g.H), width: pct(pr.width, g.W), height: pct(pr.height, g.H), background: bg }}> + {postPlayer({ width: pb.width, height: pb.height })} + {comboBadge({ width: pb.width, height: pb.height })} + </div> + ); + })()} {teaserCard} {introCard} {placeholderCard} diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -1715,7 +1715,13 @@ keeps it. With the popups left out, a clip that carries posts is not held for th a frozen frame with nothing over it), and nothing moves the picture; every other second is the landscape cut's. Play the cut plays a vertical cut's deck 9:16 (its player sized for the tall frame): the same pages, composed for -preview. Present is the landscape one. +preview. Present is the landscape one. A take's `--preview` of a vertical cut is 9:16 too (720x1280, `render.preview`). + +A reel's **outro in 9:16 is the end card** (`outro.mjs`): over its title "EVERY CLIP, IN FULL", the archive's link as a +large QR (`provenance.qrLink`, else `siteOrigin`) with "Scan or search", its host and the call to action beside it, +the short's sources -- each clip's date, channel and the time it is from, three of them, then "+ N more in the +archive" -- and the site's name at the foot of the safe area. A short of a stacked deck cut cuts its pieces from the +built cut (deck and all), not from its bare segments. **720p.** A deck cut rendered 1280x720 (`render.width`/`height`) has its band scaled with the frame's height -- its height, the title, the QR, the pips (`deck.mjs` `deckScale`) -- so `deck.footageScale` 0.82 fits as at 1080 (it was diff --git a/umtool/e2e/fixtures/make-fixture.mjs b/umtool/e2e/fixtures/make-fixture.mjs @@ -2109,6 +2109,16 @@ await makeMeasureExtrasFixture({ deck: { dial: true, odometer: true, trail: true, goals: false, peak: false, promise: false, diet: false, streak: false }, }); +// THE STACKED VERTICAL DECK (vertical-deck.spec.ts, lane L10): the same measured cut rendered 9:16 with its deck kept +// (render.format vertical; render.vertical.deck absent = stacked) -- the rail, the instruments' panel, the source +// line and its QR in Play the cut. READ-ONLY. +await makeMeasureExtrasFixture({ + reports, deckManifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), + name: "vertical-deck-fixture", title: "The Vertical Deck Fixture", + deck: { dial: true, odometer: true, trail: true, goals: false, peak: false, promise: false, diet: false, streak: false, markers: [{ after: "c02", label: "Carnivore" }], sectionTitle: { first: "Keto" } }, + render: { format: "vertical" }, +}); + // Wrong speaker in Play the cut (play-modules.spec.ts), which WRITES (removes c02, then undoes): // its own copy, so no other spec's cut moves under it. makePlayCutFixture({ reports, deckManifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), name: "play-wrong-fixture", title: "The Play Wrong Speaker Fixture" }); diff --git a/umtool/e2e/fixtures/measure-extras-fixture.mjs b/umtool/e2e/fixtures/measure-extras-fixture.mjs @@ -48,11 +48,11 @@ export const MEASURE_LEDGER = [ ]; /** - * @param {{ reports: string, deckManifest: Function, cachedWindow: string, name?: string, title?: string, deck?: Record<string, any> }} o + * @param {{ reports: string, deckManifest: Function, cachedWindow: string, name?: string, title?: string, deck?: Record<string, any>, render?: Record<string, any> | null }} o * `name`/`title`/`deck`: another copy with more deck keys (play-instruments-fixture: the dial, the odometer and * the trail on, the extras off -- instruments.spec.ts). */ -export async function makeMeasureExtrasFixture({ reports, deckManifest, cachedWindow, name = "play-measure-fixture", title = "The Play Measure Fixture", deck = {} }) { +export async function makeMeasureExtrasFixture({ reports, deckManifest, cachedWindow, name = "play-measure-fixture", title = "The Play Measure Fixture", deck = {}, render = null }) { const { dir } = makePlayCutFixture({ reports, deckManifest, cachedWindow, name, title, chrome: { @@ -70,6 +70,8 @@ export async function makeMeasureExtrasFixture({ reports, deckManifest, cachedWi promise: { label: "scale video" }, ...deck, }; + // More render keys (vertical-deck-fixture: format vertical, the stacked deck). + if (render) m.render = { ...m.render, ...render }; writeFileSync(file, JSON.stringify(m, null, 2) + "\n"); return { dir }; } diff --git a/umtool/e2e/vertical-deck.spec.ts b/umtool/e2e/vertical-deck.spec.ts @@ -0,0 +1,113 @@ +import { test, expect, type Page } from "@playwright/test"; +import * as urls from "./urls"; + +// --------------------------------------------------------------------------- +// THE STACKED VERTICAL DECK (umtool/docs/knobs.md, "The vertical deck"; lane +// L10): a 9:16 cut that has a deck keeps it -- the landscape cut's schedule and +// pages laid in another geometry (report-to-video/vertical-deck.mjs). Play the +// cut plays it: the deck's own page over the whole 1080x1920 frame (the rail +// with its section and progress, each clip's source block and its QR), the +// footage at the frame's full width, the instruments' pages in their panel. +// +// Fixture: e2e/fixtures/measure-extras-fixture.mjs as vertical-deck-fixture -- +// play-measure-fixture's cut with the dial, the odometer and the trail on (the +// extras off), a marker after c02 ("Carnivore"; "Keto" before it) and +// render.format "vertical" (render.vertical.deck absent: stacked). READ-ONLY. +// --------------------------------------------------------------------------- + +const PROJECT = "reports/vertical-deck-fixture"; +const INSTRUMENTS = ["dial", "odometer", "trail"] as const; + +type Rect = { x: number; y: number; width: number; height: number }; +type Layer = { id: string; region?: string; geometry?: Rect | null; src?: string; error?: string }; + +const root = (page: Page) => page.locator("[data-play-cut]"); +const deck = (page: Page) => page.frameLocator('[data-testid="play-deck-iframe"]'); + +/** The words of the deck page's blocks that are on screen under `sel` (visible, opacity over a half). */ +const shown = (page: Page, sel: string) => + deck(page) + .locator(sel) + .evaluateAll((els) => + els + .filter((e) => { + let n: Element | null = e; + while (n && n instanceof HTMLElement) { + const cs = getComputedStyle(n); + if (cs.visibility === "hidden" || Number(cs.opacity) < 0.5 || cs.display === "none") return false; + n = n.parentElement; + } + return true; + }) + .map((e) => (e.textContent ?? "").replace(/\s+/g, " ").trim()), + ); + +test.beforeEach(() => { + test.setTimeout(150_000); +}); + +test("the chrome preview of a vertical cut is the stacked deck: 9:16, the picture at full width, the instruments in the panel", async ({ request }) => { + const res = await request.post("/api/report/chrome/preview", { data: { project: PROJECT, estimate: true } }); + expect(res.ok(), await res.text()).toBeTruthy(); + const doc = (await res.json()) as { geometry: { W: number; H: number; footage: Rect; deck: Rect }; layers: Layer[]; posts: { windows: unknown[] } }; + expect(doc.geometry.W).toBe(1080); + expect(doc.geometry.H).toBe(1920); + expect(doc.geometry.footage.width).toBe(1080); + expect(doc.geometry.deck).toEqual({ x: 0, y: 0, width: 1080, height: 1920 }); + expect(doc.posts.windows).toEqual([]); + const by = Object.fromEntries(doc.layers.map((l) => [l.id, l])); + // The safe area: the top 8 %, the bottom 20 %, the right 12 % kept clear. + for (const id of INSTRUMENTS) { + const g = by[id]?.geometry; + expect(g, `${id} is a play layer`).toBeTruthy(); + expect(by[id].src, by[id].error).toBeTruthy(); + expect(g!.y).toBeGreaterThanOrEqual(1920 * 0.08); + expect(g!.y + g!.height).toBeLessThanOrEqual(1920 * 0.8); + expect(g!.x + g!.width).toBeLessThanOrEqual(1080 * 0.88 + 1); + // Under the picture. + expect(g!.y).toBeGreaterThanOrEqual(doc.geometry.footage.y + doc.geometry.footage.height); + } + // The dial the left column's height, the odometer and the trail down the right. + expect(by.dial.geometry!.x).toBeLessThan(by.odometer.geometry!.x); + expect(by.trail.geometry!.y).toBeGreaterThan(by.odometer.geometry!.y); +}); + +test("Play the cut plays the stacked deck: the rail's section and progress, the source line and its QR, the instruments", async ({ page }) => { + await page.setViewportSize({ width: 1366, height: 1000 }); + await page.goto(urls.playHref(PROJECT, { clip: "c04", at: 1 })); + await expect(root(page)).toHaveAttribute("data-play-edges", "render", { timeout: 30_000 }); + await expect(page.getByTestId("play-deck")).toBeVisible({ timeout: 30_000 }); + await expect(page.getByTestId("play-deck")).toHaveAttribute("data-deck-ready", "1", { timeout: 30_000 }); + await expect(page.locator("[data-play-tall]")).toHaveCount(1); + // The frame is tall: 9:16. + const box = await page.getByTestId("play-deck").boundingBox(); + expect(box).toBeTruthy(); + expect(Math.abs(box!.height / box!.width - 1920 / 1080)).toBeLessThan(0.02); + await expect(root(page)).toHaveAttribute("data-play-item", "c04"); + + // The rail: c04 is in the second section, its name up and "2 / 2" beside it. + await expect.poll(() => shown(page, ".rail .rlab"), { timeout: 10_000 }).toEqual(["Carnivore"]); + expect(await shown(page, ".rail .rcount")).toEqual(["2 / 2"]); + // The source block: the clip's QR beside its channel, title, date and time. + const src = deck(page).locator(".src").filter({ has: deck(page).locator("img.qr") }); + expect(await src.count()).toBeGreaterThan(0); + const blocks = await shown(page, ".src"); + expect(blocks.length).toBe(1); + expect(blocks[0]).toMatch(/\d+:\d{2}/); + // The tally's row (the cut counts its claims). + expect((await shown(page, ".tally")).length).toBe(1); + + // The instruments, each its page in the panel, up and ready. + for (const id of INSTRUMENTS) { + await expect(page.locator(`[data-play-layer="${id}"]`)).toHaveAttribute("data-play-layer-up", "1", { timeout: 30_000 }); + await expect(page.getByTestId(`play-layer-${id}`)).toHaveAttribute("data-feed-ready", "1", { timeout: 30_000 }); + } + await page.screenshot({ path: test.info().outputPath("vertical-deck-c04.png") }); + + // Back into the first section: its name on the rail. + await page.goto(urls.playHref(PROJECT, { clip: "c01", at: 0.5 })); + await expect(page.getByTestId("play-deck")).toHaveAttribute("data-deck-ready", "1", { timeout: 30_000 }); + await expect.poll(() => shown(page, ".rail .rlab"), { timeout: 10_000 }).toEqual(["Keto"]); + expect(await shown(page, ".rail .rcount")).toEqual(["1 / 2"]); + await page.screenshot({ path: test.info().outputPath("vertical-deck-c01.png") }); +}); diff --git a/umtool/lib/report/takePreview.mjs b/umtool/lib/report/takePreview.mjs @@ -68,9 +68,12 @@ const X264_PRESETS = ["ultrafast", "superfast", "veryfast", "faster", "fast", "m export function previewKnobs(render = {}) { const raw = render?.preview; if (raw !== undefined && raw !== null && !isObj(raw)) throw new Error("render.preview is an object: { width, height, preset, crf, segments }"); - const k = { ...PREVIEW_DEFAULTS, ...(isObj(raw) ? raw : {}) }; - const W = Number(render?.width ?? 1920); - const H = Number(render?.height ?? 1080); + // A 9:16 cut (`render.format: "vertical"`, built 1080x1920 whatever its width and height say) previews 9:16: + // the defaults turned on their side, never squashed into a 16:9 tier (lane vertical-deck). + const vertical = render?.format === "vertical"; + const k = { ...PREVIEW_DEFAULTS, ...(vertical ? { width: PREVIEW_DEFAULTS.height, height: PREVIEW_DEFAULTS.width } : {}), ...(isObj(raw) ? raw : {}) }; + const W = vertical ? 1080 : Number(render?.width ?? 1920); + const H = vertical ? 1920 : Number(render?.height ?? 1080); let width = Math.round(Number(k.width)); let height = Math.round(Number(k.height)); if (!Number.isFinite(width) || width < 16 || !Number.isFinite(height) || height < 16) throw new Error(`render.preview: width and height are pixels (≥ 16), got ${JSON.stringify(raw)}`); diff --git a/umtool/lib/report/takePreview.test.mjs b/umtool/lib/report/takePreview.test.mjs @@ -16,6 +16,8 @@ test("previewKnobs: the defaults, a knob over them, never larger than the cut, c assert.deepEqual(previewKnobs({ ...R, preview: { width: 960, height: 540, crf: 30 } }), { width: 960, height: 540, preset: "veryfast", crf: 30, segments: "shared" }); // A 640x360 cut previews at its own size. assert.deepEqual(previewKnobs({ ...R, width: 640, height: 360 }).width, 640); + // A 9:16 cut previews 9:16 (lane vertical-deck): built 1080x1920 whatever its width and height say. + assert.deepEqual(previewKnobs({ ...R, format: "vertical" }), { ...PREVIEW_DEFAULTS, width: 720, height: 1280 }); assert.deepEqual(previewKnobs({ ...R, width: 640, height: 360 }).height, 360); assert.throws(() => previewKnobs({ ...R, preview: { preset: "warp" } }), /x264 preset/); assert.throws(() => previewKnobs({ ...R, preview: { crf: 99 } }), /0–51/); diff --git a/umtool/lib/report/verticalCli.mjs b/umtool/lib/report/verticalCli.mjs @@ -246,6 +246,10 @@ export async function verticalCommand(args, { reportsRoot = REPORTS_ROOT, log = const RF = await import("umtool-report-to-video/reframe"); made = await RF.assembleShort({ pieces: plan.pieces, segmentsDir: path.join(outDir, work, "segments"), built, outFile, + // A stacked vertical deck's pieces are cut from the built cut (its deck laid over it), at the build's places. + schedule: V.stackedDeckWanted({ ...(takeManifest.render ?? {}), format: "vertical", vertical: { ...(takeManifest.render?.vertical ?? {}), ...knobs } }) + ? await readJson(path.join(outDir, work, "schedule.json")) + : null, render: { ...takeManifest.render, vertical: { ...(takeManifest.render?.vertical ?? {}), ...knobs } }, log: say, }); } @@ -255,9 +259,17 @@ export async function verticalCommand(args, { reportsRoot = REPORTS_ROOT, log = const { wrapShort } = await import("umtool-report-to-video/reel-intro"); const RF = await import("umtool-report-to-video/reframe"); const slot = await heavySlot(); + // The 9:16 end card (outro.mjs): the archive's link as a QR, and the short's sources -- each clip's date, + // channel and time, from the stacked deck's schedule when it has one. + const { endCardSources } = await import("umtool-report-to-video/outro"); + const prov = takeManifest.provenance ?? {}; + const endCard = { + qrUrl: prov.qrLink ?? prov.siteOrigin ?? null, + sources: endCardSources(plan.timeline, reframe || landscape ? null : await readJson(path.join(outDir, `vertical-${name}-${tag}`, "schedule.json"))), + }; wrapped = await slot(["umtool", "vertical", r.project.id, "--take", take, ...(reel ? ["--reel", reel] : []), "(intro/outro)"], () => wrapShort({ file: outFile, takeDir, render: takeManifest.render ?? {}, manifest: takeManifest, introSpec, outro, - xfade: typeof reelSettings.xfade === "number" ? reelSettings.xfade : 0.3, log: say, + xfade: typeof reelSettings.xfade === "number" ? reelSettings.xfade : 0.3, log: say, endCard, })); made = { ...made, seconds: await RF.probeSeconds(outFile) }; } diff --git a/umtool/report-to-video/deck.mjs b/umtool/report-to-video/deck.mjs @@ -492,6 +492,8 @@ export function deckGeometry(render) { footage: { ...g.picture }, deck: { x: 0, y: 0, width: W, height: H }, ...(resolveShelf(render) ? { shelf: { ...g.shelf } } : {}), + // A post item's hero card (the build frames it there: stackedPostFraming), for Play the cut to lay it in. + post: { ...g.post.card }, stacked: true, }; } diff --git a/umtool/report-to-video/outro.mjs b/umtool/report-to-video/outro.mjs @@ -170,10 +170,10 @@ const span = (text, { px, color, face }) => `<span font_desc="${face}" size="${M const magickOpts = { maxBuffer: 1 << 24, env: { ...process.env, FONTCONFIG_FILE } }; /** Pango markup -> a transparent PNG centred lines wrapped at `width`; its size. */ -async function textPng(markup, file, width) { +async function textPng(markup, file, width, align = "center") { const markupPath = file.replace(/\.png$/, ".pango"); await writeFile(markupPath, markup, "utf8"); - const args = ["-background", "none", "-define", "pango:align=center"]; + const args = ["-background", "none", "-define", `pango:align=${align}`]; if (width) args.push("-size", `${Math.round(width)}x`, "-define", "pango:wrap=word"); args.push(`pango:@${markupPath}`, "-trim", "+repage", file); await execFileP("magick", args, magickOpts); @@ -186,11 +186,105 @@ async function textPng(markup, file, width) { export const OUTRO_COLOURS = Object.freeze({ ground: "#151b20", ink: "#f6f1e6", muted: "#a9b4bc" }); /** - * The card's key: everything drawn (the words, the size, the image's bytes, the brand). + * The card's key: everything drawn (the words, the size, the image's bytes, the brand; a 9:16 end card's QR, + * host and sources). * @param {object} o */ -export function outroKey({ width, height, title, text, imageSha = null, brand }) { - return createHash("sha256").update(JSON.stringify({ v: 1, width, height, title, text, imageSha, brand })).digest("hex").slice(0, 20); +export function outroKey({ width, height, title, text, imageSha = null, brand, end = null }) { + return createHash("sha256").update(JSON.stringify({ v: 1, width, height, title, text, imageSha, brand, ...(end ? { end } : {}) })).digest("hex").slice(0, 20); +} + +// --------------------------------------------------------------------------- +// THE 9:16 END CARD (lane vertical-deck, out/vertical-design EndCard): a vertical outro with somewhere to go -- +// its QR large, "scan or search" and the archive's host beside it, the cut's sources listed (each its date, its +// channel and the time it is from; the rest counted), the site's name at the foot. The same card, more on it. +// --------------------------------------------------------------------------- + +/** How many sources the end card lists before it counts the rest. */ +export const END_CARD_SOURCES = 3; + +/** The end card's words over its title. */ +export const END_CARD_KICKER = "EVERY CLIP, IN FULL"; + +const MONTHS_SHORT = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; + +/** "2026-01-12" or "Jan 12, 2026" as the list's date ("Jan 12"); anything else as it is. */ +export function endCardDate(d) { + const s = String(d ?? "").trim(); + const iso = /^(\d{4})-(\d{2})-(\d{2})/.exec(s); + if (iso) return `${MONTHS_SHORT[Number(iso[2]) - 1]} ${Number(iso[3])}`; + const long = /^([A-Z][a-z]{2}) (\d{1,2}), \d{4}$/.exec(s); + return long ? `${long[1]} ${long[2]}` : s; +} + +/** + * The sources an end card lists: each clip of `timeline` once (by video), in order -- its date, its channel and + * the time it is from, from the build's schedule (a stacked deck's `vsource`) else what the entry says of itself. + * Pure. + * + * @param {Array<Record<string, any>>} timeline + * @param {{ segments?: Array<Record<string, any>> } | null} [schedule] + * @returns {Array<{ date: string, label: string }>} + */ +export function endCardSources(timeline, schedule = null) { + const bySeg = new Map((Array.isArray(schedule?.segments) ? schedule.segments : []).map((x) => [x.id, x])); + const seen = new Set(); + const out = []; + for (const e of Array.isArray(timeline) ? timeline : []) { + if (e?.type !== "clip") continue; + const key = String(e.video ?? e.id); + if (seen.has(key)) continue; + seen.add(key); + const v = bySeg.get(e.id)?.vsource ?? bySeg.get(String(e.id).replace(/~\d+$/, ""))?.vsource ?? null; + const channel = String(v?.channel ?? e.channelTitle ?? "").trim(); + const at = Number(e.cite ?? e.start); + const clock = v?.clock ?? (Number.isFinite(at) ? hmsOf(at) : ""); + const label = [channel, clock].filter(Boolean).join(" · "); + if (!label) continue; + out.push({ date: endCardDate(v?.date ?? e.date ?? ""), label }); + } + return out; +} + +function hmsOf(total) { + const s = Math.floor(Math.max(0, total)); + const h = Math.floor(s / 3600); + const m = Math.floor((s % 3600) / 60); + const x = s % 60; + return h > 0 ? `${h}:${String(m).padStart(2, "0")}:${String(x).padStart(2, "0")}` : `${m}:${String(x).padStart(2, "0")}`; +} + +/** The archive's host as the card says it ("https://jeralyzer.pages.dev/x" → "jeralyzer.pages.dev"), or "". */ +export function endCardHost(url) { + try { + return new URL(String(url ?? "")).hostname; + } catch { + return ""; + } +} + +/** + * Where the 9:16 end card's parts go, px (the mockup's at 1080x1920): inside the safe area, top to bottom -- the + * kicker and the title, the QR and its words beside it, the sources, the wordmark. Pure. + * + * @param {{ width: number, height: number }} size + */ +export function endCardLayout({ width: W, height: H }) { + const u = W / 1080; + const box = { + x0: Math.round(W * 0.05), x1: Math.round(W * (1 - VERTICAL_SAFE.right)), + y0: Math.round(H * VERTICAL_SAFE.top), y1: Math.round(H * (1 - VERTICAL_SAFE.bottom)), + }; + const qr = Math.round(450 * u); + return { + box, u, + kicker: { px: Math.round(34 * u), y: box.y0 + Math.round(34 * u) }, + title: { px: [64, 58, 52, 46].map((p) => Math.round(p * u)), lines: 3, gap: Math.round(18 * u) }, + qr: { size: qr, pad: Math.round(28 * u), radius: Math.round(26 * u) }, + side: { gap: Math.round(32 * u), headPx: Math.round(36 * u), hostPx: Math.round(30 * u), textPx: Math.round(28 * u) }, + list: { px: Math.round(32 * u), row: Math.round(54 * u), dateW: Math.round(140 * u), gap: Math.round(40 * u) }, + brandPx: Math.round(46 * u), + }; } /** @@ -202,12 +296,14 @@ export function outroKey({ width, height, title, text, imageSha = null, brand }) * brand: { name: string, lead?: string, ink: string }, dir: string }} o * @returns {Promise<{ file: string, key: string, cached: boolean, layout: ReturnType<typeof outroLayout>, placed: Record<string, { x: number, y: number, w: number, h: number }> }>} */ -export async function renderOutroCard({ width: W, height: H, title, text, imageFile = null, brand, dir }) { +export async function renderOutroCard({ width: W, height: H, title, text, imageFile = null, brand, dir, qrUrl = null, sources = null }) { const L = outroLayout({ width: W, height: H }); const imageBytes = imageFile ? await readFile(imageFile).catch(() => null) : null; if (imageFile && !imageBytes) throw new Error(`outro.image ${imageFile}: not there`); const imageSha = imageBytes ? createHash("sha256").update(imageBytes).digest("hex") : null; - const key = outroKey({ width: W, height: H, title, text, imageSha, brand }); + // A 9:16 card with somewhere to go (a QR, or the sources to list) is the END CARD: the same card, more on it. + const end = L.vertical && (qrUrl || sources?.length) ? { qrUrl: qrUrl ?? null, host: endCardHost(qrUrl), sources: sources ?? [] } : null; + const key = outroKey({ width: W, height: H, title, text, imageSha, brand, end }); await mkdir(dir, { recursive: true }); const file = path.join(dir, `outro-${key}.png`); const placedFile = `${file}.json`; @@ -241,6 +337,12 @@ export async function renderOutroCard({ width: W, height: H, title, text, imageF await execFileP("magick", ["-size", `${W}x${H}`, `xc:${OUTRO_COLOURS.ground}`, ground], magickOpts); } + if (end) { + const placed = await drawEndCard({ W, H, title, text, brand, end, ground, mark, work, file: path.join(work, "card.png") }); + await writeFile(placedFile, JSON.stringify(placed) + "\n"); + await rename(path.join(work, "card.png"), file); + return { file, key, cached: false, layout: L, placed }; + } // The column: title, the accent rule, the call to action, centred in the box above the brand's room. const colH = t.height + L.gap + L.rule.h + L.gap + cta.height; const areaTop = L.box.y0; @@ -274,6 +376,85 @@ export async function renderOutroCard({ width: W, height: H, title, text, imageF } /** + * The 9:16 end card on `ground` (endCardLayout): the kicker and the title, the QR large with "Scan or search", the + * host and the call to action beside it, the sources (END_CARD_SOURCES, then "+ N more in the archive"), the + * brand's mark at the foot of the safe area. Returns where each part went. + */ +async function drawEndCard({ W, H, title, text, brand, end, ground, mark, work, file }) { + const E = endCardLayout({ width: W, height: H }); + const boxW = E.box.x1 - E.box.x0; + const placed = {}; + const comps = []; + const at = (png, x, y) => comps.push(png, "-geometry", `+${Math.round(x)}+${Math.round(y)}`, "-composite"); + let y = E.kicker.y; + const kick = await textPng(span(END_CARD_KICKER, { px: E.kicker.px, color: brand.ink, face: "Archivo @wght=800,wdth=108" }), path.join(work, "kicker.png"), null); + at(kick.file, E.box.x0, y); + placed.kicker = { x: E.box.x0, y, w: kick.width, h: kick.height }; + y += kick.height + E.title.gap; + let t = null; + for (const px of E.title.px) { + t = await textPng(span(title, { px, color: OUTRO_COLOURS.ink, face: "Archivo @wght=800,wdth=108" }), path.join(work, "etitle.png"), boxW, "left"); + if (t.height <= px * 1.25 * E.title.lines) break; + } + at(t.file, E.box.x0, y); + placed.title = { x: E.box.x0, y, w: t.width, h: t.height }; + y += t.height + Math.round(48 * E.u); + // The QR on a white plate, its words beside it. + if (end.qrUrl) { + const raw = path.join(work, "qr-raw.png"); + const qr = path.join(work, "qr.png"); + const inner = E.qr.size - 2 * E.qr.pad; + await execFileP(process.env.QRENCODE_BIN ?? "qrencode", ["-o", raw, "-s", "8", "-m", "0", "-l", "M", "--", end.qrUrl]); + await execFileP("magick", [ + "-size", `${E.qr.size}x${E.qr.size}`, "xc:none", "-fill", "#ffffff", "-draw", `roundrectangle 0,0 ${E.qr.size - 1},${E.qr.size - 1} ${E.qr.radius},${E.qr.radius}`, + "(", raw, "-filter", "point", "-resize", `${inner}x${inner}!`, ")", "-geometry", `+${E.qr.pad}+${E.qr.pad}`, "-composite", qr, + ], magickOpts); + at(qr, E.box.x0, y); + placed.qr = { x: E.box.x0, y, w: E.qr.size, h: E.qr.size }; + const sx = E.box.x0 + E.qr.size + E.side.gap; + const sw = E.box.x1 - sx; + let sy = y + Math.round(10 * E.u); + const head = await textPng(span("Scan or search", { px: E.side.headPx, color: OUTRO_COLOURS.ink, face: "IBM Plex Sans @wght=700" }), path.join(work, "scan.png"), null); + at(head.file, sx, sy); + sy += head.height + Math.round(18 * E.u); + if (end.host) { + const host = await textPng(span(end.host, { px: E.side.hostPx, color: brand.ink, face: "IBM Plex Sans @wght=600" }), path.join(work, "host.png"), sw, "left"); + at(host.file, sx, sy); + placed.host = { x: sx, y: sy, w: host.width, h: host.height }; + sy += host.height + Math.round(18 * E.u); + } + if (text) { + const cta = await textPng(span(text, { px: E.side.textPx, color: OUTRO_COLOURS.muted, face: "IBM Plex Sans @wght=500" }), path.join(work, "ecta.png"), sw, "left"); + at(cta.file, sx, sy); + placed.cta = { x: sx, y: sy, w: cta.width, h: cta.height }; + } + y += E.qr.size + E.list.gap; + } + // The sources: each its date, then its channel and time; the rest counted. + const list = end.sources.slice(0, END_CARD_SOURCES); + const more = end.sources.length - list.length; + placed.sources = []; + for (const [i, s] of list.entries()) { + const d = await textPng(span(s.date || "—", { px: E.list.px, color: OUTRO_COLOURS.muted, face: "IBM Plex Sans @wght=500" }), path.join(work, `sd${i}.png`), null); + const l = await textPng(span(s.label, { px: E.list.px, color: OUTRO_COLOURS.ink, face: "IBM Plex Sans @wght=500" }), path.join(work, `sl${i}.png`), E.box.x1 - E.box.x0 - E.list.dateW, "left"); + at(d.file, E.box.x0, y); + at(l.file, E.box.x0 + E.list.dateW, y); + placed.sources.push({ x: E.box.x0, y, w: E.list.dateW + l.width, h: Math.max(d.height, l.height) }); + y += Math.max(E.list.row, l.height + Math.round(14 * E.u)); + } + if (more > 0) { + const m = await textPng(span(`+ ${more} more in the archive`, { px: E.list.px, color: OUTRO_COLOURS.muted, face: "IBM Plex Sans @wght=500" }), path.join(work, "more.png"), null); + at(m.file, E.box.x0, y); + placed.more = { x: E.box.x0, y, w: m.width, h: m.height }; + } + // The brand at the foot of the safe area, left. + placed.brand = { x: E.box.x0, y: E.box.y1 - mark.height, w: mark.width, h: mark.height }; + at(mark.file, placed.brand.x, placed.brand.y); + await execFileP("magick", [ground, ...comps, "-alpha", "off", "-depth", "8", file], magickOpts); + return placed; +} + +/** * The filtergraph fragment that appends the card to a cut's `[vIn]`/`[aIn]` * (`seconds` long, its `fade` overlapping the cut's last seconds): the card * looped to its frames, the cut's sound faded out over the fade and silence diff --git a/umtool/report-to-video/outro.test.mjs b/umtool/report-to-video/outro.test.mjs @@ -236,3 +236,66 @@ test("wrapShortArgs: the intro crossfaded into the short, the card after it; a h const onlyOutro = wrapShortArgs({ ...base, outro: { png: "/c.png", seconds: 3.5, fade: 0.5 } }); assert.match(onlyOutro[onlyOutro.indexOf("-filter_complex") + 1], /offset=39\.500000\[ov\]/); }); + +// ---- the 9:16 end card (lane vertical-deck) ----------------------------------------------------------------- + +test("the end card's sources: each clip once, its date, channel and time; the schedule's source parts first", async () => { + const { endCardSources, endCardDate, endCardHost } = await import("./outro.mjs"); + const timeline = [ + { type: "clip", id: "a", video: "v1", start: 5104.2, channelTitle: "TheQuartering (Rumble)", date: "2026-01-12" }, + { type: "clip", id: "b", video: "v1", start: 20 }, + { type: "post", id: "p" }, + { type: "clip", id: "c~1", video: "v2", start: 61 }, + ]; + const schedule = { segments: [{ id: "c", vsource: { channel: "Chan", date: "Feb 3, 2026", clock: "1:01" } }] }; + assert.deepEqual(endCardSources(timeline, schedule), [ + { date: "Jan 12", label: "TheQuartering (Rumble) · 1:25:04" }, + { date: "Feb 3", label: "Chan · 1:01" }, + ]); + assert.equal(endCardDate("whenever"), "whenever"); + assert.equal(endCardHost("https://jeralyzer.pages.dev/?q=1"), "jeralyzer.pages.dev"); + assert.equal(endCardHost(null), ""); +}); + +test("the end card's layout keeps inside the safe area; a landscape outro is not one", async () => { + const { endCardLayout } = await import("./outro.mjs"); + const E = endCardLayout({ width: 1080, height: 1920 }); + assert.ok(E.box.x0 >= 0 && E.box.x1 <= 1080 * (1 - VERTICAL_SAFE.right)); + assert.ok(E.box.y0 >= 1920 * VERTICAL_SAFE.top && E.box.y1 <= 1920 * (1 - VERTICAL_SAFE.bottom)); + assert.ok(E.qr.size <= E.box.x1 - E.box.x0); +}); + +test("the end card drawn: the QR, the sources and the brand inside the safe area", async (t) => { + const { execFile } = await import("node:child_process"); + const { promisify } = await import("node:util"); + const run = promisify(execFile); + const have = await run("magick", ["-version"]).then(() => run("qrencode", ["-V"]).then(() => true)).catch(() => false); + if (!have) return t.skip("needs ImageMagick and qrencode"); + const { renderOutroCard } = await import("./outro.mjs"); + const dir = await mkdtemp(path.join(tmpdir(), "endcard-")); + try { + const sources = Array.from({ length: 5 }, (_, i) => ({ date: `Jan ${i + 1}`, label: `Channel ${i} · 1:0${i}:00` })); + const r = await renderOutroCard({ + width: 1080, height: 1920, title: "Every weight he said, in his own words", text: "Full video on the channel", + brand: { name: "Jeralyzer", lead: "Jer", ink: "#5fc4a6" }, dir, qrUrl: "https://jeralyzer.pages.dev/?q=diet", sources, + }); + const { stdout } = await run("magick", [r.file, "-format", "%w %h", "info:"]); + assert.equal(stdout.trim(), "1080 1920"); + for (const k of ["kicker", "title", "qr", "host", "cta", "more", "brand"]) assert.ok(r.placed[k], k); + assert.equal(r.placed.sources.length, 3); + const boxes = [r.placed.kicker, r.placed.title, r.placed.qr, r.placed.host, r.placed.cta, r.placed.more, r.placed.brand, ...r.placed.sources]; + for (const b of boxes) { + assert.ok(b.y >= 1920 * VERTICAL_SAFE.top - 1 && b.y + b.h <= 1920 * (1 - VERTICAL_SAFE.bottom) + 1, JSON.stringify(b)); + assert.ok(b.x + b.w <= 1080 * (1 - VERTICAL_SAFE.right) + 1, JSON.stringify(b)); + } + // Drawn again: the same key, kept. + const again = await renderOutroCard({ + width: 1080, height: 1920, title: "Every weight he said, in his own words", text: "Full video on the channel", + brand: { name: "Jeralyzer", lead: "Jer", ink: "#5fc4a6" }, dir, qrUrl: "https://jeralyzer.pages.dev/?q=diet", sources, + }); + assert.equal(again.cached, true); + if (process.env.END_CARD_OUT) await writeFile(process.env.END_CARD_OUT, await readFile(r.file)); + } finally { + await rm(dir, { recursive: true, force: true }); + } +}); diff --git a/umtool/report-to-video/reel-intro.mjs b/umtool/report-to-video/reel-intro.mjs @@ -167,9 +167,9 @@ export function wrapShortArgs({ short, shortSeconds, intro = null, outro = null, * * @param {{ file: string, takeDir: string, render: Record<string, any>, manifest?: any, introSpec?: unknown, * outro?: { title: string, text: string, image?: string | null, imageFile?: string | null, seconds: number } | null, - * xfade?: number, sitesDir?: string, log?: (s: string) => void }} o + * xfade?: number, sitesDir?: string, log?: (s: string) => void, endCard?: { qrUrl?: string | null, sources?: Array<{ date: string, label: string }> } | null }} o */ -export async function wrapShort({ file, takeDir, render, manifest = null, introSpec = null, outro = null, xfade = 0.3, sitesDir = undefined, log = () => {} }) { +export async function wrapShort({ file, takeDir, render, manifest = null, introSpec = null, outro = null, xfade = 0.3, sitesDir = undefined, log = () => {}, endCard = null }) { if (!introSpec && !outro) return { intro: null, outro: null }; const { execFile } = await import("node:child_process"); const { promisify } = await import("node:util"); @@ -198,7 +198,11 @@ export async function wrapShort({ file, takeDir, render, manifest = null, introS let card = null; if (outro) { const brand = await outroBrand(ri?.entry ?? null, { provenance: manifest?.provenance ?? null, sitesDir }); - const r = await renderOutroCard({ width: W, height: H, title: outro.title, text: outro.text, imageFile: outro.imageFile ?? null, brand, dir: path.join(takeDir, "out", "sourced", "outro") }); + // A 9:16 card with somewhere to go is the end card (outro.mjs): the QR, the host, the short's sources. + const r = await renderOutroCard({ + width: W, height: H, title: outro.title, text: outro.text, imageFile: outro.imageFile ?? null, brand, dir: path.join(takeDir, "out", "sourced", "outro"), + ...(endCard && H > W ? { qrUrl: endCard.qrUrl ?? null, sources: endCard.sources ?? null } : {}), + }); card = { png: r.file, seconds: outro.seconds, fade: OUTRO_FADE }; log(`vertical: outro card ${r.cached ? "(drawn before)" : "drawn"} -- "${outro.title}"`); } diff --git a/umtool/report-to-video/reframe.mjs b/umtool/report-to-video/reframe.mjs @@ -68,7 +68,7 @@ export async function normalizeLoudness(input, output, target, { log = () => {} * piece plays whole, else each segment's part cut and joined; then the * short's loudness. `{seconds, loudness}`. */ -export async function assembleShort({ pieces, segmentsDir, built, outFile, render, log = () => {} }) { +export async function assembleShort({ pieces, segmentsDir, built, outFile, render, schedule = null, log = () => {} }) { const target = verticalKnobs(render).loudness; const whole = pieces.every((p) => !p.from && p.to === null); let src = built; @@ -76,10 +76,16 @@ export async function assembleShort({ pieces, segmentsDir, built, outFile, rende src = `${outFile}.joined-${process.pid}.mp4`; const inputs = []; const parts = []; + // THE STACKED VERTICAL DECK (vertical-deck.mjs): its segments are the picture alone -- the deck is laid over the + // built cut -- so a piece is cut from the built cut at its segment's place (the build's schedule), deck and all. + const placed = new Map((Array.isArray(schedule?.segments) ? schedule.segments : []).map((s) => [s.id, s])); + const fromBuilt = !!schedule && pieces.every((p) => placed.has(p.id)); pieces.forEach((p, i) => { - inputs.push("-i", path.join(segmentsDir, `${p.id}.mp4`)); - const trim = p.to === null ? `trim=start=${f3(p.from)}` : `trim=start=${f3(p.from)}:end=${f3(p.to)}`; - const atrim = p.to === null ? `atrim=start=${f3(p.from)}` : `atrim=start=${f3(p.from)}:end=${f3(p.to)}`; + const at = fromBuilt ? Number(placed.get(p.id).start) : 0; + const end = p.to === null ? (fromBuilt ? at + Number(placed.get(p.id).duration) : null) : at + p.to; + inputs.push("-i", fromBuilt ? built : path.join(segmentsDir, `${p.id}.mp4`)); + const trim = end === null ? `trim=start=${f3(at + p.from)}` : `trim=start=${f3(at + p.from)}:end=${f3(end)}`; + const atrim = end === null ? `atrim=start=${f3(at + p.from)}` : `atrim=start=${f3(at + p.from)}:end=${f3(end)}`; parts.push(`[${i}:v]${trim},setpts=PTS-STARTPTS,fps=${render?.fps ?? 30},format=yuv420p,setsar=1[v${i}]`, `[${i}:a]${atrim},asetpts=PTS-STARTPTS,afade=t=in:d=0.08,areverse,afade=t=in:d=0.12,areverse[a${i}]`); }); parts.push(`${pieces.map((_, i) => `[v${i}][a${i}]`).join("")}concat=n=${pieces.length}:v=1:a=1[v][a]`);