commit 7d16b6689bb5c0653fcf5ab6c261127b426e1d29 parent 31af39e1d4622b31e619f9ea0cb99e2dbe5ff8b2 Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st> Date: Mon, 9 Nov 2026 23:16:31 -0500 umtool: the stacked vertical deck -- a 9:16 cut keeps its deck (render.vertical.deck, default "stacked"; "bare" is the vertical as it shipped) One composition, two geometries (report-to-video/vertical-deck.mjs): the landscape cut's schedule and pages, laid top to bottom inside the safe area -- the rail (section name, progress segments, "2 / 5") under the top band, the picture at full width, the captions under it (two lines, each word lit), the instruments in two columns (the dial tall at the left, the odometer and the trail down the right), the tally, the source block (QR, channel, title, date, time) above the bottom band, the wordmark dim in it. deckGeometry, instrumentsGeometry, the stamp/stats/ measure-extras/story scales and the dial finale answer for it; the shell's page is chrome-vdeck.mjs. A clip's two crops (vertical.layout "twocrop", vertical.crops): crop one, a strip of the instruments, crop two with the captions over its foot, the QR small and low-left; a crop past 2.5x its source's pixels is said (lint, build). A post item is the hero card with the counters under it and its date line in the source block; the instruments stand down over it and over a twocrop clip. The finale is the instrument column (dial-finale, portrait, opaque). Each module declares its vertical form (contract.mjs VERTICAL_SLOTS); one without (popups, feed, threads, flips, chat, the landscape finale, the rail's claim checks) is left out, said in the lint and the build's notes; the popups' holds are not made. Play the cut plays a vertical cut's deck 9:16. A 720p deck's band scales with the frame's height (deckScale, floored at 2/3): footageScale 0.82 fits, the footage no longer at y < 0. Landscape at 1080 and the bare vertical are byte for byte main's (pinned in vertical-deck.test.mjs). CLI: umtool look <p> vertical='{"deck":"stacked"|"bare"}', umtool set <p> <clip> vertical.layout=twocrop 'vertical.crops=[[..],[..]]', umtool vertical … --deck stacked|bare; knobs.md "The vertical deck". Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Diffstat:
50 files changed, 1533 insertions(+), 60 deletions(-)
diff --git a/common/lib/report/look.mjs b/common/lib/report/look.mjs @@ -18,7 +18,7 @@ // styles with `umtool look <p> intro=<style>`, and every writer checks it here. import { introPatchValue, validateIntro } from "./intro.mjs"; // `format` and `vertical` (lane vertical): the cut rendered 9:16, and a clip's side post (./vertical.mjs). -import { VERTICAL_CLIP_LAYOUTS, validateVerticalFormat } from "./vertical.mjs"; +import { CLIP_OWN_LAYOUTS, validateVerticalFormat } from "./vertical.mjs"; const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v); const num = (v) => typeof v === "number" && Number.isFinite(v); @@ -313,8 +313,11 @@ export function verticalErrors(v, who = "vertical") { if (v === undefined || v === null) return []; if (!isObj(v)) return [`${who} must be an object ({crop: [x, y, w, h]}), not ${q(v)}`]; const errors = []; - for (const k of Object.keys(v)) if (k !== "crop" && k !== "aspect" && k !== "layout") errors.push(`${who}.${k} is not a setting here (crop, aspect, layout)`); - if (v.layout !== undefined && !VERTICAL_CLIP_LAYOUTS.includes(v.layout)) errors.push(`${who}.layout must be one of ${VERTICAL_CLIP_LAYOUTS.join(", ")}`); + for (const k of Object.keys(v)) if (!["crop", "aspect", "layout", "crops"].includes(k)) errors.push(`${who}.${k} is not a setting here (crop, aspect, layout, crops)`); + if (v.layout !== undefined && !CLIP_OWN_LAYOUTS.includes(v.layout)) errors.push(`${who}.layout must be one of ${CLIP_OWN_LAYOUTS.join(", ")}`); + // The stacked deck's two crops (`layout: "twocrop"`): two boxes of the source, the first on top. Any shape: + // each is fitted to its band (cut to the band's aspect about its centre). + if (v.crops !== undefined || v.layout === "twocrop") errors.push(...twoCropErrors(v, who)); // A clip may set its vertical layout alone: the crop is then the centred one. if (v.crop === undefined && v.layout !== undefined) return errors; if (v.aspect !== undefined && (!num(v.aspect) || v.aspect <= 0.2 || v.aspect > 5)) { @@ -339,6 +342,27 @@ export function verticalErrors(v, who = "vertical") { return errors; } +/** A clip's `vertical.crops` (and the "twocrop" layout that needs them), as sentences. */ +function twoCropErrors(v, who) { + const errors = []; + const c = v.crops; + if (v.layout === "twocrop" && c === undefined) return [`${who}.layout "twocrop" needs ${who}.crops: [[x, y, w, h], [x, y, w, h]] (the top crop first)`]; + if (v.layout !== undefined && v.layout !== "twocrop") errors.push(`${who}.crops are the "twocrop" layout's (set ${who}.layout=twocrop, or remove the crops)`); + if (!Array.isArray(c) || c.length !== 2) return [...errors, `${who}.crops must be two boxes [[x, y, w, h], [x, y, w, h]], fractions of the source picture`]; + const E = 1e-3; + c.forEach((b, i) => { + const at = `${who}.crops[${i}]`; + if (!Array.isArray(b) || b.length !== 4 || !b.every(num)) { + errors.push(`${at} must be [x, y, w, h], four fractions of the source picture`); + return; + } + const [x, y, w, h] = b; + if (w <= 0.02 || h <= 0.02) errors.push(`${at}'s width and height must be above 0.02 of the picture`); + if (x < -E || y < -E || x + w > 1 + E || y + h > 1 + E) errors.push(`${at} must lie inside the picture (each of x, y, x + w, y + h from 0 to 1)`); + }); + return errors; +} + /** Every clip's `vertical`. */ export function validateVertical(manifest) { const errors = []; diff --git a/common/lib/report/vertical.d.mts b/common/lib/report/vertical.d.mts @@ -5,7 +5,9 @@ type Render = Record<string, unknown> | null | undefined; export type ClipLayout = "full" | "framed" | "quote"; export type PostLayout = "card" | "stack" | "media"; export type SideLayout = "split" | "overlay"; +export type VerticalDeck = "stacked" | "bare"; export type VerticalKnobs = { + deck: VerticalDeck; clip: ClipLayout; post: PostLayout; side: SideLayout; @@ -18,6 +20,8 @@ export type VerticalKnobs = { }; export const RENDER_FORMATS: readonly ("landscape" | "vertical")[]; export const VERTICAL_CLIP_LAYOUTS: readonly ClipLayout[]; +export const CLIP_OWN_LAYOUTS: readonly (ClipLayout | "twocrop")[]; +export const VERTICAL_DECKS: readonly VerticalDeck[]; export const VERTICAL_POST_LAYOUTS: readonly PostLayout[]; export const VERTICAL_SIDE_LAYOUTS: readonly SideLayout[]; export const LANDSCAPE_SIDE_PLACES: readonly ("right" | "left")[]; @@ -34,6 +38,8 @@ export const VERTICAL_SAFE_MAX: Readonly<{ top: number; bottom: number; right: n export function verticalOn(render: Render): boolean; export function verticalKnobs(render: Render): VerticalKnobs; export function clipLayoutOf(entry: unknown, render: Render): ClipLayout; +export function stackedDeckWanted(render: Render): boolean; +export function clipTwoCrop(entry: unknown): [number[], number[]] | null; export function validateVerticalRender(manifest: unknown): string[]; export function sideErrors(side: unknown, who?: string, opts?: { itemIds?: Set<string> | null }): string[]; export function validateClipSides(manifest: unknown): string[]; diff --git a/common/lib/report/vertical.mjs b/common/lib/report/vertical.mjs @@ -2,7 +2,11 @@ // 9:16 for the shorts platforms, and the side post a clip may carry. // // render.format "vertical" | "landscape" absent = landscape, the cut as it always was -// render.vertical { clip?, post?, side?, captions?, hook?, tag?, safe?, loudness?, maxSeconds? } +// render.vertical { deck?, clip?, post?, side?, captions?, hook?, tag?, safe?, loudness?, maxSeconds? } +// deck "stacked" (the default: a cut that has a deck keeps it in 9:16 -- the rail under the top band, +// the picture at full width, the captions under it, the instruments in two columns, +// the source line and its QR above the bottom band; report-to-video/vertical-deck.mjs) +// "bare" (the vertical format as it first shipped: no header, footer, QR, rail or deck) // clip "full" (T1: a 9:16 crop, big word captions in the lower middle, a source tag) // "framed" (T2: the whole 16:9 picture in the middle third over a blurred enlargement // of itself; captions below, a hook band above) @@ -27,7 +31,9 @@ // `from`/`to` are seconds into the clip as it plays; `place` overrides the cut's // render.vertical.side for this clip ("split" | "overlay"), or, in a landscape cut, // "right" (the default) | "left" for the panel's side. -// clip.vertical.layout this clip's own layout ("full" | "framed" | "quote") over the cut's. +// clip.vertical.layout this clip's own layout ("full" | "framed" | "quote") over the cut's -- or, in the +// stacked deck, "twocrop": two crops of its picture stacked, `vertical.crops: [[x,y,w,h],[x,y,w,h]]` +// (fractions of the source; the first on top), a strip of the instruments between them. // // PURE: no fs, no ffmpeg. Plain ESM with a .d.mts beside it. @@ -37,6 +43,10 @@ const q = (v) => JSON.stringify(v); export const RENDER_FORMATS = Object.freeze(["landscape", "vertical"]); export const VERTICAL_CLIP_LAYOUTS = Object.freeze(["full", "framed", "quote"]); +/** A clip's OWN layouts: the cut's, and the stacked deck's two crops (a clip's alone: it needs its crops). */ +export const CLIP_OWN_LAYOUTS = Object.freeze([...VERTICAL_CLIP_LAYOUTS, "twocrop"]); +/** What a vertical cut does with the deck: keep it stacked in 9:16, or drop it (the bare vertical). */ +export const VERTICAL_DECKS = Object.freeze(["stacked", "bare"]); export const VERTICAL_POST_LAYOUTS = Object.freeze(["card", "stack", "media"]); export const VERTICAL_SIDE_LAYOUTS = Object.freeze(["split", "overlay"]); /** Where a side post sits in a LANDSCAPE cut. */ @@ -54,6 +64,7 @@ export const VERTICAL_HEIGHT = 1920; /** The shorts conventions, as knobs: what a cut that sets none gets. */ export const VERTICAL_DEFAULTS = Object.freeze({ + deck: "stacked", clip: "full", post: "card", side: "split", @@ -74,6 +85,7 @@ export const verticalOn = (render) => render?.format === "vertical"; export function verticalKnobs(render) { const v = isObj(render?.vertical) ? render.vertical : {}; return { + deck: VERTICAL_DECKS.includes(v.deck) ? v.deck : VERTICAL_DEFAULTS.deck, clip: VERTICAL_CLIP_LAYOUTS.includes(v.clip) ? v.clip : VERTICAL_DEFAULTS.clip, post: VERTICAL_POST_LAYOUTS.includes(v.post) ? v.post : VERTICAL_DEFAULTS.post, side: VERTICAL_SIDE_LAYOUTS.includes(v.side) ? v.side : VERTICAL_DEFAULTS.side, @@ -86,12 +98,29 @@ export function verticalKnobs(render) { }; } -/** A clip's layout in a vertical cut: its own `vertical.layout`, else the cut's. */ +/** A clip's layout in a vertical cut: its own `vertical.layout`, else the cut's ("twocrop" is the stacked deck's: clipTwoCrop). */ export function clipLayoutOf(entry, render) { const own = entry?.vertical?.layout; return VERTICAL_CLIP_LAYOUTS.includes(own) ? own : verticalKnobs(render).clip; } +/** + * Does this cut keep its deck in 9:16 (the stacked deck)? A vertical cut whose `render.vertical.deck` is + * "stacked" (the default) AND that has a deck to keep (`render.chrome`, the HyperFrames deck). A cut with no + * deck is the bare vertical whatever it says. + */ +export function stackedDeckWanted(render) { + const c = render?.chrome; + return verticalOn(render) && verticalKnobs(render).deck === "stacked" && isObj(c) && c.engine === "hyperframes" && c.layout === "deck"; +} + +/** A clip's two crops (`vertical.layout: "twocrop"`, `vertical.crops`), or null: the stacked deck plays it so. */ +export function clipTwoCrop(entry) { + const v = entry?.vertical; + if (!isObj(v) || v.layout !== "twocrop" || !Array.isArray(v.crops) || v.crops.length !== 2) return null; + return v.crops.every((c) => Array.isArray(c) && c.length === 4 && c.every(num)) ? v.crops.map((c) => [...c]) : null; +} + /** Every reason `render.format` / `render.vertical` cannot be built. */ export function validateVerticalRender(manifest) { const r = manifest?.render; @@ -106,6 +135,7 @@ export function validateVerticalRender(manifest) { const oneOf = (k, list) => { if (v[k] !== undefined && !list.includes(v[k])) errors.push(`render.vertical.${k} must be one of ${list.join(", ")}, not ${q(v[k])}`); }; + oneOf("deck", VERTICAL_DECKS); oneOf("clip", VERTICAL_CLIP_LAYOUTS); oneOf("post", VERTICAL_POST_LAYOUTS); oneOf("side", VERTICAL_SIDE_LAYOUTS); diff --git a/umtool/app/api/report/chrome/preview/route.ts b/umtool/app/api/report/chrome/preview/route.ts @@ -22,6 +22,7 @@ import { resolveFactcheck, stampsDrawn, tallyAlways, tallyOf } from "umtool-repo import { counterOrder } from "umtool-report-to-video/counter"; import { cachedTakeManifest, takePlayDir, writePlayManifest } from "@/lib/report/takeManifest.mjs"; import { isTakeId } from "@/lib/report/takes.mjs"; +import { stackedOn } from "umtool-report-to-video/vertical-deck"; export const dynamic = "force-dynamic"; @@ -197,8 +198,10 @@ export async function POST(request: Request) { } catch (e) { return Response.json({ error: e instanceof Error ? e.message : String(e) }, { status: 500 }); } - // `posts: false` -- the clip bench's strip, which has no footage to lay them on. - const windows = body.posts === false ? [] : await composePostsPreviews(target, r.variant, schedule); + // `posts: false` -- the clip bench's strip, which has no footage to lay them on. The stacked vertical deck draws + // no popups (they have no vertical form: vertical-deck.mjs), nor the landscape finale's page. + const stacked = stackedOn(render); + const windows = body.posts === false || stacked ? [] : await composePostsPreviews(target, r.variant, schedule); const stamp = Date.now(); const isFeed = body.posts !== false && (schedule as { layout?: string }).layout === "feed"; let feed: Record<string, unknown> | null = null; @@ -240,7 +243,7 @@ export async function POST(request: Request) { // Not on the bench's strip either. const fin = (schedule as { finale?: { from: number; to: number } }).finale ?? null; let finale: Record<string, unknown> | null = null; - if (body.posts !== false && fin) { + if (body.posts !== false && fin && !stacked) { let error: string | null = null; try { await composeFinalePreview(target, r.variant, schedule); diff --git a/umtool/components/projects/review/PlayCut.tsx b/umtool/components/projects/review/PlayCut.tsx @@ -195,6 +195,8 @@ const L_RATES = [1, 1.5, 2, 2.5, 3]; const SKIP_S = 5; /** The player is as wide as leaves the strip and Now on screen under it (never under 480 px). */ const PLAYER_MAX_W = "max(480px, min(1100px, calc((100dvh - 430px) * 16 / 9)))"; +/** A 9:16 cut's player (the stacked vertical deck, vertical-deck.mjs): as tall as the 16:9 one would be wide allows, centred. */ +const PLAYER_MAX_W_TALL = "max(240px, min(460px, calc((100dvh - 250px) * 9 / 16)))"; const PAUSE_KEY = "umtool.play.pauseWhileWriting"; /** "on": play the clips the walk rejected too (for re-review); absent or "off": skip them. */ // The key keeps its old name: a browser that chose "show" before rejections had reasons still has. @@ -916,6 +918,8 @@ export default function PlayCut({ const item = plan.items[ui.cur] ?? null; const entry = item ? entryOf.get(item.id) : null; const g = doc?.geometry ?? null; + // A 9:16 cut (the stacked vertical deck): its frame is tall, and the player is sized for it. + const tall = !!g && g.H > g.W; const box: Rect | null = g ? (doc?.feed?.footage ?? g.footage) : null; const move = schedule ? footageAt(schedule, tc) : null; const rect: Rect | null = move?.rect ?? box; @@ -1225,10 +1229,11 @@ export default function PlayCut({ data-play-player-pin="" data-compact={compact ? "" : undefined} className="relative w-full max-md:sticky max-md:top-0 max-md:z-30 max-md:-mx-4 max-md:w-auto max-md:bg-ground" + data-play-tall={tall ? "" : undefined} style={ compact - ? { maxWidth: PLAYER_MAX_W, width: (STRIP_H * 16) / 9, marginBottom: Math.max(0, fullH - STRIP_H) } - : { maxWidth: PLAYER_MAX_W } + ? { maxWidth: PLAYER_MAX_W, width: (STRIP_H * (tall ? 9 / 16 : 16 / 9)), marginBottom: Math.max(0, fullH - STRIP_H) } + : tall ? { maxWidth: PLAYER_MAX_W_TALL, marginInline: "auto" } : { maxWidth: PLAYER_MAX_W } } > <div className="pointer-events-none absolute inset-0 overflow-hidden" aria-hidden> diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md @@ -243,7 +243,7 @@ draft (the project's manifest); *project*: a project's other files, or reads; *c | `pool prune [--max-gb N] [--dry-run]` | the render pool pruned to its cap | form · *corpus* | | `pool verify [--sample N] [--all]` | the render pool's files checked | form · queued · *corpus* | | `trailer <project> [--take TAKE] [--reel REEL] [--beats BEATS] [--beats-json JSON] [--intro] [--finale N] [--xfade N] [--no-snap] [--out OUT] [--dry-run] [--candidates] [--vertical] [--layout reframe]` | a trailer or beat reel cut from a take's master | form · queued · *project* | -| `vertical <project> --take TAKE [--reel REEL] [--beats BEATS] [--items ITEMS] [--clip full\|framed\|quote] [--post card\|stack\|media] [--side split\|overlay] [--hook HOOK] [--captions l\|xl] [--lines 1\|2] [--loudness N] [--max N] [--name NAME] [--reframe] [--dry-run] [--intro] [--no-intro] [--no-outro]` | a vertical short (1080x1920) of a take's items | form · queued · *project* | +| `vertical <project> --take TAKE [--reel REEL] [--beats BEATS] [--items ITEMS] [--clip full\|framed\|quote] [--post card\|stack\|media] [--side split\|overlay] [--hook HOOK] [--captions l\|xl] [--lines 1\|2] [--loudness N] [--max N] [--name NAME] [--reframe] [--dry-run] [--intro] [--no-intro] [--no-outro] [--deck stacked\|bare]` | a vertical short (1080x1920) of a take's items | form · queued · *project* | | `trailer-beats <project> ls [--reel REEL]` | a reel's beats against its limit | form · *project* | | `trailer-beats <project> add <clip> [<span>] [--at N] [--label LABEL] [--take TAKE] [--reel REEL]` | a clip beat | form · *project* | | `trailer-beats <project> add-raw <at> <dur> [--at N] [--label LABEL] [--reel REEL]` | a beat of master seconds | form · *project* | diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -1652,7 +1652,8 @@ byte what it was. | Knob | Values (default) | What it does | |---|---|---| -| `render.format` | `"landscape"` · `"vertical"` (absent = landscape) | the whole cut 9:16: no header, footer, QR, rail, deck or brand intro | +| `render.format` | `"landscape"` · `"vertical"` (absent = landscape) | the whole cut 9:16, no brand intro: with its deck kept stacked (below), or bare -- no header, footer, QR, rail or deck | +| `render.vertical.deck` | `stacked` · `bare` (`stacked`) | a cut with a deck keeps it in 9:16 ([The vertical deck](#the-vertical-deck)); `bare` is the vertical as it first shipped, byte for byte. A cut with no deck is bare whatever it says | | `render.vertical.clip` | `full` · `framed` · `quote` (`full`) | T1 a 9:16 crop full-bleed, captions in the lower middle, a source tag · T2 the whole picture in the middle third over a blurred enlargement, hook above, captions below · T3 the picture in the top 40 %, the line set large below, each word lit, "— channel · date" | | `render.vertical.post` | `card` · `stack` · `media` (`card`) | P1 the card at full width, its attachment under the words · P2 the attachment over them, the thread column below · P3 the attachment large on top (60 %), the words under it | | `render.vertical.side` | `split` · `overlay` (`split`) | a clip with a side post: M1 the clip in the top half, the post rising into the bottom half for its span · M2 the clip full-bleed, the post floating over the lower third (the captions move above it) | @@ -1662,13 +1663,15 @@ byte what it was. | `render.vertical.safe` | `{top, bottom, right}` fractions (0.08, 0.2, 0.12) | kept clear of every caption, tag, card and post (the platforms' buttons) | | `render.vertical.loudness` | LUFS -30 … -8 (-14) | each clip levelled to it in its segment; the short brought to it at the end | | `render.vertical.maxSeconds` | 5 … 600 (60) | a short over it is said so (a note, never a refusal) | -| a clip's `vertical` | `{crop: [x, y, w, h], aspect?, layout?}` | its 9:16 box on the source (else centred) and its own layout over the cut's | +| a clip's `vertical` | `{crop: [x, y, w, h], aspect?, layout?, crops?}` | its 9:16 box on the source (else centred) and its own layout over the cut's; `layout: "twocrop"` with `crops: [[x, y, w, h], [x, y, w, h]]` (fractions of the source, the top one first) is the stacked deck's two-crop reframe | | a clip's `side` | `{item \| post, from, to, place?}` | a post shown BESIDE the clip while it plays: not read, the clip's sound on. `item` a post item of the cut, `post` its fields; `from`/`to` seconds into the clip; `place` `split`/`overlay` (vertical) or `right`/`left` (16:9: a panel over that side of the picture, sliding in) | | | From a terminal | |---|---| | a clip's crop, layout, side post | `umtool set <p> <clip> 'vertical.crop=[0.64,0,0.3164,1]' vertical.layout=quote side.item=<post item> side.from=1 side.to=9 side.place=overlay` (`side=` removes it; `--json`) | +| a clip's two crops (the stacked deck) | `umtool set <p> <clip> vertical.layout=twocrop 'vertical.crops=[[0.05,0.1,0.6,0.6],[0.62,0.55,0.36,0.45]]'` (`vertical.layout=` and `vertical.crops=` back) | | the cut 9:16 | `umtool look <p> format='"vertical"' vertical='{"clip":"framed","hook":"section"}'` (`format='"landscape"'` back) | +| the deck in 9:16, or none | `umtool look <p> vertical='{"deck":"stacked"}'` (the default) · `vertical='{"deck":"bare"}'` · a short: `umtool vertical <p> … --deck bare` | | a short of a take's items | `umtool vertical <p> --take <t> (--reel <r> \| --beats F \| --items a,b) [--clip …] [--post …] [--side …] [--hook …] [--json]` | | a reel 9:16 | `umtool trailer <p> --reel <r> --take <t> --vertical [--layout reframe]` | | the brand intro 9:16 first (centred in the safe area); the reel's outro card 9:16 last | `umtool vertical <p> --take <t> --reel <r> --intro` (a reel with `intro` on: by itself; `--no-intro`) · the reel's `outro` on: by itself (`--no-outro`) | @@ -1679,6 +1682,45 @@ A clip's `vertical` and `side` are read from the PROJECT's manifest over the tak made). The side card is drawn by the post card's own page with the cut's redaction and the authors' pictures; its attachments are left off. Play the cut shows the side post over the clip for its span. +### The vertical deck + +A 9:16 cut that has a deck keeps it (`render.vertical.deck: "stacked"`, the default; `report-to-video/vertical-deck.mjs`). +It is the landscape cut's deck -- the same schedule, the same pages, the same timing -- drawn in another geometry, +top to bottom inside the safe area (`render.vertical.safe`): + +| Zone | What stands there | +|---|---| +| the rail (under the top 8 %) | the section's name (the deck's markers; `deck.sectionTitle.first` before the first), its progress -- one segment per section, filled as its clips play -- and `2 / 5` | +| the picture | the clip's 16:9 footage box at the frame's full width; over it, as over the landscape footage box, the stamps, the stats, the effects, the chapters, the measure extras (the diet badge lower-left …) and the shelf (`deck.shelf`) at the picture's lower-left | +| the captions | under the picture, at most two lines (`render.vertical.captions.lines`), each word lit as it is said | +| the instruments' panel | two columns: the dial the left column's height, the odometer and the trail down the right (the promise clock in the trail's cell, as in the landscape column); an instrument the panel has no room for is left out, never squashed | +| the counters | the tally's cells, when the cut counts its claims (`render.chrome.factcheck`, `deck.counter`) | +| the source block (above the bottom 20 %) | the clip's QR, its channel, its title (the deck's own when the clip sets one), its date and the time it is from | +| the bottom 20 % | the site's name, dim (decoration only) | + +A **post item** is the hero card -- today's vertical post card (`render.vertical.post`) from under the rail to the +panel's top -- the counters under it, its big date line and who posted it in the source block; the instruments stand +down while it is up. A clip with **two crops** (`vertical.layout: "twocrop"`, `vertical.crops`) plays crop one over a +one-row strip of the instruments (what he says he weighs, what he says he has lost, NET), crop two under it with the +captions over its foot, its source line over the rail at the top and its QR small and low-left in the bottom band; a +crop drawn past 2.5× its source's pixels is said so (the lint, on a 16:9 source of `render.maxHeightSource`; the build +again, from the real one). The **finale** (`layout: "finale"`) is the instrument column over the picture's room: its +title, the dial large in a card, the odometer and NET under it (module `dial-finale`). + +Every module declares its vertical form (`vertical: {slot}` in `modules/<id>.mjs`: frame, panel, picture, shelf, +finale, inline, segment, input). One the cut sets up that has none -- the posts popups and feed, the side panel +(threads, flips), the live chat, the landscape finale's page, the claim checks on the rail -- is LEFT OUT: the lint +and the build say so (`popup-posts: no vertical form -- left out of the stacked vertical deck …`); the landscape cut +keeps it. With the popups left out, a clip that carries posts is not held for them (the landscape cut's `posts.hold`: +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. + +**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 +refused: "at most 0.736") and the footage box no longer stands above the frame. 1080 is untouched. + ## Takes: relabel, supersede, cancel, delete, fork as variant, compare | | In umtool | From a terminal | Route | diff --git a/umtool/lib/cli/groups.mjs b/umtool/lib/cli/groups.mjs @@ -656,7 +656,8 @@ export const GROUPS = [ cmd: "vertical", usage: [ " umtool vertical <project> --take <t> (--reel R | --beats F | --items a,b) [--clip full|framed|quote]", - " [--post card|stack|media] [--side split|overlay] [--hook title|section|<copy>] [--reframe] [--json]", + " [--post card|stack|media] [--side split|overlay] [--hook title|section|<copy>] [--deck stacked|bare]", + " [--reframe] [--json]", " a vertical short (1080x1920, -14 LUFS) of the take's items: each clip cut again in its layout,", " each post drawn in a portrait box; --reframe recomposes the finished 16:9 master instead", ], diff --git a/umtool/lib/cli/verbs.mjs b/umtool/lib/cli/verbs.mjs @@ -246,6 +246,7 @@ export const VERBS = Object.freeze([ project(), takeOpt({ required: true, help: "the take" }), reel(), file("--beats", { help: "a beats file of the project" }), opt("--items", { help: "id,id" }), pick("--clip", ["full", "framed", "quote"]), pick("--post", ["card", "stack", "media"]), pick("--side", ["split", "overlay"]), opt("--hook", { help: "title | section | a line of the cut's own copy" }), pick("--captions", ["l", "xl"]), pick("--lines", ["1", "2"]), num("--loudness"), num("--max"), name("--name"), bool("--reframe", "recompose the finished 16:9 master"), dry(), bool("--intro"), bool("--no-intro"), bool("--no-outro"), + pick("--deck", ["stacked", "bare"]), ], Q), // ---- the trailer's beats ---- diff --git a/umtool/lib/report/knobsCli.mjs b/umtool/lib/report/knobsCli.mjs @@ -55,7 +55,7 @@ const REVIEW_KEYS = ["verdict", "reason", "rejectNote", "correction"]; const FX_KEYS = ["fx", ...FX_ENTRY_FIELDS.map((k) => `fx.${k}`)]; /** Seconds taken out of the clip's middle (gaps.mjs): the whole list, one added, one removed. */ const GAP_KEYS = ["gaps", "gap.add", "gap.remove"]; -export const VERTICAL_SET_KEYS = Object.freeze(["vertical", "vertical.crop", "vertical.layout", "vertical.aspect"]); +export const VERTICAL_SET_KEYS = Object.freeze(["vertical", "vertical.crop", "vertical.layout", "vertical.aspect", "vertical.crops"]); export const SIDE_SET_KEYS = Object.freeze(["side", "side.item", "side.post", "side.from", "side.to", "side.place"]); const SET_KEYS = [ ...CLAIM_KNOBS.map((k) => `claim.${k}`), ...MARK_KEYS, ...AUDIO_KNOBS.map((k) => `audio.${k}`), ...BLUR_KNOBS.map((k) => `blur.${k}`), "layout", ...REVIEW_KEYS, @@ -106,7 +106,8 @@ export const SET_USAGE = [ " --take <t>: the entry knobs (not claim.* or marks) land in takes/<t>/take.json's patch, an undo point first", " (`umtool timeline <p> --take <t> undo`); the project's manifest is untouched.", " vertical.crop='[x,y,w,h]' (fractions of the source: the 9:16 box a vertical render cuts; vertical.aspect the", - " source's w/h when not 16:9); vertical.layout=full|framed|quote (this clip's layout in a vertical cut).", + " source's w/h when not 16:9); vertical.layout=full|framed|quote (this clip's layout in a vertical cut), or", + " twocrop with vertical.crops='[[x,y,w,h],[x,y,w,h]]' (the stacked vertical deck's two crops, the top one first).", " side.item=<post item id> | side.post='{\"author\",\"handle\",\"date\",\"text\",…}' -- a post shown BESIDE the", " clip while it plays, never read, the clip's sound running; side.from / side.to seconds into the clip;", " side.place=split|overlay (vertical) | right|left (16:9). `side=` removes it (docs/knobs.md \"Vertical\").", diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs @@ -840,12 +840,14 @@ export function patchClipEntry(manifest, clipId, patch, { edit = "trim", now = n const errors = verticalErrors(v, "vertical"); if (errors.length) throw new Error(errors.join("; ")); const r4 = (n) => Number(Number(n).toFixed(4)); - const vv = /** @type {{ crop?: number[], aspect?: number, layout?: string }} */ (v); + const vv = /** @type {{ crop?: number[], aspect?: number, layout?: string, crops?: number[][] }} */ (v); // `layout` (lane vertical): the clip's own layout in a vertical cut; a layout alone keeps the centred crop. entry.vertical = { ...(Array.isArray(vv.crop) ? { crop: vv.crop.map(r4) } : {}), ...(vv.aspect !== undefined ? { aspect: r4(vv.aspect) } : {}), ...(vv.layout !== undefined ? { layout: vv.layout } : {}), + // The stacked deck's two crops (layout "twocrop"), the top one first. + ...(Array.isArray(vv.crops) ? { crops: vv.crops.map((c) => c.map(r4)) } : {}), }; } } diff --git a/umtool/lib/report/onscreen.mjs b/umtool/lib/report/onscreen.mjs @@ -19,6 +19,10 @@ import { readFile, rm, writeFile } from "node:fs/promises"; import path from "node:path"; import { composeChrome } from "umtool-report-to-video/compose-chrome"; import { selectVariant } from "umtool-report-to-video/build-video"; +// The stacked vertical deck (vertical-deck.mjs): a 9:16 cut that keeps its deck previews at the render its build +// makes (vertical.mjs verticalRender), and only the modules with a vertical form. +import { stackedDeckWanted, verticalRender } from "umtool-report-to-video/vertical"; +import { stackedOn } from "umtool-report-to-video/vertical-deck"; import { createPostChannelResolver, resolvePostLinks } from "umtool-report-to-video/post-links"; import { attachPosts, @@ -446,7 +450,9 @@ export async function scheduleForPreview( project, manifest, variant, draft = new Map(), postsDraft = {}, { resolver = previewPostResolver(), claimsDraft = new Map(), estimate = false } = {}, ) { - const selected = selectVariant(manifest, variant); + const picked = selectVariant(manifest, variant); + // A stacked vertical deck is previewed at its build's render: the 9:16 frame, its geometry (vertical-deck.mjs). + const selected = stackedDeckWanted(picked.render) ? { ...picked, render: verticalRender(picked.render) } : picked; const entries = selected.timeline ?? []; const posts = Array.isArray(selected.posts) ? selected.posts : []; const [built, metas, linked] = await Promise.all([ @@ -988,8 +994,10 @@ const pick = (g) => (g ? { x: g.x, y: g.y, width: g.width, height: g.height } : * @returns {Promise<Array<Record<string, any>>>} */ export async function composePlayLayers(project, variant, schedule, render, { srcOf, compose = composeChrome }) { - const { playModules } = await import("umtool-report-to-video/modules"); - const mods = playModules().filter((m) => m.on(schedule, render)); + const { playModules, verticalFormOf } = await import("umtool-report-to-video/modules"); + // The stacked vertical deck draws only the modules with a vertical form (vertical-deck.mjs), as its build does. + const stacked = stackedOn(render); + const mods = playModules().filter((m) => m.on(schedule, render) && (!stacked || verticalFormOf(m))); if (!mods.length) return []; const total = Number(schedule.total) || 0; const rows = await composeLayerPreviews(project, variant, schedule, mods.map((m) => m.id), render, { compose }); diff --git a/umtool/lib/report/verticalCli.mjs b/umtool/lib/report/verticalCli.mjs @@ -28,7 +28,7 @@ export const VERTICAL_USAGE = [ " [--clip full|framed|quote] [--post card|stack|media] [--side split|overlay]", " [--hook title|section|\"<a line of the cut's own copy>\"] [--captions l|xl] [--lines 1|2]", " [--loudness -14] [--max 60] [--name N] [--out FILE] [--reframe] [--dry-run] [--json]", - " [--intro | --no-intro] [--no-outro]", + " [--intro | --no-intro] [--no-outro] [--deck stacked|bare]", "", "A vertical short (1080x1920, the take's fps) of a take's items: a reel's beats (promo/<r>-beats.json, as", "`umtool trailer --reel` reads them), a beats file, or whole items. Built natively: each clip cut again in", @@ -50,11 +50,14 @@ export const VERTICAL_USAGE = [ "else boot-dark with the mark on the chime); a reel whose `intro` is on opens on it too (its own intro when it", "has one; --no-intro: not). A reel whose `outro` is on ends on its card, laid out 9:16 inside the safe area", "(--no-outro: not). Both are counted in the length the --max note reads.", + "--deck stacked (the default for a cut with a deck: render.vertical.deck) keeps the deck in 9:16 -- the rail", + "under the top band, the picture at full width, the captions under it, the instruments in two columns, the", + "source line and its QR above the bottom band; --deck bare is the vertical with no deck, as it first shipped.", ].join("\n"); class CliError extends Error {} -const VALUED = new Set(["--take", "--reel", "--beats", "--items", "--clip", "--post", "--side", "--hook", "--captions", "--lines", "--loudness", "--max", "--name", "--out"]); +const VALUED = new Set(["--take", "--reel", "--beats", "--items", "--clip", "--post", "--side", "--hook", "--captions", "--lines", "--loudness", "--max", "--name", "--out", "--deck"]); const BOOL = new Set(["--reframe", "--landscape", "--dry-run", "--json", "--help", "--intro", "--no-intro", "--no-outro"]); function parse(args) { @@ -78,6 +81,7 @@ function parse(args) { export function knobsOfFlags(flags) { /** @type {Record<string, any>} */ const k = {}; + if (flags["--deck"]) k.deck = flags["--deck"]; if (flags["--clip"]) k.clip = flags["--clip"]; if (flags["--post"]) k.post = flags["--post"]; if (flags["--side"]) k.side = flags["--side"]; diff --git a/umtool/report-to-video/build-video.mjs b/umtool/report-to-video/build-video.mjs @@ -229,6 +229,10 @@ import { verticalPostBox, verticalPostEntry, verticalRender, } from "./vertical.mjs"; import { renderSideCard, sideFitFilter } from "./side-card.mjs"; +// THE STACKED VERTICAL DECK (vertical-deck.mjs): a 9:16 cut that keeps its deck -- the picture at full width, the +// captions under it, a clip's two crops, a post item's hero card -- and the modules it leaves out. +import { ENLARGE_WARN, clipTwoCrop, leftOutWords, stackedCaptionGeo, stackedGeometry, stackedOn, twoCropEnlargement, twoCropGraph } from "./vertical-deck.mjs"; +import { verticalFormOf } from "./modules/index.mjs"; import { TRAILER_AUDIO, trailerHitsGraph } from "./trailer-hits.mjs"; import { planContext, planContextOf } from "./post-conversation.mjs"; @@ -476,6 +480,22 @@ export function deckFraming(render, { feed = false, picture = [] } = {}) { }; } +/** + * A post item's box in the stacked vertical deck (vertical-deck.mjs layout 4): + * its card from under the rail down to the panel's top, the frame's ground + * round it -- the rail, the counters under it and the date line are the + * deck's page. `{ box, place }` as verticalPostBox gives them. + */ +export function stackedPostFraming(render) { + const g = stackedGeometry(render); + const c = g.post.card; + const bg = String(render?.palette?.bg ?? "#12100c"); + return { + box: { x: c.x, y: c.y, width: c.width, height: c.height }, + place: [`pad=${g.W}:${g.H}:${c.x}:${c.y}:color=${bg}`, "setsar=1", `fps=${render.fps ?? 30}`], + }; +} + /** `deckFraming`'s two runs joined: a whole picture into the box, then the frame. */ export function deckFramingFilter(render, opts = {}) { const { fit, place } = deckFraming(render, opts); @@ -1783,7 +1803,7 @@ async function buildClipSegment(entry, meta, render, dirs, opts, chrome, nodes, // A VERTICAL cut (vertical.mjs): the clip in its layout -- full, framed or quote, or split / overlay when it // carries a side post -- its captions lit word by word, its tag and hook, as one ASS file. A source with no // picture keeps the plain path's poster. - if (dirs.vertical && media.hasVideo) { + if (dirs.vertical && !dirs.vertical.stacked && media.hasVideo) { const layout = clipVerticalLayout(entry, render); const geo = clipGeometry(layout, render, width, height); const [sw, sh] = await probeDims(raw); @@ -1830,6 +1850,51 @@ async function buildClipSegment(entry, meta, render, dirs, opts, chrome, nodes, return seg; } + // THE STACKED VERTICAL DECK (vertical-deck.mjs): a clip with two crops (`vertical.layout: "twocrop"`) is the + // frame's ground with crop one over the strip and crop two under it; its captions over crop two's foot. Its + // side post and its poster are the plain deck's (a source with no picture plays there). + const twoCrop = dirs.vertical?.stacked && media.hasVideo ? clipTwoCrop(entry) : null; + if (twoCrop) { + const [sw, sh] = await probeDims(raw); + const fr = framing ?? segmentFraming(render); + const inputs = cutArgs(raw, segA, segB); + let ain = "[0:a]"; + if (soundInput) { + ain = "[1:a]"; + inputs.push(...soundInput); + } + const g = gapped(ain); + const grow = twoCropEnlargement(twoCrop, sw, sh, render); + grow.forEach((x, i) => { + if (x > ENLARGE_WARN) EMIT("note", { message: `${entry.id}: its crop ${i + 1} is drawn ${x}× its source's pixels (past ${ENLARGE_WARN}×: it will look soft) -- a wider crop, or a sharper source` }); + }); + const graph = twoCropGraph({ crops: twoCrop, srcW: sw, srcH: sh, render, blur: await blurPicture(sw, sh), fps: render.fps }); + const cap = dirs.look + ? await segmentCaptions({ + entry, provenance, look: dirs.look, render, outDir, from: cutRecord.start, seconds: segSeconds, bottom: 0, gaps: cutRecord.gaps ?? [], + vertical: { geo: stackedCaptionGeo(render, { twocrop: true }), tag: null, hook: null, side: null }, + }) + : null; + cutRecord.vertical = { layout: "twocrop", crops: twoCrop, width, height, enlarged: grow, ...(cap ? { captions: cap.lines } : {}) }; + await encodeClipSegment({ + seg, outDir, render, opts, id: entry.id, record: { ...cutRecord, framing: fr }, + argv: [ + "-nostdin", "-v", "error", "-y", + ...inputs, + "-filter_complex", [ + ...g.parts, + ...levelParts(null, g.a), + `${g.v}${graph}[vp]`, + cap ? `[vp]${cap.filter}[v]` : "[vp]null[v]", + ].join(";"), + "-map", "[v]", "-map", audioMap, + ...encodeArgs(render), + seg, + ], + }); + return seg; + } + if (deckOn(render)) { const fr = framing ?? segmentFraming(render); const pst = await poster(fr.box, 1); @@ -1840,6 +1905,15 @@ async function buildClipSegment(entry, meta, render, dirs, opts, chrome, nodes, const sideInput = sideGeo ? await sideCard(sideGeo.w, sideGeo.h) : []; const sideIdx = 1 + (pst ? 1 : 0) + (soundInput ? 1 : 0); const framed = `${pst ? "[pic]" : g.v}${deckFramingFilter(render, { feed: fr.layout === "feed", picture })}`; + // The stacked vertical deck's captions (vertical-deck.mjs): under the picture, each word lit, over the frame. + const vcap = dirs.vertical?.stacked && dirs.look + ? await segmentCaptions({ + entry, provenance, look: dirs.look, render, outDir, from: cutRecord.start, seconds: segSeconds, bottom: 0, gaps: cutRecord.gaps ?? [], + vertical: { geo: stackedCaptionGeo(render), tag: null, hook: null, side: null }, + }) + : null; + if (vcap) cutRecord.vertical = { layout: "stacked", width, height, captions: vcap.lines }; + const capped = (label) => (vcap ? [`${label}[vcx]`, `[vcx]${vcap.filter}[v]`] : null); // The box it was framed into, so --chrome-only can refuse another layout's. await encodeClipSegment({ seg, outDir, render, opts, id: entry.id, record: { ...cutRecord, framing: fr }, @@ -1853,8 +1927,8 @@ async function buildClipSegment(entry, meta, render, dirs, opts, chrome, nodes, ...g.parts, ...levelParts(pst ? pst.parts : null, g.a), ...(sideGeo - ? [`${framed}[vb]`, `[${sideIdx}:v]${sideFitFilter(sideGeo.w, sideGeo.h)}[vsc]`, `[vb][vsc]${landscapeSideOverlay(sideGeo, sideUp, render.width)}[v]`] - : [`${framed}[v]`]), + ? [`${framed}[vb]`, `[${sideIdx}:v]${sideFitFilter(sideGeo.w, sideGeo.h)}[vsc]`, ...(capped(`[vb][vsc]${landscapeSideOverlay(sideGeo, sideUp, render.width)}`) ?? [`[vb][vsc]${landscapeSideOverlay(sideGeo, sideUp, render.width)}[v]`])] + : capped(framed) ?? [`${framed}[v]`]), ].join(";"), "-map", "[v]", "-map", audioMap, ...encodeArgs(render), @@ -5835,8 +5909,16 @@ async function renderDeck({ manifestPath, render, outDir, variant, schedule, fro // will capture -- the overlay order is the jobs' order, whatever order // they finish in. const jobs = []; + // THE STACKED VERTICAL DECK (vertical-deck.mjs): each page composed at the build's own render (a `--vertical` + // build of a landscape manifest is not the manifest's), and a module with no vertical form left out, said so. + const stacked = stackedOn(render); + const own = verticalOn(render) ? { render } : {}; for (const mod of deckOverlays()) { if (!mod.on(schedule, render)) continue; + if (stacked && !verticalFormOf(mod)) { + if (duration == null) EMIT("note", { message: leftOutWords(mod.id) }); + continue; + } // The shell's events name no region (the deck's, as they always have). const named = mod.region === "deck" ? {} : { region: mod.region }; if (mod.kind === "overlay-whole") { @@ -5844,7 +5926,7 @@ async function renderDeck({ manifestPath, render, outDir, variant, schedule, fro EMIT("chrome", { phase: "compose", ...named, ...win }); const t1 = Date.now(); const r = await composeChrome({ - manifestPath, outDir, variant, region: mod.region, doRender: true, + manifestPath, outDir, variant, region: mod.region, doRender: true, ...own, fps: render.fps, workers: CHROME_WORKERS, lease, quality: "high", format: "png-sequence", ...win, // The deck's frames the chunked encode will read, and only those (deckWant). ...(mod.region === "deck" && drawOnly && duration == null ? { want: drawOnly } : {}), @@ -5873,7 +5955,7 @@ async function renderDeck({ manifestPath, render, outDir, variant, schedule, fro EMIT("chrome", { phase: "compose", region: mod.region, ...(pr.segment !== undefined ? { segment: pr.segment } : {}) }); const t1 = Date.now(); const p = await composeChrome({ - manifestPath, outDir, variant, region: mod.region, ...(pr.segment !== undefined ? { window: pr.window } : {}), doRender: true, + manifestPath, outDir, variant, region: mod.region, ...(pr.segment !== undefined ? { window: pr.window } : {}), doRender: true, ...own, fps: render.fps, workers: CHROME_WORKERS, lease, quality: "high", format: "png-sequence", }); if (p.frames !== pr.frames || p.frameCount !== pr.frameCount) { @@ -6697,7 +6779,7 @@ export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly if (opts.short) dirs.short = { id: opts.short }; // A vertical cut's hooks may name a clip's section: the deck's markers, read from the cut as written. // A short of a take's items (umtool vertical) passes the WHOLE take's sections: its own timeline is a part of it. - if (vertical) dirs.vertical = { on: true, sections: opts.verticalSections ? new Map(Object.entries(opts.verticalSections)) : sectionTitlesOf(whole) }; + if (vertical) dirs.vertical = { on: true, sections: opts.verticalSections ? new Map(Object.entries(opts.verticalSections)) : sectionTitlesOf(whole), stacked: stackedOn(render) }; // A project's out/ first, through ensureOutDir: with UMTOOL_MEDIA_DIR set it // is a link to the media root, and the recursive mkdirs below would @@ -6993,7 +7075,8 @@ export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly // A post item (post-render.mjs): its card drawn from the archived post, its attachments laid in. EMIT("card", { id: entry.id, i, n: entries.length }); const fr = deck ? framing ?? segmentFraming(render) : null; - const df = fr ? deckFraming(render, { feed: fr.layout === "feed" }) : vertical ? verticalPostBox(render) : null; + // The stacked vertical deck (vertical-deck.mjs): the hero card, from under the rail to the panel's top. + const df = dirs.vertical?.stacked ? stackedPostFraming(render) : fr ? deckFraming(render, { feed: fr.layout === "feed" }) : vertical ? verticalPostBox(render) : null; const seg = await buildPostSegment(entry, { render, outDir, manifestDir, box: df ? { width: df.box.width, height: df.box.height } : { width: render.width, height: render.height }, diff --git a/umtool/report-to-video/chrome-instruments.mjs b/umtool/report-to-video/chrome-instruments.mjs @@ -14,6 +14,7 @@ // frame whose values did not move keys as the frame before it -- the needle at // rest between two weights is captured once, not once a frame. import { cueTime, deckChoreography, even, instrumentsGeometry, railGap } from "./deck.mjs"; +import { stackedGeometry, stackedOn, stackedStandDowns } from "./vertical-deck.mjs"; import { mix, rgba } from "./chrome-deck.mjs"; import { finaleLayout } from "./chrome-finale.mjs"; import { FINALE_MOTION } from "./finale.mjs"; @@ -82,13 +83,47 @@ function windowOf(schedule, opts, what) { function withDeck(L, schedule, render, k) { L.set(k, { autoAlpha: 1 }); const fin = Number.isFinite(schedule?.finale?.from) ? schedule.finale.from : null; + const stacked = stackedOn(render); + const shown = []; for (const v of deckChoreography(schedule, render).visibility) { const [a, b] = v.at; // Going under the finale: over its grow, as the dial's finale comes in (dialFinaleHtml) -- a crossfade. const intoFinale = v.hide && fin !== null && Math.abs(a - fin) < 0.6; const dur = intoFinale ? Math.max(b - a, FINALE_MOTION.grow) : Math.max(INSTANT, b - a); - L.add(k, a, dur, { autoAlpha: v.hide ? 0 : 1 }, v.hide ? "power1.in" : "power2.out"); + if (!stacked) L.add(k, a, dur, { autoAlpha: v.hide ? 0 : 1 }, v.hide ? "power1.in" : "power2.out"); + else shown.push({ at: a, dur, hide: v.hide }); } + if (!stacked) return; + // THE STACKED VERTICAL DECK (vertical-deck.mjs): the panel stands down over a post item (its card takes the + // room) and a twocrop clip (its strip carries the numbers) -- out over the join into it, back over the join out. + const D = Number(schedule.transition) || 0; + const m = Math.max(D, 0.3); + for (const sd of mergedSpans(stackedStandDowns(schedule))) { + shown.push({ at: Math.max(0, sd.from), dur: m, hide: true }); + if (sd.to < (schedule.total ?? Infinity) - 0.05) shown.push({ at: sd.to, dur: m, hide: false }); + } + // Each change once, in time: a stand-down inside a span the deck is already away for adds nothing. + shown.sort((p, q) => p.at - q.at); + let hidden = false; + let depth = 0; + for (const v of shown) { + depth += v.hide ? 1 : -1; + const want = depth > 0; + if (want === hidden) continue; + hidden = want; + L.add(k, v.at, v.dur, { autoAlpha: want ? 0 : 1 }, want ? "power1.in" : "power2.out"); + } +} + +/** Spans that touch or overlap, as one. */ +function mergedSpans(spans) { + const out = []; + for (const sp of [...spans].sort((a, b) => a.from - b.from)) { + const last = out[out.length - 1]; + if (last && sp.from <= last.to + 0.05) last.to = Math.max(last.to, sp.to); + else out.push({ ...sp }); + } + return out; } /** Blocks shown one at a time: block j from `list[j].t` to the next one's. */ @@ -784,6 +819,12 @@ export function trailYields(schedule, render) { */ export function dialFinaleGeometry(schedule, render) { if (!schedule?.finale) return null; + // THE STACKED VERTICAL DECK (vertical-deck.mjs): the instrument column over the picture's room, its title where + // the rail stands -- the landscape finale's page is not drawn there, so this one is opaque. + if (stackedOn(render)) { + const f = stackedGeometry(render).finale; + return { x: f.title.x, y: f.title.y, width: f.column.width, height: 2 * Math.floor((f.column.y + f.column.height - f.title.y) / 2) }; + } const g = finaleLayout(schedule, render).geo; if (g.stats) return null; const kh = g.H / 1080; @@ -883,13 +924,24 @@ export function dialFinaleHtml(schedule, render, window, opts = {}) { // The claim ghosts STAY: the finale is the summary, and the residue of every number he gave is the point of it -- // each tick at its count at the cut's end, in with the finale's grow under the needle's drop, no pulses. const ghosts = ghostsOf(M, render, colors); - const size = even(Math.min(H, Math.round(W * 0.56))); + // Portrait (the stacked vertical deck): its title on top, the dial large in a card under it, the odometer and + // NET under that, all on an opaque ground (no landscape finale page under it). Landscape: the dial beside the wheels. + const portrait = stackedOn(render); + const u = W / 912; + const titleH = portrait ? Math.round(64 * u) : 0; + const cardH = portrait ? even(Math.round(H * 0.46)) : 0; + const size = portrait ? even(Math.min(W * 0.62, cardH - Math.round(36 * u))) : even(Math.min(H, Math.round(W * 0.56))); const k = size / 524; - const dial = dialParts({ size, ox: 0, oy: Math.floor((H - size) / 2), scale: M.scale, cfg, colors, fonts, track, marks, lines, ghosts, prefix: "f", preState: false }); - const rw = W - size - Math.round(40 * k); + const dial = dialParts({ + size, ox: portrait ? Math.floor((W - size) / 2) : 0, oy: portrait ? titleH + Math.round(18 * u) + Math.floor((cardH - size) / 2) : Math.floor((H - size) / 2), + scale: M.scale, cfg, colors, fonts, track, marks, lines, ghosts, prefix: "f", preState: false, + }); + const rw = portrait ? W - Math.round(48 * u) : W - size - Math.round(40 * k); const top = Math.max(Number(M.totals?.lost) || 0, nums.lost); const wheels = wheelCount(top); - const ob = { x: size + Math.round(40 * k), y: Math.floor((H - size) / 2) + Math.round(24 * k), width: rw }; + const ob = portrait + ? { x: Math.round(24 * u), y: titleH + Math.round(18 * u) + cardH + Math.round(34 * u), width: rw } + : { x: size + Math.round(40 * k), y: Math.floor((H - size) / 2) + Math.round(24 * k), width: rw }; const odo = odometerParts({ W: rw, H: H - ob.y, u: Math.min(1, rw / 420), cfg: { ...ocfg, runs: true }, colors, fonts, track: { lost: [{ t: from, total: 0, runs: 0 }, { t: A + 0.6, total: nums.lost, runs: nums.runs }] }, wheels, @@ -920,12 +972,19 @@ export function dialFinaleHtml(schedule, render, window, opts = {}) { L.set("onet", { autoAlpha: 0 }); L.add("onet", A + 3.2, 0.5, { autoAlpha: 1 }, "power1.out"); const { init, cues } = L.build(); + const ground = portrait ? ` + .fg { position: absolute; inset: 0; background: ${colors.bg}; } + .ftitle { position: absolute; left: 0; top: 0; height: ${titleH}px; line-height: ${titleH}px; font-family: ${fontStack(fonts, "display")}; + font-size: ${Math.round(40 * u)}px; letter-spacing: 0.06em; color: ${colors.accent}; white-space: nowrap; } + .fcard { position: absolute; left: 0; top: ${titleH + Math.round(18 * u)}px; width: ${W}px; height: ${cardH}px; border-radius: ${Math.round(24 * u)}px; + background: ${colors.card}; box-shadow: inset 0 0 0 1px ${colors.rule}; }` : ""; + const groundHtml = portrait ? `<div class="fg"></div><div class="ftitle">${esc(opts.title ?? "THE RECORD SO FAR")}</div><div class="fcard"></div>` : ""; return pageHtml({ id: "dial-finale", W, H, fps, fonts, gsap: opts.gsap, data: { from, dur, init, cues }, - css: `#rt { position: absolute; inset: 0; }${dial.css} + css: `#rt { position: absolute; inset: 0; }${ground}${dial.css} .ob { position: absolute; left: ${ob.x}px; top: ${ob.y}px; width: ${ob.width}px; height: ${H - ob.y}px; }${odo.css}`, - body: `<div id="rt" data-k="rt">${dial.html}<div class="ob">${odo.html}</div></div>`, + body: `<div id="rt" data-k="rt">${groundHtml}${dial.html}<div class="ob">${odo.html}</div></div>`, }); } diff --git a/umtool/report-to-video/chrome-story.mjs b/umtool/report-to-video/chrome-story.mjs @@ -15,7 +15,7 @@ // that fills as the cut plays: a row comes in on its first clip, its // outcome on the outcome's clip (else the end of its last evidence clip). // Each STATE of the ledger is its own block, shown over exactly its span. -import { deckGeometry, feedGeometry } from "./deck.mjs"; +import { deckGeometry, feedGeometry, pictureK } from "./deck.mjs"; import { rgba } from "./chrome-deck.mjs"; import { compileCues, cuePageHtml, dateText, esc, joinSpans, r4, segmentSpans, spanEvents, INSTANT } from "./chrome-cues.mjs"; import { CHAPTER_DEFAULTS, PAIR_DEFAULTS, STATUS_DEFAULTS } from "./modules/story-settings.mjs"; @@ -28,7 +28,8 @@ export function footageBox(render, { feed = false } = {}) { return { x: f.x, y: f.y, width: f.width, height: f.height }; } -const scaleOf = (render) => (render?.width ?? 1920) / 1920; +// Over the footage at the frame's share of its 1920 design (pictureK: the stacked vertical deck's own size). +const scaleOf = (render) => pictureK(render, render?.width ?? 1920); const pxOf = (render) => (v) => Math.max(1, Math.round(v * scaleOf(render))); const even = (v) => 2 * Math.round(v / 2); diff --git a/umtool/report-to-video/chrome-vdeck.mjs b/umtool/report-to-video/chrome-vdeck.mjs @@ -0,0 +1,350 @@ +// THE STACKED VERTICAL DECK'S PAGE (vertical-deck.mjs): the deck's shell, in +// 9:16. One HyperFrames page over the whole frame, transparent but for what it +// draws -- the rail under the top band (the section's name, its progress +// segments, "2 / 5"), each segment's source block above the bottom band (the +// QR, channel · title · date · time; a post item's big date line and who +// posted it), the tally's cells when the cut counts, the site's wordmark dim in +// the bottom band -- and, for a twocrop clip, the source line over the rail at +// the top, the one-row strip of the instruments between its crops and the QR +// small and low-left. +// +// The schedule is the landscape deck's (deck.mjs deckSchedule: the same +// segments, the same handovers, the same stamps); only where things stand is +// this page's. The pictures (the footage, the crops, a post's card) are the +// segments' own; the instruments are their own pages in the panel. +// +// PURE, as the other pages: a schedule and a render block in, an HTML string +// out (measure-draw.mjs pageHtml, its cue interpreter -- every state a block +// shown over exactly its span, so a frame whose words did not move keys as the +// frame before it). + +import { deckChoreography, pipSegments, resolveDeck, resolveSectionTitle, stackedCounterOn } from "./deck.mjs"; +import { mix, rgba } from "./chrome-deck.mjs"; +import { resolveCounter } from "./counter.mjs"; +import { tallyLabelOf, tallyOf, tallySteps } from "./factcheck.mjs"; +import { resolveDial, resolveOdometer } from "./instruments.mjs"; +import { cueList, esc, fmtSigned, fmtWeight, INSTANT, measureTrack, pageHtml, r4 } from "./measure-draw.mjs"; +import { stackedGeometry } from "./vertical-deck.mjs"; + +const HEX_RE = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/; + +/** The deck's text motion in the stacked deck: a block out, the next in (the landscape deck's `motion`). */ +const swap = (deck) => ({ out: deck.motion?.out ?? 0.3, in: deck.motion?.in ?? 0.45 }); + +/** + * The rail's sections: the markers (`deck.markers`, each after a pip's clip) + * split the pipped segments; the first is `sectionTitle.first`'s. Each + * `{ label, color, pips: [segment index…] }`, and `of` the section of each + * pipped segment. One section (no markers): the clips' count is the rail. + */ +export function stackedSections(schedule, render) { + const d = resolveDeck(render); + const pal = render?.palette ?? {}; + const st = resolveSectionTitle(render); + const pipped = pipSegments(schedule); + const byColor = d.pip?.color === "section"; + const hexOf = (key, fallback) => (typeof key === "string" && HEX_RE.test(key) ? key : (key && pal[key]) || fallback); + const after = new Map((Array.isArray(d.markers) ? d.markers : []) + .filter((m) => m && typeof m.after === "string" && m.level !== 2) + .map((m) => [m.after, m])); + const sections = [{ label: st?.first ?? "", color: byColor ? hexOf(d.pip?.sectionColor0, pal.accent ?? "#22AB83") : pal.accent ?? "#22AB83", pips: [] }]; + pipped.forEach((s, j) => { + sections[sections.length - 1].pips.push(j); + const m = after.get(s.id); + if (m && j < pipped.length - 1) { + sections.push({ label: String(m.label ?? "").trim(), color: byColor ? hexOf(m.color, pal.fg ?? "#ffffff") : pal.accent ?? "#22AB83", pips: [] }); + } + }); + const of = []; + sections.forEach((sec, i) => sec.pips.forEach((j) => { of[j] = i; })); + return { sections, of, pipped }; +} + +/** When each pipped segment takes the rail: the first at 0, each after it at its handover (its start plus half the join). */ +function railTimes(schedule) { + const D = Number(schedule.transition) || 0; + return pipSegments(schedule).map((s, j) => (j === 0 ? 0 : r4(s.start + D / 2))); +} + +/** The site's name the bottom band's wordmark says: its host's first label ("jeralyzer.pages.dev" → "JERALYZER"). */ +export function wordmarkOf(provenance) { + const o = String(provenance?.siteOrigin ?? "").trim(); + if (!o) return ""; + try { + return new URL(o).hostname.split(".")[0].toUpperCase(); + } catch { + return ""; + } +} + +/** The values a twocrop clip's strip shows at `t`: what he says he weighs, what he says he has lost, NET. */ +function stripCells(M, render) { + if (!M) return []; + const track = measureTrack(M); + const dial = resolveDial(render); + const odo = resolveOdometer(render); + const at = (list, t) => [...list].reverse().find((x) => x.t <= t + 1e-6) ?? list[0] ?? null; + const cells = []; + if (dial) cells.push({ label: dial.label, value: (t) => { const c = at(track.current, t); return Number.isFinite(c?.value) ? `${c.qualifier ?? ""}${fmtWeight(c.value)}` : "NOT YET"; } }); + if (odo) cells.push({ label: odo.label.replace(/^POUNDS /, ""), value: (t) => fmtWeight(at(track.lost, t)?.total ?? 0) }); + if (odo?.net) { + cells.push({ label: "NET", value: (t) => { + const n = at(track.net, t)?.net; + const f = typeof n?.from === "number" ? n.from : n?.from?.value; + const to = typeof n?.to === "number" ? n.to : n?.to?.value; + return Number.isFinite(f) && Number.isFinite(to) ? fmtSigned(to - f) : "—"; + } }); + } + const times = [...new Set([0, ...track.current.map((x) => x.t), ...track.lost.map((x) => x.t), ...track.net.map((x) => x.t)])].sort((a, b) => a - b); + return cells.map((c) => ({ label: c.label, runs: times.map((t) => ({ t, text: c.value(t) })).filter((r, i, all) => i === 0 || r.text !== all[i - 1].text) })); +} + +/** + * The stacked deck's page for the whole cut (or a window of it). `qrSrcs` = + * `{ <segment id>: "assets/qrNN.png" }`; `fonts` the deck's faces by name + * (DeckSans, DeckSansBold, MeasureDisplay, MeasureCond); `site` the + * wordmark's words. + */ +export function stackedDeckHtml(schedule, render, opts = {}) { + const deck = resolveDeck(render); + const pal = { bg: "#0F1312", fg: "#EDF0EC", muted: "#98A29B", accent: "#22AB83", amber: "#E8A33F", ...(render?.palette ?? {}) }; + const tally = tallyOf(schedule, render); + const g = stackedGeometry(render, { counter: stackedCounterOn(render) }); + const W = g.W, H = g.H; + const u = W / 1080; + const px = (v) => Math.round(v * u); + const fps = schedule.fps ?? render.fps ?? 30; + const fonts = opts.fonts ?? {}; + const qrSrcs = opts.qrSrcs ?? {}; + const from = Number(opts.from ?? 0); + const total = schedule.total; + const dur = opts.duration != null ? Number(opts.duration) : r4(total - from); + if (!(dur > 0)) throw new Error(`deck: nothing to render from ${from}s of a ${total}s cut`); + const windowed = from > 0 || Math.abs(dur - total) > 1e-6; + const D = Number(schedule.transition) || 0; + const m = swap(deck); + const segs = schedule.segments ?? []; + const display = fonts.MeasureDisplay ? "'MeasureDisplay', 'DeckSansBold', sans-serif" : "'DeckSansBold', sans-serif"; + const cond = fonts.MeasureCond ? "'MeasureCond', 'DeckSans', sans-serif" : "'DeckSans', sans-serif"; + const card = mix(pal.bg, pal.fg, 0.06); + const rule = mix(pal.bg, pal.fg, 0.16); + const L = cueList(fps); + + // ---- the page's visibility: the deck's own (away over a card, a teaser, the finale) ---- + L.set("rt", { autoAlpha: 1 }); + for (const v of deckChoreography(schedule, render).visibility) { + const [a, b] = v.at; + L.add("rt", a, Math.max(INSTANT, b - a), { autoAlpha: v.hide ? 0 : 1 }, v.hide ? "power1.in" : "power2.out"); + } + + // ---- each segment's span on the deck: from its handover in to the next one's ---- + const handIn = (i) => (i === 0 ? 0 : r4(segs[i].start + D / 2)); + const handOut = (i) => (i + 1 < segs.length ? r4(segs[i + 1].start + D / 2) : total); + const twocrop = (s) => s?.vlayout === "twocrop"; + const show = (k, i, { fade = true } = {}) => { + const a = handIn(i); + const b = handOut(i); + L.set(k, { autoAlpha: a <= 0 ? 1 : 0 }); + if (a > 0) L.add(k, a, fade ? m.in : INSTANT, { autoAlpha: 1 }, "power2.out"); + if (b < total - 1e-6) L.add(k, Math.max(a + INSTANT, b - (fade ? m.out : 0)), fade ? m.out : INSTANT, { autoAlpha: 0 }, "power1.in"); + }; + + // ---- the rail: the section's name, its progress, "2 / 5" -- and a twocrop clip's own over its source line ---- + const { sections, of, pipped } = stackedSections(schedule, render); + const times = railTimes(schedule); + const many = sections.length > 1; + const railBars = (pre) => sections.map((sec, i) => `<div class="bar" style="flex:${Math.max(1, sec.pips.length)}; background:${rgba(sec.color, 0.22)}"><div class="fill" data-k="${pre}f${i}" style="background:${sec.color}"></div></div>`).join(""); + const railLabels = (pre, cls) => sections.map((sec, i) => `<div class="${cls}" data-k="${pre}l${i}" style="color:${sec.color}">${esc(sec.label)}</div>`).join(""); + const counts = many + ? sections.map((_, i) => `<div class="rcount" data-k="rc${i}">${i + 1} / ${sections.length}</div>`).join("") + : pipped.map((_, j) => `<div class="rcount" data-k="rc${j}">${j + 1} / ${pipped.length}</div>`).join(""); + // The fills and the labels: a section filled to its share as each of its clips takes the rail, the ones before full. + for (const pre of ["r", "t"]) { + sections.forEach((_, i) => { + L.set(`${pre}f${i}`, { scaleX: 0, transformOrigin: "0% 50%" }); + L.set(`${pre}l${i}`, { autoAlpha: 0 }); + }); + } + (many ? sections : pipped).forEach((_, i) => L.set(`rc${i}`, { autoAlpha: 0 })); + let curSec = null; + pipped.forEach((_, j) => { + const s = of[j]; + const sec = sections[s]; + const share = (sec.pips.indexOf(j) + 1) / sec.pips.length; + const t = times[j]; + for (const pre of ["r", "t"]) { + if (curSec !== null && curSec !== s) { + L.add(`${pre}f${curSec}`, t, 0.35, { scaleX: 1 }, "power2.out"); + L.add(`${pre}l${curSec}`, t, 0.25, { autoAlpha: 0 }, "power1.in"); + } + L.add(`${pre}f${s}`, t, t <= 0 ? INSTANT : 0.5, { scaleX: r4(share) }, "power2.inOut"); + if (curSec !== s) L.add(`${pre}l${s}`, t, t <= 0 ? INSTANT : 0.3, { autoAlpha: 1 }, "power2.out"); + } + const ck = many ? s : j; + const prevCk = many ? curSec : j - 1; + if (prevCk !== null && prevCk >= 0 && prevCk !== ck) L.add(`rc${prevCk}`, t, INSTANT, { autoAlpha: 0 }); + if (prevCk !== ck) L.add(`rc${ck}`, t, INSTANT, { autoAlpha: 1 }); + curSec = s; + }); + // The rail itself: up but over a twocrop clip, whose own stands over its source line. + L.set("rail", { autoAlpha: 1 }); + L.set("top2", { autoAlpha: 0 }); + segs.forEach((s, i) => { + if (!twocrop(s)) return; + L.add("rail", handIn(i) - m.out, m.out, { autoAlpha: 0 }, "power1.in"); + L.add("top2", handIn(i), m.in, { autoAlpha: 1 }, "power2.out"); + if (handOut(i) < total - 1e-6) { + L.add("top2", handOut(i) - m.out, m.out, { autoAlpha: 0 }, "power1.in"); + L.add("rail", handOut(i), m.in, { autoAlpha: 1 }, "power2.out"); + } + }); + + // ---- each segment's source block ---- + const blocks = []; + const tops = []; + const strips = []; + const smallQrs = []; + const M = schedule.measure && Array.isArray(schedule.measure.state) ? schedule.measure : null; + const cellsAll = stripCells(M, render); + segs.forEach((s, i) => { + if (s.hideDeck) return; + const qr = qrSrcs[s.id] ?? null; + const k = `s${i}`; + if (twocrop(s)) { + // The source line over the rail at the top; the QR small and low-left; the instruments' strip between the crops. + const v = s.vsource ?? {}; + tops.push(`<div class="tline" data-k="${k}t"><span class="tch">${esc(v.channel || s.title || "")}</span><span class="tdt">${esc([v.date, v.clock].filter(Boolean).join(" · "))}</span></div>`); + show(`${k}t`, i); + if (qr) { + smallQrs.push(`<img class="qrs" data-k="${k}q" src="${esc(qr)}" alt="" />`); + show(`${k}q`, i); + } + if (cellsAll.length) { + const cells = cellsAll.map((c, ci) => { + const runs = c.runs.map((r, ri) => `<div class="sv" data-k="${k}c${ci}r${ri}">${esc(r.text)}</div>`).join(""); + c.runs.forEach((r, ri) => { + const a = r.t; + const b = c.runs[ri + 1]?.t ?? Infinity; + L.set(`${k}c${ci}r${ri}`, { autoAlpha: a <= 0 && b > 0 ? 1 : 0 }); + if (a > 0) L.add(`${k}c${ci}r${ri}`, a, INSTANT, { autoAlpha: 1 }); + if (Number.isFinite(b)) L.add(`${k}c${ci}r${ri}`, b, INSTANT, { autoAlpha: 0 }); + }); + return `<div class="scell"><div class="sl">${esc(c.label)}</div><div class="svs">${runs}</div></div>`; + }).join(""); + strips.push(`<div class="strip" data-k="${k}x" style="grid-template-columns: repeat(${cellsAll.length}, minmax(0, 1fr))">${cells}</div>`); + show(`${k}x`, i); + } + return; + } + let words; + if (s.type === "post") { + words = `<div class="pdate">${esc(s.title ?? "")}</div><div class="pwho">${esc(s.subtitle ?? "")}</div>`; + } else if (s.vsource) { + const v = s.vsource; + words = `<div class="ch">${esc(v.channel)}</div><div class="ti">${esc(v.title)}</div><div class="dt">${esc([v.date, v.clock].filter(Boolean).join(" · "))}</div>`; + } else { + words = `<div class="ch">${esc(s.title ?? "")}</div><div class="ti">${esc(s.subtitle ?? "")}</div>`; + } + const html = `<div class="src" data-k="${k}">${qr ? `<img class="qr" src="${esc(qr)}" alt="" />` : ""}<div class="words${qr ? "" : " noqr"}">${words}</div></div>`; + blocks.push(html); + show(k, i); + }); + + // ---- the tally: a cell per verdict the cut counts, its count over its label; under a post item's card ---- + let tallyHtml = ""; + if (tally?.length) { + const byId = resolveCounter(render).byId ?? {}; + const steps = tallySteps(schedule.factcheck?.stamps ?? [], tally); + const cells = tally.map((v, ci) => { + const vr = byId[v] ?? {}; + const color = HEX_RE.test(vr.color ?? "") ? vr.color : pal.accent; + const runs = [{ at: 0, n: 0 }, ...steps.filter((x) => x.verdict === v).map((x) => ({ at: x.at, n: x.count }))]; + const nums = runs.map((r, ri) => { + const kk = `tn${ci}r${ri}`; + const b = runs[ri + 1]?.at ?? Infinity; + L.set(kk, { autoAlpha: r.at <= 0 && b > 0 ? 1 : 0 }); + if (r.at > 0) L.add(kk, r.at, INSTANT, { autoAlpha: 1 }); + if (Number.isFinite(b)) L.add(kk, b, INSTANT, { autoAlpha: 0 }); + return `<div class="tnum" data-k="${kk}" style="color:${color}">${r.n}</div>`; + }).join(""); + const label = tallyLabelOf(vr) ?? vr.label ?? v; + return `<div class="tcell" style="border-color:${rgba(color, 0.5)}"><div class="tlab">${esc(label)}</div><div class="tnums">${nums}</div></div>`; + }).join(""); + tallyHtml = `<div class="tally" data-k="tal">${cells}</div>`; + // Under a post item's card while it is up; over the source block otherwise. + const dy = g.post.counters.y - (g.counters?.y ?? g.post.counters.y); + L.set("tal", { y: 0 }); + segs.forEach((s, i) => { + if (s.type !== "post" || !dy) return; + L.add("tal", handIn(i) - m.out, m.out + m.in, { y: dy }, "power2.inOut"); + if (handOut(i) < total - 1e-6) L.add("tal", handOut(i) - m.out, m.out + m.in, { y: 0 }, "power2.inOut"); + }); + } + + const site = typeof opts.site === "string" ? opts.site : ""; + const { init, cues } = L.build(); + const sq = g.source.qr; + const st = g.source.text; + const tq = g.twocrop.qr; + const t2 = g.twocrop.top; + const strip = g.twocrop.strip; + const ct = g.counters ?? { x: g.safe.x0, y: g.source.y - px(100), width: g.safe.x1 - g.safe.x0, height: px(80) }; + const css = ` + #rt { position: absolute; inset: 0; } + .rail, .top2 { position: absolute; left: ${g.rail.x}px; top: ${g.rail.y}px; width: ${g.rail.width}px; height: ${g.rail.height}px; } + .top2 { top: ${t2.y}px; height: ${t2.height}px; } + .rlab, .rcount, .tlab2 { position: absolute; top: 0; height: ${g.rail.label}px; line-height: ${g.rail.label}px; white-space: nowrap; overflow: hidden; } + .rlab { left: 0; right: ${px(130)}px; font-family: ${display}; font-size: ${px(40)}px; letter-spacing: 0.06em; text-transform: uppercase; text-overflow: ellipsis; } + .rcount { right: 0; font-family: 'DeckSans', sans-serif; font-size: ${px(24)}px; color: ${pal.muted}; font-variant-numeric: tabular-nums; } + .bars { position: absolute; left: 0; right: 0; bottom: 0; height: ${g.rail.bar}px; display: flex; gap: ${px(8)}px; } + .bar { position: relative; height: 100%; border-radius: ${px(2)}px; overflow: hidden; } + .fill { position: absolute; inset: 0; } + .top2 .bars { bottom: ${px(4)}px; right: ${px(260)}px; } + .tlab2 { top: auto; bottom: ${px(-8)}px; right: 0; width: ${px(250)}px; text-align: right; font-family: ${display}; font-size: ${px(30)}px; letter-spacing: 0.06em; text-transform: uppercase; text-overflow: ellipsis; } + .tline { position: absolute; left: 0; top: 0; right: 0; height: ${px(44)}px; line-height: ${px(44)}px; white-space: nowrap; overflow: hidden; } + .tch { font-family: 'DeckSansBold', sans-serif; font-size: ${px(30)}px; color: ${pal.fg}; margin-right: ${px(16)}px; } + .tdt { font-family: 'DeckSans', sans-serif; font-size: ${px(27)}px; color: ${pal.accent}; font-variant-numeric: tabular-nums; } + .src { position: absolute; left: ${g.source.x}px; top: ${g.source.y}px; width: ${g.source.width}px; height: ${g.source.height}px; + border-top: ${Math.max(1, px(2))}px solid ${rule}; } + .src .qr { position: absolute; left: 0; top: ${sq.y - g.source.y}px; width: ${sq.size}px; height: ${sq.size}px; border-radius: ${px(8)}px; + image-rendering: pixelated; box-shadow: 0 0 0 1px ${rgba(pal.fg, 0.25)}; } + .src .words { position: absolute; left: ${st.x - g.source.x}px; top: ${st.y - g.source.y}px; width: ${st.width}px; height: ${st.height}px; + display: flex; flex-direction: column; justify-content: center; gap: ${px(6)}px; } + .src .words.noqr { left: 0; width: ${g.source.width}px; } + .src .ch { font-family: 'DeckSansBold', sans-serif; font-size: ${px(32)}px; color: ${pal.fg}; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } + .src .ti { font-family: 'DeckSans', sans-serif; font-size: ${px(28)}px; color: ${mix(pal.muted, pal.fg, 0.45)}; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } + .src .dt { font-family: 'DeckSans', sans-serif; font-size: ${px(28)}px; color: ${pal.accent}; font-variant-numeric: tabular-nums; white-space: nowrap; } + .src .pdate { font-family: ${display}; font-size: ${px(56)}px; line-height: 1; color: ${pal.fg}; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } + .src .pwho { font-family: 'DeckSans', sans-serif; font-size: ${px(28)}px; color: ${mix(pal.muted, pal.fg, 0.45)}; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } + .qrs { position: absolute; left: ${tq.x}px; top: ${tq.y}px; width: ${tq.size}px; height: ${tq.size}px; border-radius: ${px(6)}px; opacity: 0.9; image-rendering: pixelated; } + .strip { position: absolute; left: 0; top: ${strip.y}px; width: ${W}px; height: ${strip.height}px; background: ${card}; + border-top: 1px solid ${rule}; border-bottom: 1px solid ${rule}; display: grid; padding: 0 ${W - g.safe.x1}px 0 ${g.safe.x0}px; } + .scell { position: relative; display: flex; flex-direction: column; justify-content: center; gap: ${px(4)}px; padding-left: ${px(20)}px; border-left: 1px solid ${rule}; } + .scell:first-child { padding-left: 0; border-left: 0; } + .scell .sl { font-family: ${cond}; font-size: ${px(21)}px; letter-spacing: 0.08em; color: ${pal.muted}; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } + .scell .svs { position: relative; height: ${px(42)}px; } + .scell .sv { position: absolute; left: 0; top: 0; font-family: ${display}; font-size: ${px(38)}px; line-height: ${px(42)}px; color: ${pal.fg}; white-space: nowrap; } + .tally { position: absolute; left: ${ct.x}px; top: ${ct.y}px; width: ${ct.width}px; height: ${ct.height}px; display: flex; gap: ${px(12)}px; } + .tcell { position: relative; flex: 0 1 ${px(230)}px; border: 1px solid; border-radius: ${px(10)}px; background: ${rgba(pal.bg, 0.85)}; + display: flex; flex-direction: column; justify-content: center; padding: 0 ${px(16)}px; } + .tlab { font-family: ${cond}; font-size: ${px(20)}px; letter-spacing: 0.08em; color: ${pal.muted}; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } + .tnums { position: relative; height: ${px(40)}px; } + .tnum { position: absolute; left: 0; top: 0; font-family: ${display}; font-size: ${px(36)}px; line-height: ${px(40)}px; font-variant-numeric: tabular-nums; } + .mark { position: absolute; left: ${g.wordmark.x}px; top: ${g.wordmark.y}px; font-family: ${display}; font-size: ${g.wordmark.size}px; + letter-spacing: 0.12em; color: ${mix(pal.bg, pal.fg, 0.24)}; white-space: nowrap; }`; + const body = `<div id="rt" data-k="rt"> + <div class="rail" data-k="rail">${railLabels("r", "rlab")}${counts}<div class="bars">${railBars("r")}</div></div> + <div class="top2" data-k="top2">${tops.join("")}<div class="bars">${railBars("t")}</div>${railLabels("t", "tlab2")}</div> + ${blocks.join("")} + ${strips.join("")} + ${smallQrs.join("")} + ${tallyHtml} + ${site ? `<div class="mark">${esc(site)}</div>` : ""} + </div>`; + return pageHtml({ + id: "deck", W, H, fps, fonts, gsap: opts.gsap, + data: { total: r4(total), window: windowed ? { from: r4(from), dur: r4(dur) } : null, init, cues }, + css, + body, + }); +} diff --git a/umtool/report-to-video/compose-chrome.mjs b/umtool/report-to-video/compose-chrome.mjs @@ -47,6 +47,7 @@ import { FRAME_KEY_REGIONS, frameKeys } from "./frame-keys.mjs"; import { FRAME_KEYS_FILE, SPARSE_FILE } from "./chunked-encode.mjs"; import { poolFor, poolFrame, poolFrameEvents, poolPutFrames } from "./render-pool.mjs"; import { regionCaching, regionModule } from "./modules/index.mjs"; +import { stackedDeckWanted, verticalRender } from "./vertical.mjs"; const run = promisify(execFile); @@ -869,12 +870,17 @@ export async function composeChrome({ schedule = null, preview = false, doRender = false, fps = null, workers = null, quality = "high", format = "png-sequence", still = null, png = null, from = 0, duration = null, window = null, segment = null, transition = null, - lease = null, want = null, + lease = null, want = null, render: renderOverride = null, }) { // The variant's view, and its own out directory. Handed the whole manifest // the band would draw claims this cut never makes, and the deck would name // clips it does not play. const manifest = selectVariant(JSON.parse(await readFile(manifestPath, "utf8")), variant); + // THE STACKED VERTICAL DECK (vertical-deck.mjs): a 9:16 cut that keeps its deck is composed at the render the + // build makes it with (vertical.mjs verticalRender) -- the build passes its own (`render`: a `--vertical` + // build of a landscape manifest, its knobs); Play the cut and the previews read the manifest's. + if (renderOverride) manifest.render = renderOverride; + else if (stackedDeckWanted(manifest.render)) manifest.render = verticalRender(manifest.render); // Absolute: the still is a file:// URL, and a relative one is no page at all. const base = path.resolve(outDir ?? path.join(path.dirname(path.resolve(manifestPath)), "out", variant)); // The project's out/ through ensureOutDir before anything lands under it: a diff --git a/umtool/report-to-video/deck.mjs b/umtool/report-to-video/deck.mjs @@ -22,7 +22,7 @@ import { measureOn, measureSlice } from "./measure-slice.mjs"; import { COMPOSITION_PARAMS } from "yt-dlp-transcript-common/lib/report/fxParams.mjs"; import { INTRO_SECONDS } from "yt-dlp-transcript-common/lib/report/intro.mjs"; -import { attributionParts, deckSubtitle, deckSubtitleLines, deckSubtitleLinesParts, deckSubtitleParts, formatDeckDate } from "./attribution.mjs"; +import { attributionParts, deckSubtitle, deckSubtitleLines, deckSubtitleLinesParts, deckSubtitleParts, formatDeckDate, hms } from "./attribution.mjs"; import { panelEntry, postDeckText, postItemSeconds, postLayout } from "./post-item.mjs"; import { videoDip, videoEnter, videoHidesChrome, videoSeconds } from "./video-entry.mjs"; import { @@ -33,6 +33,9 @@ import { INSTRUMENT_COLUMN, instrumentsOn, instrumentsPlacement, instrumentsWant import { TRAILER_HIT_TIERS, TRAILER_SWELL } from "./trailer-hits.mjs"; import { DECK_PAD_X, counterCell } from "./modules/design.mjs"; import { parseShelfNote, resolveShelf, SHELF_MIN } from "./modules/shelf-settings.mjs"; +// THE STACKED VERTICAL DECK (vertical-deck.mjs, a leaf): a 9:16 render that keeps its deck answers every +// geometry below with the stacked deck's boxes. A landscape render never is one: everything below is as it was. +import { STACKED_PICTURE_K, clipTwoCrop, panelCells, stackedGeometry, stackedOn } from "./vertical-deck.mjs"; // An entry's note on the shelf, as written (`umtool set <p> <entry> shelfNote=…`; manifest.mjs checks it here). export { parseShelfNote }; @@ -124,6 +127,18 @@ export function resolveDeck(render) { // The instruments' column (instruments.mjs) takes the frame's right side: // the posts stay in the footage box, and nothing moves them over it. if (instrumentsOn(render)) merged.posts = { ...merged.posts, shift: false }; + // The stacked deck (vertical-deck.mjs): the posts' popups have no vertical form -- not drawn, so no clip holds + // for them (a frozen frame with nothing over it) and nothing moves the picture; there is no feed's column. + if (stackedOn(render)) merged.posts = { ...merged.posts, show: false, shift: false, layout: "popup" }; + // A frame of another height than 1080 (a 720p render): the band's sizes scaled with it -- its height, the + // title, the QR, the pips -- so the footage fits above it as at 1080 (deckScale). 1080 is untouched. + const k = deckScale(render); + if (k !== 1) { + merged.height = Math.round(merged.height * k); + merged.title = { ...merged.title, size: Math.max(12, Math.round(merged.title.size * k)) }; + merged.qr = { ...merged.qr, size: Math.round(merged.qr.size * k) }; + merged.pip = { ...merged.pip, size: Math.max(2, Math.round(merged.pip.size * k)), activeSize: Math.max(4, Math.round(merged.pip.activeSize * k)) }; + } return merged; } @@ -197,8 +212,9 @@ export function validateChrome(chrome, render = {}) { } // The footage has to fit above the deck. Clamping the scale instead would - // make the setting lie about what was drawn. - if (!errors.length) { + // make the setting lie about what was drawn. (The stacked vertical deck lays + // its own frame -- vertical-deck.mjs: nothing of the landscape fit applies.) + if (!errors.length && !stackedOn(render)) { const g = deckGeometry({ ...render, chrome }); // Only a deck that sets `posts` and draws them is held to the column's fit // here; one with posts on the defaults is checked by validatePosts, which @@ -467,9 +483,23 @@ export const even = (v) => Math.round(v / 2) * 2; export function deckGeometry(render) { const W = render?.width ?? 1920; const H = render?.height ?? 1080; + // THE STACKED VERTICAL DECK (vertical-deck.mjs): the picture at the frame's full width under the rail, and the + // deck's one page over the whole frame -- the rail, the source block, the wordmark are all in it. + if (stackedOn(render)) { + const g = stackedGeometry(render); + return { + W, H, + footage: { ...g.picture }, + deck: { x: 0, y: 0, width: W, height: H }, + ...(resolveShelf(render) ? { shelf: { ...g.shelf } } : {}), + stacked: true, + }; + } const deck = resolveDeck(render); // A two-line subtitle grows the band by its head line (subtitleBoxes): - // the footage box stands on the band's top edge wherever that is. + // the footage box stands on the band's top edge wherever that is. (A frame + // of another height than 1080 -- a 720p render -- has its band scaled with + // it: resolveDeck, deckScale.) const dh = deck.height + subtitleBoxes(deck).extra; // The instruments' column (instruments.mjs) takes the right: the footage // gives it room and stands at the left edge, `railGap` in. @@ -504,6 +534,20 @@ export function deckGeometry(render) { }; } +/** The smallest the deck band is scaled to: a 720p frame's (a smaller one is refused as it always was). */ +export const DECK_SCALE_MIN = 2 / 3; + +/** + * The deck band's scale against its 1080 design size: a frame SHORTER than + * 1080 takes its height over 1080 -- a 720p render's band two thirds as tall -- + * down to DECK_SCALE_MIN; 1080 and taller are 1, the deck as it always was. The + * stacked vertical deck lays its own frame and is not scaled. + */ +export const deckScale = (render) => { + const H = render?.height ?? 1080; + return stackedOn(render) || !(H > 0) || H >= 1080 ? 1 : Math.max(DECK_SCALE_MIN, H / 1080); +}; + /** The air between the frame's edges, the thread rail and the footage. */ export const railGap = (render) => Math.round(24 * ((render?.width ?? 1920) / 1920)); @@ -540,6 +584,7 @@ export function threadsGeometry(render) { * trail: {x:number,y:number,width:number,height:number}|null }} */ export function instrumentsGeometry(render) { + if (stackedOn(render)) return stackedInstruments(render); const { W, deck, footage } = deckGeometry(render); const k = W / 1920; const gap = railGap(render); @@ -560,6 +605,36 @@ export function instrumentsGeometry(render) { return out; } +/** The instruments' design boxes (w / h): what each cell of the stacked deck's panel is cut to. */ +export const INSTRUMENT_ASPECTS = Object.freeze({ odometer: 600 / 140, trail: 600 / 138 }); + +/** + * The instruments in the STACKED vertical deck's panel (vertical-deck.mjs + * panelCells): the dial the left column's whole height, the odometer and the + * trail down the right -- each its column's width and its design box's + * aspect; one that does not fit is left out (null, its name in `out`), never + * squashed. `column` is the panel. Wherever the dial is placed in landscape, + * the stacked deck stands it in its panel. + */ +export function stackedInstruments(render) { + const g = stackedGeometry(render, { counter: stackedCounterOn(render) }); + const on = instrumentsWanted(render); + const items = on.map((n) => (n === "dial" ? { id: n, tall: true, aspect: 1 } : { id: n, aspect: INSTRUMENT_ASPECTS[n] })); + const { cells, out } = panelCells(g.panel, items, g.gap); + return { + column: { ...g.panel }, + dial: cells.dial ?? null, odometer: cells.odometer ?? null, trail: cells.trail ?? null, + stacked: true, out, + }; +} + +/** Does the stacked deck keep a row for the tally (the fact-check counter, when the cut counts its claims)? */ +export function stackedCounterOn(render) { + const fc = render?.chrome?.factcheck; + const asked = (!!fc && typeof fc === "object") || isObj(render?.chrome?.deck?.counter); + return asked && resolveFactcheck(render).tally?.show !== false && resolveCounter(render).show !== false; +} + /** * The instruments in the CORNER (`deck.dial.placement: "corner"`): over the * footage box where the deck puts it, `inset` in from its edges -- the dial a @@ -1369,7 +1444,9 @@ export function deckSchedule({ // window is an output the counter reads (`finale.window`), and the finale // reads the counter's totals -- neither writes the other's slice. const stamps = stampsWithFinale(stamped, finale ? { start: finale.start, segments: finIds } : null); - const allMoves = finale ? [...moves, ...finale.moves] : moves; + // The stacked vertical deck never moves its picture: the finale's column stands over it (vertical-deck.mjs). + const stacked = stackedOn(render); + const allMoves = stacked ? [] : finale ? [...moves, ...finale.moves] : moves; const threads = threadsOn(render) ? threadSchedule({ segments: segs.map((s, i) => ({ ...s, thread: threadOf(entries[i]) })), D, total, render, moves }) : null; @@ -1464,6 +1541,9 @@ export function deckSchedule({ ...(finIds.has(e.id) ? { finale: true } : {}), // And off the rail, when the finale says so (finale.pips: false). ...(finIds.has(e.id) && resolveFinale(render).pips === false ? { noPip: true } : {}), + // Only in the stacked vertical deck (vertical-deck.mjs): a clip's source line in its parts (channel, + // title, date, the clock at its start), and a twocrop clip's layout -- its strip and its small QR. + ...(stacked ? stackedSegmentFields(e, metas[i] ?? null, provenance, deck) : {}), }; }), // The finale: present only when the cut has one. @@ -1531,6 +1611,27 @@ export function deckSchedule({ } /** + * A segment's fields only the stacked vertical deck's page reads: a clip's + * source line in its four parts (`vsource`: channel, title -- the deck's own + * title when the entry sets one --, date, the clock at its start) and a + * twocrop clip's layout (`vlayout`). + */ +export function stackedSegmentFields(entry, meta, provenance, deck) { + if (entry?.type !== "clip") return {}; + const p = attributionParts(entry, meta ?? {}, provenance); + const title = String(entry.onscreen?.title ?? "").trim() || String(p.title ?? "").trim(); + return { + vsource: { + channel: String(p.channel ?? "").trim(), + title, + date: formatDeckDate(p.date ?? "", deck.subtitle?.dateFormat ?? "long"), + clock: p.at === null || p.at === undefined ? "" : hms(p.at), + }, + ...(clipTwoCrop(entry) ? { vlayout: "twocrop" } : {}), + }; +} + +/** * The notes an entry puts on the shelf (`entry.shelfNote`, one line): `[{ segment, * from, to, text }]` -- `from`/`to` its segment's span in the cut. The shelf * module (modules/shelf.mjs) shows each over its span, fading with the entry. @@ -2774,7 +2875,7 @@ export function feedGeometry(render) { export function stampGeometry(render, { feed = false } = {}) { const { W } = deckGeometry(render); const f = feed ? feedGeometry(render).footage : deckGeometry(render).footage; - const k = W / 1920; + const k = pictureK(render, W); // `stamp.scale` sizes the region (the stamp is drawn to it), still inside the footage. const { position: pos, scale = 1 } = resolveFactcheck(render).stamp; const width = Math.min(even(560 * k * scale), even(f.width)); @@ -2787,6 +2888,14 @@ export function stampGeometry(render, { feed = false } = {}) { } /** + * The scale of what stands over the footage (the stamps, the stats, the + * measure extras) against its 1920-wide design: the frame's width over 1920 -- + * or, in the stacked vertical deck, STACKED_PICTURE_K (its picture is the + * frame's whole width, so the landscape share would draw them a size small). + */ +export const pictureK = (render, W = render?.width ?? 1920) => (stackedOn(render) ? STACKED_PICTURE_K : W / 1920); + +/** * Where the stats region sits in the frame (chrome-stats.mjs, stats.mjs): a * panel in the footage box -- the feed's when `feed`, else the deck's -- at * `stats.position`, `inset` clear of its edges: 48 px plus 150 a field wide @@ -2800,7 +2909,7 @@ export function stampGeometry(render, { feed = false } = {}) { export function statsGeometry(render, { feed = false } = {}) { const { W } = deckGeometry(render); const f = feed ? feedGeometry(render).footage : deckGeometry(render).footage; - const k = W / 1920; + const k = pictureK(render, W); const cfg = resolveStats(render); const width = Math.min(even((48 + 150 * cfg.fields.length) * k), even(f.width)); const height = Math.min(even((cfg.name ? 150 : 112) * k), even(f.height)); @@ -2834,6 +2943,8 @@ export function fxGeometry(render, { feed = false } = {}) { * `layout: "feed"` exactly then -- a feed with nothing to draw is the deck alone. */ export function feedOn({ render, posts = [], entries = [] }) { + // The stacked vertical deck has no column for a feed: its posts stay popups (resolveDeck). + if (stackedOn(render)) return false; if (!deckOn(render)) return false; const p = resolveDeck(render).posts; return p.show && p.layout === "feed" && attachPosts({ posts: posts ?? [], entries }).length > 0; diff --git a/umtool/report-to-video/instruments.mjs b/umtool/report-to-video/instruments.mjs @@ -24,7 +24,8 @@ // in the finale's lower column (module `dial-finale`). // // A LEAF, like modules/settings.mjs: deck.mjs and settings.mjs import it, so it -// imports neither. +// imports neither (vertical-deck.mjs, the stacked deck's geometry, is a leaf too). +import { stackedOn } from "./vertical-deck.mjs"; /** The column's width at 1920 wide (scaled with the frame): what the footage gives up. */ export const INSTRUMENT_COLUMN = 600; @@ -126,8 +127,8 @@ export function instrumentsWanted(render) { return out; } -/** Where the instruments stand: the dial's `placement` ("column" without a dial). */ -export const instrumentsPlacement = (render) => resolveDial(render)?.placement ?? "column"; +/** Where the instruments stand: the dial's `placement` ("column" without a dial) -- always the panel's column in the stacked vertical deck. */ +export const instrumentsPlacement = (render) => (stackedOn(render) ? "column" : resolveDial(render)?.placement ?? "column"); /** * Is the instrument COLUMN on: any of the three asked for, placed in the column. diff --git a/umtool/report-to-video/lint.mjs b/umtool/report-to-video/lint.mjs @@ -101,6 +101,10 @@ import { validateAssist } from "yt-dlp-transcript-common/lib/clips/assist.mjs"; import { validateFxEntries } from "./fx.mjs"; import { validateTransitionStyle } from "./transition.mjs"; import { validateLook } from "./look.mjs"; +// The stacked vertical deck (vertical-deck.mjs): what it leaves out, and a twocrop band drawn past its source's pixels. +import { stackedLeftOut } from "./modules/index.mjs"; +import { verticalOn, verticalRender } from "./vertical.mjs"; +import { ENLARGE_WARN, clipTwoCrop, stackedOn, twoCropEnlargement } from "./vertical-deck.mjs"; import { roomWindowWarnings } from "./room.mjs"; import { qrUrlFor } from "./render-cards.mjs"; import { archiveMomentUrl } from "./site-links.mjs"; @@ -396,6 +400,28 @@ export function narrationLengthErrors(manifest, secondsById, { only = null } = { * `draftsUnreviewed` / `narrationUnreviewed` let the unapproved through. * @returns {{ errors: string[], warnings: string[] }} */ +/** A twocrop clip's warnings: past ENLARGE_WARN on a 16:9 source, or in a cut that does not play the stacked deck. */ +export function stackedLintWarnings(manifest, { only = null } = {}) { + const out = []; + const render = manifest?.render ?? {}; + const vr = verticalOn(render) ? verticalRender(render) : null; + const sh = Number(render.maxHeightSource) || 1080; + const sw = Math.round((sh * 16) / 9); + for (const e of manifest?.timeline ?? []) { + if (e?.type !== "clip" || (only && e.id !== only)) continue; + const crops = clipTwoCrop(e); + if (!crops) continue; + if (!vr || !stackedOn(vr)) { + if (vr) out.push(`timeline ${e.id}.vertical.layout "twocrop" is the stacked deck's: this vertical cut has none (render.vertical.deck "bare", or no deck), so it plays in the cut's clip layout`); + continue; + } + twoCropEnlargement(crops, sw, sh, vr).forEach((x, i) => { + if (x > ENLARGE_WARN) out.push(`timeline ${e.id}.vertical.crops[${i}] is drawn ${x}× its source's pixels at ${sw}x${sh} (past ${ENLARGE_WARN}×: it will look soft) -- a wider crop`); + }); + } + return out; +} + export function lintManifest(manifest, { manifestDir, whole = manifest, exists = existsSync, only = null, validators = true, narrationSeconds = null, narrationReview = null, narrationUnreviewed = false, draftsReview = null, final = false, draftsUnreviewed = false, @@ -413,6 +439,11 @@ export function lintManifest(manifest, { warnings.push(...roomWindowWarnings(only ? { ...manifest, timeline: (manifest.timeline ?? []).filter((e) => e?.id === only) } : manifest)); // A narrated post's read that says a link aloud (post-thread.mjs threadReadWarnings), with its fix. warnings.push(...validateThreadReadWarnings(only ? { ...manifest, timeline: (manifest.timeline ?? []).filter((e) => e?.id === only) } : manifest)); + // THE STACKED VERTICAL DECK: each module the cut sets up that has no vertical form, left out (a note, never a + // refusal); a twocrop clip's band drawn past ENLARGE_WARN times its source's pixels (a 16:9 source of the cut's + // `maxHeightSource`, 1080 by default: the build says it again from the real one); a twocrop where no stacked deck plays it. + if (!only) warnings.push(...stackedLeftOut(manifest)); + warnings.push(...stackedLintWarnings(manifest, { only })); for (const { where, src } of imageSrcsOf(manifest, { only })) { if (path.isAbsolute(src) || src.startsWith("~")) { diff --git a/umtool/report-to-video/measure-extras.mjs b/umtool/report-to-video/measure-extras.mjs @@ -25,10 +25,11 @@ // - DIET: the state's diet, re-stamped at each change of regime or diet // number; a null diet after one is "NO DIET" (the producer has applied the // off-scope rule: this only draws state.diet). -import { deckGeometry, feedGeometry, instrumentsGeometry } from "./deck.mjs"; +import { deckGeometry, feedGeometry, instrumentsGeometry, pictureK } from "./deck.mjs"; import { chapterCover, chapterWindows } from "./chrome-story.mjs"; import { dietTagWidth, MEASURE_EXTRAS, MEASURE_POSITIONS, resolveMeasureExtra, SHELF_POSITION } from "./modules/measure-extras-settings.mjs"; import { resolveShelf } from "./modules/shelf-settings.mjs"; +import { stackedOn, stackedStandDowns } from "./vertical-deck.mjs"; const r4 = (v) => Math.round(v * 10000) / 10000; const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v); @@ -883,7 +884,9 @@ export function measureExtraGeometry(id, render, { feed = false } = {}) { } const g = deckGeometry(render); const f = feed ? feedGeometry(render).footage : g.footage; - const k = (g.W / 1920) * (cfg.scale ?? 1); + // Over the footage at its design size scaled with the frame (pictureK: the stacked vertical deck's own). + const pk = pictureK(render, g.W); + const k = pk * (cfg.scale ?? 1); const box = measureBox(id, render); const width = Math.min(even(box.width * k), even(g.W)); const height = Math.min(even(box.height * k), even(g.H)); @@ -893,7 +896,7 @@ export function measureExtraGeometry(id, render, { feed = false } = {}) { x = cfg.x * (g.W / 1920); y = cfg.y * (g.W / 1920); } else { - const inset = Math.round(24 * (g.W / 1920)); + const inset = Math.round(24 * pk); const [v, h] = cfg.position.split("-"); x = h === "left" ? f.x + inset : h === "right" ? f.x + f.width - inset - width : f.x + (f.width - width) / 2; y = v === "top" ? f.y + inset : f.y + f.height - inset - height; @@ -935,11 +938,12 @@ export function anchorRect(id, render, anchor, size = 1, { feed = false } = {}) const cfg = resolveMeasureExtra(id, render) ?? resolveMeasureExtra(id, { chrome: { deck: {} } }); const g = deckGeometry(render); const f = feed ? feedGeometry(render).footage : g.footage; - const k = (g.W / 1920) * (cfg.scale ?? 1) * size; + const pk = pictureK(render, g.W); + const k = pk * (cfg.scale ?? 1) * size; const box = measureBox(id, render); const width = Math.min(even(box.width * k), even(f.width)); const height = Math.min(even(box.height * k), even(f.height)); - const inset = Math.round(24 * (g.W / 1920)); + const inset = Math.round(24 * pk); const [v, h] = anchor.split("-"); const x = h === "left" ? f.x + inset : h === "right" ? f.x + f.width - inset - width : f.x + (f.width - width) / 2; const y = v === "top" ? f.y + inset : f.y + f.height - inset - height; @@ -1099,6 +1103,18 @@ export function measurePlacements(schedule, render, { finaleSlot = null } = {}) out.promise.moves.push({ from: finaleSlot.at, to: Number(schedule.total) || fin.to, rect: finaleSlot.rect, size: finaleSlot.size }); } else if (inColumn) out.promise.moves.push({ from: fin.from, to: Number(schedule.total) || fin.to, rect: null, size: 1 }); } + // THE STACKED VERTICAL DECK (vertical-deck.mjs): over a post item (its card takes the picture's room) and a + // twocrop clip (its strip carries the numbers) every extra stands down, as an entry's hideModules hides it. + if (stackedOn(render)) { + for (const sd of stackedStandDowns(schedule)) { + for (const id of MEASURE_EXTRAS) { + if (!resolveMeasureExtra(id, render)) continue; + out[id].moves = carveSpans(out[id].moves, sd.from, sd.to); + out[id].moves.push({ from: sd.from, to: sd.to, rect: null, size: 1 }); + if (id === "promise") out.promise.strips = carveSpans(out.promise.strips, sd.from, sd.to); + } + } + } // An entry that hides modules over its span (`hideModules`, deck.mjs entryHides -- text in the footage no // dodge can know of, rev 9: the refund email in v02): each named module hidden there with its own fade, whatever // it would otherwise have done in that span. diff --git a/umtool/report-to-video/modules/blur.mjs b/umtool/report-to-video/modules/blur.mjs @@ -13,6 +13,8 @@ export default defineModule({ z: 2, kind: "input", slot: "footage", + // Its form in the stacked vertical deck (vertical-deck.mjs). + vertical: { slot: "input" }, title: "Blur", summary: "A clip's picture blurred at its encode, a caption on it, the sound as recorded.", configKey: "render.blur", diff --git a/umtool/report-to-video/modules/chapter.mjs b/umtool/report-to-video/modules/chapter.mjs @@ -17,6 +17,8 @@ export default defineModule({ z: 85, kind: "overlay-window", slot: "footage", + // Its form in the stacked vertical deck (vertical-deck.mjs). + vertical: { slot: "picture" }, title: "Chapters", summary: "A section bumper over the first seconds of the clip it opens: title, subtitle, date.", configKey: "render.chrome.chapter", diff --git a/umtool/report-to-video/modules/contract.mjs b/umtool/report-to-video/modules/contract.mjs @@ -63,6 +63,15 @@ export const MODULE_SLOTS = Object.freeze(["footer", "column", "popup", "stamp", */ export const PLAY_CLOCKS = Object.freeze(["cut"]); +/** + * Where a module stands in the STACKED vertical deck (vertical-deck.mjs): the + * whole frame (the shell's page), a cell of the instruments' panel, over the + * picture (as it stands over the footage box), on the picture's lower-left + * shelf, the finale's instrument column, inside its host's page (a part), a + * segment of the cut (its own frame), or a filter on the footage itself. + */ +export const VERTICAL_SLOTS = Object.freeze(["frame", "panel", "picture", "shelf", "finale", "inline", "segment", "input"]); + /** How a region is laid over the cut: a whole-cut sequence from frame 1, or a window at its own second. */ export const REGION_PLACEMENTS = Object.freeze(["whole", "window"]); @@ -100,6 +109,7 @@ const SPEC = Object.freeze({ play: "its live-preview contract: { clock: \"cut\", ready: \"<region>:ready\" } -- its page seeked in an iframe by Play the cut and the live preview", docs: "its knobs.md section: { heading, intro?, rows: [[knob, range, terminal]], after? }", workers: "\"wide\" or \"narrow\": how many renderer workers its page takes", + vertical: "its form in the stacked vertical deck (vertical-deck.mjs): { slot: one of VERTICAL_SLOTS }; absent, it has none and is left out of one", noun: "how a message names its sequence (\"the stamps'\")", cached: "false for a page the render cache does not key (the legacy chart band)", check: "a function (schedule, render) => the sentence why this schedule cannot draw it, or null", @@ -173,6 +183,7 @@ export function defineModule(def) { } } if (def.docs !== undefined && !(isObj(def.docs) && typeof def.docs.heading === "string")) throw new Error(`${where}: docs must be ${SPEC.docs}`); + if (def.vertical !== undefined && !(isObj(def.vertical) && VERTICAL_SLOTS.includes(def.vertical.slot))) throw new Error(`${where}: vertical must be ${SPEC.vertical}`); if (def.workers !== undefined && !["wide", "narrow"].includes(def.workers)) throw new Error(`${where}: workers must be ${SPEC.workers}`); return Object.freeze({ ...def }); } diff --git a/umtool/report-to-video/modules/counter.mjs b/umtool/report-to-video/modules/counter.mjs @@ -14,6 +14,8 @@ export default defineModule({ kind: "part", host: "shell", slot: "inline", + // Its form in the stacked vertical deck (vertical-deck.mjs). + vertical: { slot: "inline" }, title: "Counter", summary: "A running tally of named series in the deck, each cell stepping as a mark's stamp lands.", configKey: "render.chrome.deck.counter", diff --git a/umtool/report-to-video/modules/dial-finale.mjs b/umtool/report-to-video/modules/dial-finale.mjs @@ -23,6 +23,8 @@ export default defineModule({ z: 95, kind: "overlay-window", slot: "full", + // Its form in the stacked vertical deck (vertical-deck.mjs). + vertical: { slot: "finale" }, title: "Dial finale", summary: "The finale with the dial and the odometer large: the needle drops to his last stated weight, the wheels roll to the total, NET holds.", docs: { diff --git a/umtool/report-to-video/modules/dial.mjs b/umtool/report-to-video/modules/dial.mjs @@ -24,6 +24,8 @@ export default defineModule({ z: 74, kind: "overlay-whole", slot: "instruments", + // Its form in the stacked vertical deck (vertical-deck.mjs). + vertical: { slot: "panel" }, title: "Scale dial", summary: "A bathroom-scale face: the needle swings to each weight he states, his remembered weights as ghosts, every goal in force on the bezel (the closest headlined), and -- with deck.measure.ghosts -- a faint tick for every weight he has claimed.", configKey: "render.chrome.deck.dial", diff --git a/umtool/report-to-video/modules/fx.mjs b/umtool/report-to-video/modules/fx.mjs @@ -13,6 +13,8 @@ export default defineModule({ z: 60, kind: "overlay-whole", slot: "footage", + // Its form in the stacked vertical deck (vertical-deck.mjs). + vertical: { slot: "picture" }, title: "Effects", summary: "Overlays on the picture: receipts, a zoom, a scrubber, captions.", validate: settingsOf("fx").validate, diff --git a/umtool/report-to-video/modules/index.mjs b/umtool/report-to-video/modules/index.mjs @@ -7,6 +7,10 @@ // Pure: the module files are, and so is this. import { assertRegion, defineModule, MODULE_KINDS, MODULE_SLOTS, PLAY_CLOCKS, REGION_PLACEMENTS } from "./contract.mjs"; import { settingsOf, settingValue } from "./settings.mjs"; +// The stacked vertical deck's rules (vertical-deck.mjs) and the render a vertical cut is built with (vertical.mjs). +import { instrumentsGeometry } from "../deck.mjs"; +import { verticalOn, verticalRender } from "../vertical.mjs"; +import { leftOutWords, stackedOn } from "../vertical-deck.mjs"; import chart from "./chart.mjs"; import shell from "./shell.mjs"; @@ -174,3 +178,51 @@ export function moduleProblems(manifest) { } return out; } + +// --------------------------------------------------------------------------- +// THE STACKED VERTICAL DECK (vertical-deck.mjs): a module stands in it by its +// `vertical` form (contract.mjs VERTICAL_SLOTS); one with none is left out -- +// said so in the lint and the build's notes, never squashed into the frame. +// --------------------------------------------------------------------------- + +/** A module's form in the stacked vertical deck (`{ slot }`), or null: it has none. */ +export const verticalFormOf = (m) => (m && m.vertical) || null; + +/** Is this module's setting written on the render (its configKey, or its SETTINGS entry) and not `false`? */ +function configured(m, render) { + const chrome = render?.chrome ?? {}; + const entry = settingsOf(m.id); + const value = entry + ? settingValue(chrome, entry) + : m.configKey + ? m.configKey.split(".").slice(1).reduce((o, k) => (o && typeof o === "object" ? o[k] : undefined), render) + : undefined; + if (value === undefined || value === null || value === false) return false; + if (value && typeof value === "object" && value.show === false) return false; + return true; +} + +/** + * What the stacked vertical deck leaves out of a manifest, as sentences: each + * module the cut sets up that has no vertical form (the posts popups and + * feed, the side panel, the finale's landscape page …), and an instrument + * the panel has no room for. Empty for any other cut. `manifest.render` is the + * cut's as written (the vertical one is derived here, as the build derives it). + */ +export function stackedLeftOut(manifest) { + const render = verticalRender(manifest?.render ?? {}); + if (!verticalOn(manifest?.render) || !stackedOn(render)) return []; + const out = []; + const tl = Array.isArray(manifest?.timeline) ? manifest.timeline : []; + for (const m of MODULES) { + // A legacy page the deck never draws (the chart band) is not the deck's to leave out. + if (verticalFormOf(m) || m.cached === false) continue; + let on = configured(m, render); + if (m.id === "popup-posts") on = Array.isArray(manifest?.posts) && manifest.posts.length > 0 && render?.chrome?.deck?.posts?.show !== false; + if (m.id === "finale") on = tl.some((e) => e?.layout === "finale"); + if (m.id === "feed") on = render?.chrome?.deck?.posts?.layout === "feed"; + if (on) out.push(leftOutWords(m.id)); + } + for (const id of instrumentsGeometry(render).out ?? []) out.push(leftOutWords(id, "no room left in the instruments' panel")); + return out; +} diff --git a/umtool/report-to-video/modules/intro.mjs b/umtool/report-to-video/modules/intro.mjs @@ -32,6 +32,8 @@ export default defineModule({ z: 1, kind: "segment", slot: "full", + // Its form in the stacked vertical deck (vertical-deck.mjs). + vertical: { slot: "segment" }, title: "Intro", summary: "The brand sting the cut opens with, a site's name swapped in on the chime.", configKey: "render.intro", diff --git a/umtool/report-to-video/modules/measure-extras-module.mjs b/umtool/report-to-video/modules/measure-extras-module.mjs @@ -46,6 +46,8 @@ export function measureExtraModule(spec) { z: spec.z, kind: "overlay-whole", slot: "footage", + // Its form in the stacked vertical deck (vertical-deck.mjs): over the picture, at its anchor there. + vertical: { slot: "picture" }, title: spec.title, summary: spec.summary, configKey: `render.chrome.deck.${id}`, diff --git a/umtool/report-to-video/modules/odometer.mjs b/umtool/report-to-video/modules/odometer.mjs @@ -19,6 +19,8 @@ export default defineModule({ z: 75, kind: "overlay-whole", slot: "instruments", + // Its form in the stacked vertical deck (vertical-deck.mjs). + vertical: { slot: "panel" }, title: "Lost odometer", summary: "Rolling digits of the pounds he says he has lost (only ever up), NET beside them.", configKey: "render.chrome.deck.odometer", diff --git a/umtool/report-to-video/modules/pair.mjs b/umtool/report-to-video/modules/pair.mjs @@ -16,6 +16,8 @@ export default defineModule({ z: 52, kind: "overlay-whole", slot: "footage", + // Its form in the stacked vertical deck (vertical-deck.mjs). + vertical: { slot: "picture" }, title: "Then and now", summary: "Two clips on one subject, each with its date: a then | now strip (or a then→now card) with the pair's caption.", configKey: "render.chrome.pair", diff --git a/umtool/report-to-video/modules/qr.mjs b/umtool/report-to-video/modules/qr.mjs @@ -12,6 +12,8 @@ export default defineModule({ kind: "part", host: "shell", slot: "inline", + // Its form in the stacked vertical deck (vertical-deck.mjs). + vertical: { slot: "inline" }, title: "QR", summary: "Each clip's code in the deck, to the archive at the clip or to the record itself.", configKey: "render.chrome.deck.qr", diff --git a/umtool/report-to-video/modules/rail.mjs b/umtool/report-to-video/modules/rail.mjs @@ -32,6 +32,8 @@ export default defineModule({ kind: "part", host: "shell", slot: "inline", + // Its form in the stacked vertical deck (vertical-deck.mjs). + vertical: { slot: "inline" }, title: "Rail", summary: "The deck's pip track: a pip per clip, the marker, the fuse, and the markers' flags.", configKey: "render.chrome.deck.pip", diff --git a/umtool/report-to-video/modules/section-title.mjs b/umtool/report-to-video/modules/section-title.mjs @@ -26,6 +26,8 @@ export default defineModule({ kind: "part", host: "shell", slot: "inline", + // Its form in the stacked vertical deck (vertical-deck.mjs). + vertical: { slot: "inline" }, title: "Section title", summary: "The current section's name (the marker that opened it) on one quiet line under the rail.", configKey: "render.chrome.deck.sectionTitle", diff --git a/umtool/report-to-video/modules/shelf.mjs b/umtool/report-to-video/modules/shelf.mjs @@ -20,6 +20,8 @@ export default defineModule({ z: 64, kind: "overlay-whole", slot: "shelf", + // Its form in the stacked vertical deck (vertical-deck.mjs). + vertical: { slot: "shelf" }, title: "Shelf", summary: "A strip cleared under (or over) the footage for the diet's dated tags, the streak chain, a goal stack or an entry's note -- nothing on it stands on the picture.", configKey: "render.chrome.deck.shelf", diff --git a/umtool/report-to-video/modules/shell.mjs b/umtool/report-to-video/modules/shell.mjs @@ -8,6 +8,9 @@ import path from "node:path"; import { deckGeometry, deckLayout } from "../deck.mjs"; import { deckHtml } from "../chrome-deck.mjs"; +import { stackedDeckHtml, wordmarkOf } from "../chrome-vdeck.mjs"; +import { STACKED_QR_SHARE, stackedOn } from "../vertical-deck.mjs"; +import { instrumentFonts } from "./instruments-shared.mjs"; import { assertRegion, defineModule } from "./contract.mjs"; import { DECK_DEFAULTS, settingsOf } from "./settings.mjs"; @@ -17,6 +20,8 @@ export default defineModule({ z: 10, kind: "overlay-whole", slot: "footer", + // Its form in the stacked vertical deck (vertical-deck.mjs). + vertical: { slot: "frame" }, title: "Deck", summary: "The panel at the foot of the frame: each clip's title, and the band the subtitle, QR, rail and counter draw in.", configKey: "render.chrome.deck", @@ -54,6 +59,15 @@ export default defineModule({ on: () => true, async page(ctx) { const { render, schedule } = ctx; + // THE STACKED VERTICAL DECK (vertical-deck.mjs): the same schedule, drawn over the 9:16 frame -- the rail, + // each segment's source block and its QR, the tally, the wordmark (chrome-vdeck.mjs). + if (stackedOn(render)) { + const fonts = await instrumentFonts(ctx); + const qrSrcs = {}; + const byUrl = await ctx.qrs(schedule.segments.map((s) => s.qrUrl), Math.round(render.width * STACKED_QR_SHARE)); + for (const s of schedule.segments) if (s.qrUrl) qrSrcs[s.id] = byUrl.get(s.qrUrl); + return stackedDeckHtml(schedule, render, { fonts, qrSrcs, from: ctx.from, duration: ctx.duration, site: wordmarkOf(ctx.manifest?.provenance) }); + } const fonts = await ctx.fonts({ regular: "DeckSans", bold: "DeckSansBold" }, { strict: true }); // With the schedule: a staggered marker band moves the QR down and may shrink it. const lay = deckLayout(render, { schedule }); diff --git a/umtool/report-to-video/modules/stamp.mjs b/umtool/report-to-video/modules/stamp.mjs @@ -16,6 +16,8 @@ export default defineModule({ z: 40, kind: "overlay-whole", slot: "stamp", + // Its form in the stacked vertical deck (vertical-deck.mjs). + vertical: { slot: "picture" }, title: "Stamps", summary: "Each counted mark's word, stamped over the footage as it lands.", configKey: "render.chrome.factcheck.stamp", diff --git a/umtool/report-to-video/modules/stats.mjs b/umtool/report-to-video/modules/stats.mjs @@ -14,6 +14,8 @@ export default defineModule({ z: 50, kind: "overlay-whole", slot: "panel", + // Its form in the stacked vertical deck (vertical-deck.mjs). + vertical: { slot: "picture" }, title: "Stats", summary: "A frame scan's running numbers over the clips that declare them.", validate: settingsOf("stats").validate, diff --git a/umtool/report-to-video/modules/status.mjs b/umtool/report-to-video/modules/status.mjs @@ -15,6 +15,8 @@ export default defineModule({ z: 55, kind: "overlay-whole", slot: "footage", + // Its form in the stacked vertical deck (vertical-deck.mjs). + vertical: { slot: "picture" }, title: "Status ledger", summary: "A row per item -- announced, then followed up or not -- filling a column as the cut plays.", configKey: "render.chrome.status", diff --git a/umtool/report-to-video/modules/subtitle.mjs b/umtool/report-to-video/modules/subtitle.mjs @@ -15,6 +15,8 @@ export default defineModule({ kind: "part", host: "shell", slot: "inline", + // Its form in the stacked vertical deck (vertical-deck.mjs). + vertical: { slot: "inline" }, title: "Subtitle", summary: "Each clip's source line under its title: the channel, the source's title, the date, the clock.", configKey: "render.chrome.deck.subtitle", diff --git a/umtool/report-to-video/modules/teaser.mjs b/umtool/report-to-video/modules/teaser.mjs @@ -12,6 +12,8 @@ export default defineModule({ z: 0, kind: "segment", slot: "full", + // Its form in the stacked vertical deck (vertical-deck.mjs). + vertical: { slot: "segment" }, title: "Teaser", summary: "A full-frame card of lines popping in on the beat, inserted as its own segment.", validate: (_value, { manifest }) => validateTeasers(manifest), diff --git a/umtool/report-to-video/modules/trail.mjs b/umtool/report-to-video/modules/trail.mjs @@ -18,6 +18,8 @@ export default defineModule({ z: 76, kind: "overlay-whole", slot: "instruments", + // Its form in the stacked vertical deck (vertical-deck.mjs). + vertical: { slot: "panel" }, title: "Weight trail", summary: "His stated weights by date, drawn up to the playhead, the 300 lb line and the times he says he is under it.", configKey: "render.chrome.deck.trail", diff --git a/umtool/report-to-video/package.json b/umtool/report-to-video/package.json @@ -25,6 +25,7 @@ "./build-video": "./build-video.mjs", "./basic": "./basic.mjs", "./vertical": "./vertical.mjs", + "./vertical-deck": "./vertical-deck.mjs", "./vertical-plan": "./vertical-plan.mjs", "./reframe": "./reframe.mjs", "./side-card": "./side-card.mjs", diff --git a/umtool/report-to-video/subtitle-lines.test.mjs b/umtool/report-to-video/subtitle-lines.test.mjs @@ -73,11 +73,14 @@ test("two lines at 1920×1080: the band grows by the head line and every slot mo assert.equal(reservedFooterHeight(renderOf({ overCards: "show" })), 190); }); -test("two lines at 1280×720: the same band, and the footage still above it", () => { +// Lane vertical-deck (9 Nov): a frame shorter than 1080 has its band scaled with its height (deck.mjs deckScale) -- +// at 720 two thirds of the 1080 band, its head line too (title 36: a 28 px head box) -- where it was the 1080 band +// unscaled (229 px), which refused the default footageScale. footageScale 0.6 fits either way. +test("two lines at 1280×720: the band scaled with the frame, and the footage still above it", () => { const render = renderOf({ ...TWO, footageScale: 0.6 }, { width: 1280, height: 720 }); assert.deepEqual(validateChrome(render.chrome, render), []); const g = deckGeometry(render); - assert.deepEqual(g.deck, { x: 0, y: 720 - 229, width: 1280, height: 229 }); + assert.deepEqual(g.deck, { x: 0, y: 720 - 155, width: 1280, height: 155 }); assert.ok(g.footage.y + g.footage.height <= g.deck.y); const lay = deckLayout(render); assert.ok(lay.text.subtitleY + lay.text.headBox + lay.text.subtitleBox <= lay.height - 8); diff --git a/umtool/report-to-video/vertical-deck.mjs b/umtool/report-to-video/vertical-deck.mjs @@ -0,0 +1,270 @@ +// THE VERTICAL DECK (lane vertical-deck, 9 Nov): a cut that has a deck keeps it +// in 9:16. The operator's pick from the layouts (out/vertical-design): the +// STACKED deck as the default (`render.vertical.deck: "stacked"`; "bare" is the +// vertical format as it first shipped, no deck), a clip's TWO-CROP reframe as +// its own option (`vertical.layout: "twocrop"`, `vertical.crops`), and a post +// item as the hero card with the deck kept round it. +// +// ONE composition, two geometries: the deck's schedule, its pages and its +// timing are the landscape cut's; only where things stand changes. This file +// says where, top to bottom, inside the platforms' safe area +// (render.vertical.safe: the top 8 %, the bottom 20 %, the right 12 %): +// +// rail the section's name and its progress segments, "2 / 5" under the top band +// picture the clip's 16:9 footage box at the frame's full width +// shelf over the picture's lower-left (the stamps, a shelf's notes) +// captions under the picture, at most two lines, each word lit +// panel the instruments in two columns (the dial tall at the left) +// counters the tally's cells, when the cut counts +// source channel · title · date · time, the QR beside it above the bottom band +// wordmark the site's name, dim, in the bottom band (decoration only) +// +// A post item: its card in the picture's and the captions' room, the counters +// under it, the big date line and the QR in the source block. A twocrop clip: +// the source line and the rail together on top, crop one, a one-row strip of +// the instruments, crop two with the captions over its foot, the QR small and +// low-left in the bottom band. The finale: the instrument column over the +// picture's room. +// +// A LEAF and PURE: no fs, no ffmpeg, and it imports nothing of the deck's -- +// deck.mjs, the pages and the build read it. + +import { VERTICAL_HEIGHT, VERTICAL_WIDTH, clipTwoCrop, stackedDeckWanted, verticalKnobs } from "yt-dlp-transcript-common/lib/report/vertical.mjs"; + +export { clipTwoCrop, stackedDeckWanted }; + +const even = (n) => 2 * Math.round(n / 2); +const evenDown = (n) => 2 * Math.floor(n / 2); + +/** + * Is this render the stacked deck: a 9:16 render (`format: "vertical"`, the + * build's 1080x1920) that keeps its deck. The geometry functions of deck.mjs + * (deckGeometry, instrumentsGeometry …) ask this and answer with the stacked + * deck's boxes; a landscape render is never one. + */ +export const stackedOn = (render) => stackedDeckWanted(render) && (render?.height ?? 0) > (render?.width ?? 0); + +/** How large the picture's own overlays (the stamps, the stats, the measure extras) are drawn, against the landscape deck's 1920 design px. */ +export const STACKED_PICTURE_K = 0.75; + +/** The caption face's size in the stacked deck, a share of the frame's width (under the picture: two lines fit their band). */ +export const STACKED_CAPTION_SHARE = 0.046; + +/** The QR's size (a share of the width) in the source block, and the twocrop's small one in the bottom band. */ +export const STACKED_QR_SHARE = 0.13; +export const STACKED_QR_SMALL_SHARE = 0.1; + +/** The panel's gap between its two columns and between its cells, a share of the width. */ +export const STACKED_GAP_SHARE = 0.02; + +/** + * The safe area in px: everything that must be read keeps inside x0..x1, + * y0..y1 (render.vertical.safe). The left margin is the stacked deck's own + * (the mockups' 14 of 405). + */ +export function stackedSafe(render, W = render?.width ?? VERTICAL_WIDTH, H = render?.height ?? VERTICAL_HEIGHT) { + const s = verticalKnobs(render).safe; + return { x0: Math.round(W * 0.035), x1: Math.round(W * (1 - s.right)), y0: Math.round(H * s.top), y1: Math.round(H * (1 - s.bottom)) }; +} + +/** + * Where everything of the stacked deck stands, frame px. `counter`: the cut + * draws the tally's cells (they take a row over the source block). + * + * @returns {{ W: number, H: number, safe: {x0:number,x1:number,y0:number,y1:number}, + * rail: Rect & { label: number, bar: number }, picture: Rect, shelf: Rect, captions: Rect & { size: number, lines: number }, + * panel: Rect, gap: number, counters: Rect | null, source: Rect & { qr: {x:number,y:number,size:number}, text: Rect }, + * wordmark: { x: number, y: number, size: number }, post: { card: Rect, counters: Rect }, + * twocrop: { top: Rect, crop1: Rect, strip: Rect, crop2: Rect, captions: { bottom: number }, qr: {x:number,y:number,size:number} }, + * finale: { title: Rect, column: Rect } }} + */ +export function stackedGeometry(render, { counter = false } = {}) { + const W = render?.width ?? VERTICAL_WIDTH; + const H = render?.height ?? VERTICAL_HEIGHT; + const a = stackedSafe(render, W, H); + const u = W / 1080; + const gap = Math.round(W * STACKED_GAP_SHARE); + const k = verticalKnobs(render); + // The rail: the section's name over its progress segments, just under the top band. + const label = Math.round(40 * u); + const bar = Math.max(4, Math.round(8 * u)); + const rail = { x: a.x0, y: a.y0 + Math.round(12 * u), width: a.x1 - a.x0, height: label + Math.round(17 * u) + bar, label, bar }; + // The picture: the frame's full width, 16:9, under the rail. + const ph = even((W * 9) / 16); + const picture = { x: 0, y: even(rail.y + rail.height + Math.round(31 * u)), width: W, height: ph }; + // The shelf: over the picture's lower-left. + const shelf = { x: a.x0 - Math.round(11 * u), y: picture.y + ph - Math.round(16 * u) - Math.round(110 * u), width: evenDown((a.x1 - a.x0) * 0.62), height: Math.round(110 * u) }; + // The captions: at most two lines under the picture. + const size = Math.round(W * STACKED_CAPTION_SHARE); + const lines = k.captions.lines; + const captions = { x: a.x0, y: picture.y + ph + Math.round(22 * u), width: a.x1 - a.x0, height: Math.round(size * 1.24 * 2), size, lines }; + // The source block, standing on the bottom band: its rule, the QR, the words. + const qrSize = even(W * STACKED_QR_SHARE); + const padTop = Math.round(22 * u); + const sourceH = padTop + qrSize; + const source = { x: a.x0, y: a.y1 - Math.round(12 * u) - sourceH, width: a.x1 - a.x0, height: sourceH }; + const sq = { x: a.x0, y: source.y + padTop, size: qrSize }; + const sourceBlock = { ...source, qr: sq, text: { x: sq.x + qrSize + Math.round(27 * u), y: sq.y, width: a.x1 - (sq.x + qrSize + Math.round(27 * u)), height: qrSize } }; + // The tally's row, over the source block. + const counters = counter ? { x: a.x0, y: source.y - gap - Math.round(80 * u), width: a.x1 - a.x0, height: Math.round(80 * u) } : null; + // The panel: what is left between the captions and the counters (or the source block). + const panelTop = captions.y + captions.height + Math.round(15 * u); + const panelBottom = (counters ? counters.y : source.y) - gap; + const panel = { x: a.x0, y: panelTop, width: a.x1 - a.x0, height: Math.max(0, panelBottom - panelTop) }; + // The wordmark: dim, low in the bottom band. + const wordmark = { x: a.x0, y: H - Math.round(38 * u) - Math.round(28 * u), size: Math.round(28 * u) }; + // A post item (layout 4): its card from under the rail to the panel's top, the counters under it. + const card = { x: a.x0, y: even(rail.y + rail.height + Math.round(76 * u)), width: evenDown(a.x1 - a.x0), height: 0 }; + card.height = evenDown(panelTop - card.y); + const postCounters = { x: a.x0, y: card.y + card.height + Math.round(26 * u), width: a.x1 - a.x0, height: Math.round(80 * u) }; + // Two crops (layout 3): the source line over the rail at the top, crop one, the strip, crop two to the bottom band. + const top = { x: a.x0, y: a.y0 + Math.round(6 * u), width: a.x1 - a.x0, height: picture.y - (a.y0 + Math.round(6 * u)) - Math.round(10 * u) }; + const crop1 = { x: 0, y: picture.y, width: W, height: even(H * 0.3275) }; + const strip = { x: 0, y: crop1.y + crop1.height, width: W, height: even(144 * u) }; + const crop2 = { x: 0, y: strip.y + strip.height, width: W, height: evenDown(a.y1 - (strip.y + strip.height)) }; + const qs = even(W * STACKED_QR_SMALL_SHARE); + const twocrop = { + top, crop1, strip, crop2, + captions: { bottom: crop2.y + crop2.height - Math.round(18 * u) }, + qr: { x: a.x0, y: a.y1 + Math.round((H - a.y1 - qs) / 2), size: qs }, + }; + // The finale: its title in the rail's place, the instrument column over the picture's room. + const finale = { + title: { x: a.x0, y: rail.y, width: a.x1 - a.x0, height: label }, + column: { x: a.x0, y: even(rail.y + label + Math.round(30 * u)), width: evenDown(a.x1 - a.x0), height: 0 }, + }; + finale.column.height = evenDown(a.y1 - Math.round(10 * u) - finale.column.y); + return { + W, H, safe: a, gap, rail, picture, shelf, captions, panel, counters, source: sourceBlock, wordmark, + post: { card, counters: postCounters }, twocrop, finale, + }; +} + +/** + * The panel's cells: `items` in order, each `{ id, tall?, aspect }` (its + * design box's width / height). A TALL item (the dial) takes the left column's + * whole height and the rest stack down the right; without one they fill the + * two columns, the shorter first. Each cell is its column's width and its + * aspect's height (at most what is left). An item that does not fit is left + * out (`out`), never squashed. + * + * @param {{x:number,y:number,width:number,height:number}} panel + * @param {Array<{ id: string, tall?: boolean, aspect: number }>} items + * @param {number} gap + * @returns {{ cells: Record<string, {x:number,y:number,width:number,height:number}>, out: string[] }} + */ +export function panelCells(panel, items, gap) { + const colW = evenDown((panel.width - gap) / 2); + const cols = [ + { x: panel.x, y: panel.y }, + { x: panel.x + panel.width - colW, y: panel.y }, + ]; + const bottom = panel.y + panel.height; + const cells = {}; + const out = []; + let tallDone = false; + for (const it of items) { + if (it.tall && !tallDone && cols[0].y === panel.y) { + cells[it.id] = { x: cols[0].x, y: panel.y, width: colW, height: evenDown(panel.height) }; + cols[0].y = bottom + gap; + tallDone = true; + continue; + } + const h = evenDown(colW / Math.max(0.2, it.aspect)); + // The column with the most room left that holds it. + const fits = cols.filter((c) => c.y + h <= bottom + 0.5).sort((p, q) => p.y - q.y || p.x - q.x); + if (!fits.length || h < 24) { + out.push(it.id); + continue; + } + const c = fits[0]; + cells[it.id] = { x: c.x, y: c.y, width: colW, height: h }; + c.y += h + gap; + } + return { cells, out }; +} + +/** + * The caption geometry the vertical captions (vertical.mjs verticalAss) are + * drawn with in the stacked deck: under the picture, centred, the stacked + * deck's size -- or, for a twocrop clip, over crop two's foot. + */ +export function stackedCaptionGeo(render, { twocrop = false } = {}) { + const g = stackedGeometry(render); + const marginL = g.safe.x0 + Math.round(10 * (g.W / 1080)); + const marginR = g.W - g.safe.x1 + Math.round(10 * (g.W / 1080)); + if (twocrop) { + return { layout: "stacked", size: Math.round(g.captions.size * 1.08), tag: null, captions: { align: 2, marginL, marginR, marginV: g.H - g.twocrop.captions.bottom } }; + } + return { layout: "stacked", size: g.captions.size, tag: null, captions: { align: 8, marginL, marginR, marginV: g.captions.y } }; +} + +/** + * A crop of the source (`[x, y, w, h]` fractions) cut to a box's aspect about + * its centre, in source px (even): what a twocrop band shows. + */ +export function cropToBox(crop, srcW, srcH, box) { + const [fx, fy, fw, fh] = crop; + let w = fw * srcW; + let h = fh * srcH; + const want = box.width / box.height; + if (w / h > want) w = h * want; + else h = w / want; + w = Math.max(2, Math.min(evenDown(w), srcW - (srcW % 2))); + h = Math.max(2, Math.min(evenDown(h), srcH - (srcH % 2))); + const cx = (fx + fw / 2) * srcW; + const cy = (fy + fh / 2) * srcH; + return { w, h, x: Math.round(Math.max(0, Math.min(srcW - w, cx - w / 2))), y: Math.round(Math.max(0, Math.min(srcH - h, cy - h / 2))) }; +} + +/** How far a band enlarges the source's own pixels, each crop (its band's width over the crop's): past ENLARGE_WARN it softens. */ +export function twoCropEnlargement(crops, srcW, srcH, render) { + const g = stackedGeometry(render).twocrop; + return [g.crop1, g.crop2].map((box, i) => { + const c = cropToBox(crops[i], srcW, srcH, box); + return Math.round((box.width / c.w) * 100) / 100; + }); +} + +/** A band enlarged past this many times its source pixels is said to soften (a lint warning, never a refusal). */ +export const ENLARGE_WARN = 2.5; + +/** + * The twocrop picture as ONE filtergraph from the build's picture pad to its + * last filter: the frame's ground, crop one in its band, crop two in its band. + * `blur` the clip's own blur on the source first. + */ +export function twoCropGraph({ crops, srcW, srcH, render, blur = [], fps = 30, id = "tc" }) { + const g = stackedGeometry(render); + const W = g.W; + const H = g.H; + const p = (s) => `${id}${s}`; + const bg = String(render?.palette?.bg ?? "#12100c").replace("#", "0x"); + const t = g.twocrop; + const a = cropToBox(crops[0], srcW, srcH, t.crop1); + const b = cropToBox(crops[1], srcW, srcH, t.crop2); + const lead = [...blur, "setsar=1"].join(","); + return [ + `${lead},split=2[${p("a")}][${p("b")}]`, + `color=c=${bg}:s=${W}x${H}:r=${fps}[${p("g")}]`, + `[${p("a")}]crop=${a.w}:${a.h}:${a.x}:${a.y},scale=${t.crop1.width}:${t.crop1.height}:flags=lanczos,setsar=1[${p("1")}]`, + `[${p("b")}]crop=${b.w}:${b.h}:${b.x}:${b.y},scale=${t.crop2.width}:${t.crop2.height}:flags=lanczos,setsar=1[${p("2")}]`, + `[${p("g")}][${p("1")}]overlay=x=0:y=${t.crop1.y}:shortest=1[${p("g1")}]`, + `[${p("g1")}][${p("2")}]overlay=x=0:y=${t.crop2.y}:format=auto,setsar=1,fps=${fps}`, + ].join(";"); +} + +/** + * The spans the panel's instruments stand down for in the stacked deck: a post + * item (its card takes the room) and a twocrop clip (its strip carries them). + * `[{ from, to }]` in cut seconds, from the schedule's segments. + */ +export function stackedStandDowns(schedule) { + return (schedule?.segments ?? []) + .filter((s) => s.type === "post" || s.vlayout === "twocrop") + .map((s) => ({ from: s.start, to: s.end ?? s.start + s.duration, why: s.type === "post" ? "post" : "twocrop" })); +} + +/** The words a module left out of the stacked deck is said with (the lint, the build's note). */ +export const leftOutWords = (id, why = "no vertical form") => + `${id}: ${why} -- left out of the stacked vertical deck (render.vertical.deck "bare" drops the deck; landscape keeps it)`; diff --git a/umtool/report-to-video/vertical-deck.test.mjs b/umtool/report-to-video/vertical-deck.test.mjs @@ -0,0 +1,292 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; + +import { + ENLARGE_WARN, STACKED_PICTURE_K, cropToBox, panelCells, stackedCaptionGeo, stackedGeometry, stackedOn, stackedSafe, stackedStandDowns, + twoCropEnlargement, twoCropGraph, +} from "./vertical-deck.mjs"; +import { verticalRender } from "./vertical.mjs"; +import { + deckGeometry, deckLayout, deckSchedule, instrumentsGeometry, pictureK, resolveDeck, stampGeometry, validateChrome, +} from "./deck.mjs"; +import { verticalKnobs, validateVerticalRender } from "yt-dlp-transcript-common/lib/report/vertical.mjs"; +import { validateLook } from "yt-dlp-transcript-common/lib/report/look.mjs"; +import { measureExtraGeometry } from "./measure-extras.mjs"; +import { stackedLeftOut, MODULES, verticalFormOf } from "./modules/index.mjs"; +import { stackedLintWarnings } from "./lint.mjs"; +import { stackedDeckHtml, stackedSections, wordmarkOf } from "./chrome-vdeck.mjs"; +import { dialFinaleGeometry } from "./chrome-instruments.mjs"; + +const DECK = { engine: "hyperframes", layout: "deck", deck: {} }; +const landscape = (deck = {}) => ({ width: 1920, height: 1080, fps: 30, chrome: { ...DECK, deck }, palette: { bg: "#0F1312", fg: "#EDF0EC", accent: "#22AB83" } }); +const stacked = (deck = {}, vertical = {}) => verticalRender({ ...landscape(deck), format: "vertical", vertical }); + +const inside = (r, a) => r.x >= a.x0 - 1e-9 && r.x + r.width <= a.x1 + 1e-9 && r.y >= a.y0 - 1e-9 && r.y + r.height <= a.y1 + 1e-9; + +test("the knob: absent is stacked; bare and stacked validate; anything else is refused", () => { + assert.equal(verticalKnobs({}).deck, "stacked"); + assert.equal(verticalKnobs({ vertical: { deck: "bare" } }).deck, "bare"); + assert.deepEqual(validateVerticalRender({ render: { format: "vertical", vertical: { deck: "stacked" } } }), []); + assert.ok(validateVerticalRender({ render: { vertical: { deck: "tall" } } })[0].includes("render.vertical.deck")); +}); + +test("stacked only where a vertical cut keeps a deck; bare and landscape never", () => { + assert.equal(stackedOn(stacked()), true); + assert.equal(stackedOn(stacked({}, { deck: "bare" })), false); + assert.equal(stackedOn(landscape()), false); + // A vertical cut with no deck is the bare vertical whatever it says. + assert.equal(stackedOn(verticalRender({ width: 1920, height: 1080, format: "vertical" })), false); + // verticalRender keeps the chrome only for the stacked deck. + assert.ok(stacked().chrome); + assert.equal(stacked({}, { deck: "bare" }).chrome, undefined); +}); + +test("bare is the vertical as it shipped, byte for byte: the same render, whatever the deck", () => { + const withDeck = verticalRender({ ...landscape(), format: "vertical", vertical: { deck: "bare" } }); + const noDeck = verticalRender({ ...landscape(), chrome: undefined, format: "vertical", vertical: { deck: "bare" } }); + assert.equal(JSON.stringify(withDeck), JSON.stringify(noDeck)); + // And a deck-less vertical cut is unchanged by the default. + const plain = verticalRender({ width: 1920, height: 1080, fps: 30, format: "vertical" }); + assert.equal(plain.chrome, undefined); + assert.equal(plain.width, 1080); +}); + +test("every zone of the stacked deck keeps inside the safe area; the picture is the frame's width", () => { + for (const safe of [{}, { top: 0.1, bottom: 0.22, right: 0.14 }]) { + const r = stacked({ measure: {} }, { safe }); + const g = stackedGeometry(r, { counter: true }); + const a = stackedSafe(r); + for (const [name, box] of [["rail", g.rail], ["captions", g.captions], ["panel", g.panel], ["counters", g.counters], ["source", g.source], ["card", g.post.card], ["post counters", g.post.counters], ["finale", g.finale.column]]) { + assert.ok(inside(box, a), `${name} ${JSON.stringify(box)} inside ${JSON.stringify(a)}`); + } + // Nothing that must be read in the right band or the bottom band. + for (const box of [g.rail, g.captions, g.panel, g.source, g.counters]) { + assert.ok(box.x + box.width <= a.x1); + assert.ok(box.y + box.height <= a.y1); + } + // The picture: the frame's full width, 16:9, under the rail and over the captions. + assert.equal(g.picture.width, g.W); + assert.equal(g.picture.height, Math.round((g.W * 9) / 16 / 2) * 2); + assert.ok(g.picture.y >= g.rail.y + g.rail.height); + assert.ok(g.captions.y >= g.picture.y + g.picture.height); + // The zones stack top to bottom without meeting. + assert.ok(g.panel.y >= g.captions.y + g.captions.height); + assert.ok(g.counters.y >= g.panel.y + g.panel.height); + assert.ok(g.source.y >= g.counters.y + g.counters.height); + // Only the wordmark and the twocrop's small QR stand in the bottom band. + assert.ok(g.wordmark.y >= a.y1); + assert.ok(g.twocrop.qr.y >= a.y1 && g.twocrop.qr.x + g.twocrop.qr.size <= a.x1); + } +}); + +test("the twocrop bands: crop one, the strip, crop two to the bottom band; its captions over crop two's foot", () => { + const r = stacked(); + const g = stackedGeometry(r); + const t = g.twocrop; + assert.equal(t.crop1.y + t.crop1.height, t.strip.y); + assert.equal(t.strip.y + t.strip.height, t.crop2.y); + assert.ok(t.crop2.y + t.crop2.height <= g.safe.y1); + assert.ok(t.top.y >= g.safe.y0 && t.top.y + t.top.height <= t.crop1.y); + const cap = stackedCaptionGeo(r, { twocrop: true }); + assert.equal(cap.captions.align, 2); + assert.ok(g.H - cap.captions.marginV <= t.crop2.y + t.crop2.height && g.H - cap.captions.marginV > t.crop2.y); + // Under the picture otherwise, top-aligned, inside the safe edges. + const c = stackedCaptionGeo(r); + assert.equal(c.captions.align, 8); + assert.equal(c.captions.marginV, g.captions.y); + assert.ok(c.captions.marginR >= g.W - g.safe.x1); +}); + +test("a crop is cut to its band's aspect about its centre; the enlargement is said past 2.5x", () => { + const box = { width: 1080, height: 629 }; + const c = cropToBox([0, 0, 0.5, 0.5], 1920, 1080, box); + assert.ok(Math.abs(c.w / c.h - box.width / box.height) < 0.01); + assert.ok(c.x >= 0 && c.x + c.w <= 1920 && c.y >= 0 && c.y + c.h <= 1080); + const r = stacked(); + const [a, b] = twoCropEnlargement([[0, 0, 0.9, 0.9], [0.8, 0.8, 0.2, 0.2]], 1920, 1080, r); + assert.ok(a < ENLARGE_WARN); + assert.ok(b > ENLARGE_WARN); + const graph = twoCropGraph({ crops: [[0, 0, 0.6, 0.6], [0.6, 0.6, 0.4, 0.4]], srcW: 1920, srcH: 1080, render: r, fps: 30 }); + assert.ok(graph.includes(`overlay=x=0:y=${stackedGeometry(r).twocrop.crop1.y}`)); + assert.ok(graph.includes(`overlay=x=0:y=${stackedGeometry(r).twocrop.crop2.y}`)); + assert.ok(graph.startsWith("setsar=1,split=2")); +}); + +test("a clip's twocrop: its crops required, two boxes inside the picture; the lint says a soft band", () => { + const ok = { render: {}, timeline: [{ type: "clip", id: "a", vertical: { layout: "twocrop", crops: [[0, 0, 0.5, 0.5], [0.5, 0.5, 0.5, 0.5]] } }] }; + assert.deepEqual(validateLook(ok), []); + assert.ok(validateLook({ render: {}, timeline: [{ type: "clip", id: "a", vertical: { layout: "twocrop" } }] })[0].includes("needs")); + assert.ok(validateLook({ render: {}, timeline: [{ type: "clip", id: "a", vertical: { layout: "twocrop", crops: [[0, 0, 1.5, 0.5], [0, 0, 0.5, 0.5]] } }] }).some((x) => x.includes("inside"))); + assert.ok(validateLook({ render: {}, timeline: [{ type: "clip", id: "a", vertical: { layout: "full", crops: [[0, 0, 0.5, 0.5], [0, 0, 0.5, 0.5]] } }] }).some((x) => x.includes("twocrop"))); + const m = { render: { ...landscape(), format: "vertical" }, timeline: [{ type: "clip", id: "a", vertical: { layout: "twocrop", crops: [[0, 0, 0.9, 0.9], [0.9, 0.9, 0.1, 0.1]] } }] }; + assert.equal(stackedLintWarnings(m).length, 1); + assert.ok(stackedLintWarnings(m)[0].includes("crops[1]")); + assert.ok(stackedLintWarnings({ ...m, render: { ...m.render, vertical: { deck: "bare" } } })[0].includes("stacked deck's")); +}); + +test("the panel: the dial tall at the left, the odometer and the trail down the right; what does not fit is left out", () => { + const p = { x: 0, y: 0, width: 900, height: 300 }; + const { cells, out } = panelCells(p, [{ id: "dial", tall: true, aspect: 1 }, { id: "odometer", aspect: 600 / 140 }, { id: "trail", aspect: 600 / 138 }], 20); + assert.deepEqual(out, []); + assert.equal(cells.dial.x, 0); + assert.equal(cells.dial.height, 300); + assert.ok(cells.odometer.x > cells.dial.x + cells.dial.width); + assert.ok(cells.trail.y >= cells.odometer.y + cells.odometer.height); + // Too many for the room: the last is left out, never squashed. + const crowd = panelCells(p, [{ id: "a", aspect: 2 }, { id: "b", aspect: 2 }, { id: "c", aspect: 2 }, { id: "d", aspect: 2 }, { id: "e", aspect: 2 }], 20); + assert.ok(crowd.out.length >= 1); + for (const c of Object.values(crowd.cells)) assert.ok(c.y + c.height <= p.height); +}); + +test("the stacked geometry answers deck.mjs's: the footage the picture, the instruments in the panel, the shell the frame", () => { + const r = stacked({ measure: {} }); + const d = deckGeometry(r); + const g = stackedGeometry(r); + assert.deepEqual(d.footage, g.picture); + assert.deepEqual(d.deck, { x: 0, y: 0, width: 1080, height: 1920 }); + const ig = instrumentsGeometry(r); + for (const n of ["dial", "odometer", "trail"]) assert.ok(inside(ig[n], stackedSafe(r)), n); + assert.equal(pictureK(r), STACKED_PICTURE_K); + // The posts stay popups that never move the picture. + assert.equal(resolveDeck(r).posts.shift, false); + assert.equal(resolveDeck(r).posts.layout, "popup"); + assert.equal(resolveDeck(r).posts.show, false); + // The landscape fit checks do not apply. + assert.deepEqual(validateChrome(r.chrome, r), []); + // The stamp over the picture's lower-left by default, inside it. + const st = stampGeometry(r); + assert.ok(st.x >= d.footage.x && st.y + st.height <= d.footage.y + d.footage.height); + // A measure extra over the picture. + const diet = measureExtraGeometry("diet", r); + assert.ok(diet.y >= d.footage.y && diet.y + diet.height <= d.footage.y + d.footage.height); + // The dial's finale: the column over the picture's room, inside the safe area. + assert.ok(inside(dialFinaleGeometry({ finale: { from: 0, to: 5 } }, r), stackedSafe(r))); +}); + +test("landscape at 1080 is the deck as it always was; 720p fits instead of standing at y < 0", () => { + const r = landscape(); + assert.deepEqual(deckGeometry(r), { W: 1920, H: 1080, footage: { x: 173, y: 2, width: 1574, height: 886 }, deck: { x: 0, y: 890, width: 1920, height: 190 } }); + assert.deepEqual(resolveDeck(r).title, { size: 54, maxChars: 48 }); + assert.equal(resolveDeck(r).height, 190); + const lay = deckLayout(r); + assert.equal(lay.text.titleSize, 54); + assert.equal(lay.qr.size, 150); + const r720 = { ...r, width: 1280, height: 720 }; + const g = deckGeometry(r720); + assert.ok(g.footage.y >= 0, `footage y ${g.footage.y}`); + assert.ok(g.footage.y + g.footage.height <= g.deck.y); + assert.equal(g.deck.y + g.deck.height, 720); + assert.deepEqual(validateChrome(r720.chrome, r720), []); + // Its band scaled with the height: two thirds of the 1080 deck. + assert.equal(g.deck.height, Math.round(190 * (720 / 1080))); + assert.equal(deckLayout(r720).text.titleSize, 36); +}); + +test("the schedule: a stacked deck's clips carry their source parts and a twocrop its layout; landscape does not", () => { + const entries = [ + { id: "c1", type: "clip", video: "v1", start: 125, end: 130, title: "First", channelTitle: "Chan", date: "2026-01-12" }, + { id: "c2", type: "clip", video: "v2", start: 5, end: 9, title: "Second", vertical: { layout: "twocrop", crops: [[0, 0, 0.5, 0.5], [0.5, 0.5, 0.5, 0.5]] } }, + { id: "p1", type: "post", platform: "x", author: "A", handle: "a", date: "2026-11-04", text: "hi" }, + ]; + const args = { entries, durs: [5, 4, 6], D: 0.4, provenance: {}, metas: [null, null, null] }; + const v = deckSchedule({ ...args, render: stacked() }); + assert.equal(v.segments[0].vsource.clock, "2:05"); + assert.equal(v.segments[0].vsource.channel, "Chan"); + assert.equal(v.segments[1].vlayout, "twocrop"); + assert.equal(v.segments[2].vsource, undefined); + assert.deepEqual(stackedStandDowns(v).map((x) => x.why), ["twocrop", "post"]); + const l = deckSchedule({ ...args, render: landscape() }); + assert.equal(l.segments[0].vsource, undefined); + assert.equal(l.segments[1].vlayout, undefined); +}); + +test("the shell's page in 9:16: the rail's sections, each segment's source block and its QR, the wordmark", () => { + const r = stacked({ markers: [{ after: "c1", label: "Carnivore", color: "#C9534B" }], sectionTitle: { first: "The first diets" }, pip: { color: "section" } }); + const entries = [ + { id: "c1", type: "clip", video: "v1", start: 5, end: 9, title: "First", channelTitle: "Chan", date: "2026-01-12" }, + { id: "c2", type: "clip", video: "v2", start: 5, end: 9, title: "Second", channelTitle: "Chan", date: "2026-01-13" }, + ]; + const sched = deckSchedule({ entries, durs: [4, 4], D: 0.4, render: r, provenance: {}, metas: [null, null] }); + const sec = stackedSections(sched, r); + assert.deepEqual(sec.sections.map((s) => s.label), ["The first diets", "Carnivore"]); + const html = stackedDeckHtml(sched, r, { qrSrcs: { c1: "assets/qr00.png" }, site: wordmarkOf({ siteOrigin: "https://jeralyzer.pages.dev" }) }); + assert.ok(html.includes('data-width="1080" data-height="1920"')); + assert.ok(html.includes("JERALYZER")); + assert.ok(html.includes("Carnivore") && html.includes("The first diets")); + assert.ok(html.includes("assets/qr00.png")); + assert.ok(html.includes('id="deck-data"')); + assert.ok(html.includes("1 / 2") && html.includes("2 / 2")); +}); + +test("what the stacked deck leaves out is said; every module that stands in it declares where", () => { + const forms = new Map(MODULES.map((m) => [m.id, verticalFormOf(m)?.slot ?? null])); + assert.equal(forms.get("shell"), "frame"); + assert.equal(forms.get("dial"), "panel"); + assert.equal(forms.get("dial-finale"), "finale"); + assert.equal(forms.get("popup-posts"), null); + const m = { render: { ...landscape({ measure: {} }), format: "vertical", chrome: { ...DECK, deck: { measure: {} }, flips: { items: [] } } }, posts: [{ id: "p" }], timeline: [] }; + const words = stackedLeftOut(m); + assert.ok(words.some((w) => w.startsWith("popup-posts:"))); + assert.ok(words.some((w) => w.startsWith("flips:"))); + assert.deepEqual(stackedLeftOut({ ...m, render: { ...m.render, vertical: { deck: "bare" } } }), []); + assert.deepEqual(stackedLeftOut({ ...m, render: landscape() }), []); +}); + +// ---- landscape and the bare vertical: byte for byte what main drew ----------------------------- +// +// md5s taken from main (7f7767a0) with the same fixture -- the measure-dial cut of instruments.test.mjs with +// markers and a section title: the estimate's schedule, the deck's page, the dial's, the odometer's, the trail's, +// the dial finale's and the deck's geometry; and the bare vertical's render, each clip layout's geometry, picture +// graph and words, and a post's box. +const MAIN = { + schedule: "4ebd0afd1cddb975b6d20ce934df2158", + deck: "546848c82d65e45e4d1a4ac4c7a9c3c8", + dial: "f7e21e4a3622703975f746d39cbcb738", + odometer: "8425983d217408dddcb6ee794881c6c4", + trail: "3512192be69f8b9bc33aec6e7b41a088", + dialFinale: "52866e4d87e15bd55afe8c1a703414a3", + geometry: "182959796c281f769766df3d02962904", + bare: "7ce1f7a66452adec21575bcdbba900f1", +}; + +test("a landscape cut and a bare vertical draw what main drew, byte for byte", async () => { + const { createHash } = await import("node:crypto"); + const { readFileSync } = await import("node:fs"); + const path = await import("node:path"); + const { fileURLToPath } = await import("node:url"); + const deck = await import("./deck.mjs"); + const ci = await import("./chrome-instruments.mjs"); + const cd = await import("./chrome-deck.mjs"); + const v = await import("./vertical.mjs"); + const here = path.dirname(fileURLToPath(import.meta.url)); + const md5 = (s) => createHash("md5").update(typeof s === "string" ? s : JSON.stringify(s)).digest("hex"); + const MEASURE = JSON.parse(readFileSync(path.join(here, "fixtures/measure-dial/measure.json"), "utf8")); + const RENDER = { + width: 1920, height: 1080, fps: 30, transition: 0.4, + palette: { bg: "#0F1312", fg: "#EDF0EC", muted: "#98A29B", accent: "#22AB83", amber: "#E8A33F" }, + chrome: { ...DECK, deck: { dial: true, odometer: true, trail: true, qr: { show: false }, finale: { video: "side", totals: false }, markers: [{ after: "c3", label: "Two" }], sectionTitle: { first: "One" } } }, + }; + const timeline = Array.from({ length: 9 }, (_, i) => ({ + type: "clip", id: `c${i + 1}`, video: "vidx", start: 10 * i, end: 10 * i + (i === 8 ? 14 : 8), cite: 1, section: 0, + quote: "q", onscreen: { title: `Clip ${i + 1}` }, ...(i === 8 ? { layout: "finale" } : {}), + })); + const s = { ...deck.estimateSchedule({ slug: "m", title: "M", provenance: {}, render: RENDER, timeline }), measure: MEASURE }; + const fonts = { DeckSans: "assets/r.ttf", DeckSansBold: "assets/b.ttf" }; + assert.equal(md5(s), MAIN.schedule); + assert.equal(md5(cd.deckHtml(s, RENDER, { fonts: { regular: "r.ttf", bold: "b.ttf" } })), MAIN.deck); + assert.equal(md5(ci.dialHtml(s, RENDER, { fonts })), MAIN.dial); + assert.equal(md5(ci.odometerHtml(s, RENDER, { fonts })), MAIN.odometer); + assert.equal(md5(ci.trailHtml(s, RENDER, { fonts })), MAIN.trail); + const win = deck.snapWindow({ segment: "dial-finale", from: s.finale.from, to: s.finale.to }, { fps: 30, total: s.total }); + assert.equal(md5(ci.dialFinaleHtml(s, RENDER, win, { fonts })), MAIN.dialFinale); + assert.equal(md5([deck.deckGeometry(RENDER), deck.instrumentsGeometry(RENDER), deck.deckLayout(RENDER, { schedule: s }), deck.stampGeometry(RENDER), deck.statsGeometry({ ...RENDER, chrome: { ...RENDER.chrome, stats: {} } })]), MAIN.geometry); + const vr = v.verticalRender({ ...RENDER, format: "vertical", vertical: { deck: "bare", clip: "framed", hook: "section" } }); + const words = [{ text: "so", start: 0.2, end: 0.4 }, { text: "the", start: 0.45, end: 0.6 }, { text: "scale", start: 0.62, end: 1 }, { text: "says", start: 1.1, end: 1.4 }]; + const bare = { render: vr, layouts: {} }; + for (const layout of ["full", "framed", "quote", "split", "overlay"]) { + const geo = v.clipGeometry(layout, vr); + bare.layouts[layout] = { geo, graph: v.verticalClipGraph({ geo, srcW: 1920, srcH: 1080, crop: null, fps: 30 }), ass: v.verticalAss({ geo, render: vr, words, seconds: 3, tag: "Chan · 12 Jan 2026", hook: "One" }) }; + } + bare.post = v.verticalPostBox(vr); + assert.equal(md5(bare), MAIN.bare); +}); diff --git a/umtool/report-to-video/vertical.mjs b/umtool/report-to-video/vertical.mjs @@ -22,11 +22,12 @@ // command (lib/report/verticalCli.mjs) call it. import { - VERTICAL_HEIGHT, VERTICAL_WIDTH, clipLayoutOf, sidePostOf, sideSpan, verticalKnobs, verticalOn, + VERTICAL_HEIGHT, VERTICAL_WIDTH, clipLayoutOf, sidePostOf, sideSpan, stackedDeckWanted, verticalKnobs, verticalOn, } from "yt-dlp-transcript-common/lib/report/vertical.mjs"; import { assColour, assTime, captionText, cropPixels } from "./look.mjs"; export { + CLIP_OWN_LAYOUTS, VERTICAL_DECKS, clipTwoCrop, stackedDeckWanted, LANDSCAPE_SIDE_PLACES, RENDER_FORMATS, SIDE_MIN_SECONDS, SIDE_PLACES, VERTICAL_CAPTION_SIZES, VERTICAL_CLIP_LAYOUTS, VERTICAL_DEFAULTS, VERTICAL_HEIGHT, VERTICAL_HOOKS, VERTICAL_KEYS, VERTICAL_POST_LAYOUTS, VERTICAL_SIDE_LAYOUTS, VERTICAL_WIDTH, clipLayoutOf, sideErrors, sidePostOf, sideSpan, validateClipSides, validateVerticalFormat, @@ -54,13 +55,17 @@ export const SIDE_MOTION = 0.35; /** * The render a vertical cut is built with: 1080x1920 at the cut's fps, no * header, footer, QR, rail, deck or montage; the cut's posts, narration, - * palette and fonts kept; the loudness the short is brought to. + * palette and fonts kept; the loudness the short is brought to. A cut that + * keeps its deck (`render.vertical.deck` "stacked", the default, on a cut with + * one: vertical-deck.mjs) keeps `chrome` -- the deck's geometry answers for + * 9:16 -- and nothing else changes; "bare" is the format as it first shipped. */ export function verticalRender(render = {}) { - const { chrome: _c, rail: _r, chromeEngine: _e, brand: _b, montage: _m, intro: _i, room: _ro, ...rest } = render; + const { chrome, rail: _r, chromeEngine: _e, brand: _b, montage: _m, intro: _i, room: _ro, ...rest } = render; const k = verticalKnobs(render); return { ...rest, + ...(stackedDeckWanted(render) ? { chrome } : {}), format: "vertical", width: VERTICAL_WIDTH, height: VERTICAL_HEIGHT,