Archilyzer · Source

archilyzer

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

commit 725a908c1f36b869d1f4036f3fa62a75ce881d09
parent e6a07ce54701019ee6f02725c0d3b2c5cae73f10
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Fri, 13 Nov 2026 21:11:37 -0500

clip kit C: desktop clips -- 16:9, minimal chrome, captions, for X

`umtool vertical <p> --take <t> --items a --desktop` and a batch's `desktop` format build
a take's clips 1920x1080 through the same per-clip branch a short uses, in its own
geometry (vertical.mjs desktopGeometry): the picture full frame (fitted, no letterbox),
one thin source line on a plate, the words lit along the foot (verticalAss with the
desktop knobs), a code only when asked (render.desktop.qr, any corner; a bottom one
narrows the captions both sides). -14 LUFS; over 140 s a note.

render.desktop is a look key (common vertical.mjs DESKTOP_DEFAULTS, desktopKnobs,
validateDesktopRender): the Look panel's Desktop clips (source line, QR, captions),
umtool look desktop={...}. build-video --desktop [--desktop-knobs]; desktopRender marks
the render (desktopBuild) so the lint measures its code. A batch keeps a short's code at
the top when a bottom corner is asked for the desktop clips (a note).

A cut never renders desktop by itself; --landscape (the take's own look) is unchanged.
Render test: a desktop clip's size, code and plate; a short with no code byte-identical
whether qr is absent or false.

Co-Authored-By: Claude <noreply@anthropic.com>

Diffstat:
Mcommon/lib/report/look.d.mts | 2+-
Mcommon/lib/report/look.mjs | 2+-
Mcommon/lib/report/vertical.d.mts | 20++++++++++++++++++++
Mcommon/lib/report/vertical.mjs | 89++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Mcommon/lib/report/videoAssistOps.test.ts | 2+-
Meditor/CHANGELOG.md | 10++++++++++
Mumtool/components/projects/report/LookPanel.tsx | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/docs/cli.md | 16++++++++++------
Mumtool/docs/knobs.md | 34+++++++++++++++++++++++++++++++++-
Mumtool/lib/cli/verbs.mjs | 10+++++-----
Mumtool/lib/report/look.test.mjs | 2+-
Mumtool/lib/report/shortsBatch.mjs | 18++++++++++++++++--
Mumtool/lib/report/shortsCli.mjs | 21++++++++++++---------
Mumtool/lib/report/verticalCli.mjs | 70+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------
Mumtool/report-to-video/build-video.mjs | 55+++++++++++++++++++++++++++++++++++++++++++++----------
Aumtool/report-to-video/clip-kit-render.test.mjs | 131+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/report-to-video/clip-kit.mjs | 20+++++++++++++++++++-
Mumtool/report-to-video/clip-kit.test.mjs | 64++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/report-to-video/lint.mjs | 11++++++++++-
Mumtool/report-to-video/vertical.mjs | 67++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
20 files changed, 644 insertions(+), 52 deletions(-)

diff --git a/common/lib/report/look.d.mts b/common/lib/report/look.d.mts @@ -4,7 +4,7 @@ type Manifest = { render?: Record<string, unknown> | null; timeline?: unknown[] } & Record<string, unknown>; type Render = Record<string, unknown> | null | undefined; -export type LookKey = "headerHeight" | "footerHeight" | "qr" | "transition" | "transitionStyle" | "loudness" | "captions" | "room" | "slide" | "blur" | "intro" | "format" | "vertical" | "mode" | "basic" | "tallWindows"; +export type LookKey = "headerHeight" | "footerHeight" | "qr" | "transition" | "transitionStyle" | "loudness" | "captions" | "room" | "slide" | "blur" | "intro" | "format" | "vertical" | "mode" | "basic" | "tallWindows" | "desktop"; export const LOOK_KEYS: readonly LookKey[]; export const QR_CORNERS: readonly ["br", "bl", "tr", "tl"]; export const QR_LINK_VALUES: readonly ["cite", "moment", "channel"]; diff --git a/common/lib/report/look.mjs b/common/lib/report/look.mjs @@ -29,7 +29,7 @@ const round2 = (n) => Number(Number(n).toFixed(2)); /** The corner code's corners and links (lane clip-kit; umtool report-to-video clip-kit.mjs draws them). */ export const QR_CORNERS = Object.freeze(["br", "bl", "tr", "tl"]); export const QR_LINK_VALUES = Object.freeze(["cite", "moment", "channel"]); -export const LOOK_KEYS = Object.freeze(["headerHeight", "footerHeight", "qr", "transition", "transitionStyle", "loudness", "captions", "room", "slide", "blur", "intro", "format", "vertical", "mode", "basic", "tallWindows"]); +export const LOOK_KEYS = Object.freeze(["headerHeight", "footerHeight", "qr", "transition", "transitionStyle", "loudness", "captions", "room", "slide", "blur", "intro", "format", "vertical", "mode", "basic", "tallWindows", "desktop"]); /** `headerHeight` / `footerHeight`: whole pixels, 0 (off) to this. */ export const BAND_MAX = 240; diff --git a/common/lib/report/vertical.d.mts b/common/lib/report/vertical.d.mts @@ -53,3 +53,23 @@ export const VERTICAL_QR_KEYS: readonly string[]; export const VERTICAL_QR_SIZE: Readonly<{ min: number; max: number; default: number }>; export const QR_LINKS: readonly ["cite", "moment", "channel"]; export function verticalQrErrors(v: unknown, where?: string): string[]; + +export type DesktopKnobs = { + tag: boolean; + hook: false | "title" | "section" | { text: string }; + captions: { size: "m" | "l" | "xl"; lines: 1 | 2 }; + safe: { top: number; bottom: number; right: number; left: number }; + loudness: number; + maxSeconds: number; + qr: false | true | { corner?: "br" | "bl" | "tr" | "tl"; size?: number; links?: "cite" | "moment" | "channel" }; +}; +export const DESKTOP_WIDTH: number; +export const DESKTOP_HEIGHT: number; +export const DESKTOP_CAPTION_SIZES: readonly ["m", "l", "xl"]; +export const DESKTOP_QR_CORNERS: readonly ["br", "bl", "tr", "tl"]; +export const DESKTOP_QR_SIZE: Readonly<{ min: number; max: number; default: number }>; +export const DESKTOP_SAFE_MAX: number; +export const DESKTOP_DEFAULTS: Readonly<DesktopKnobs>; +export const DESKTOP_KEYS: readonly string[]; +export function desktopKnobs(render: Render): DesktopKnobs; +export function validateDesktopRender(manifest: { render?: Record<string, unknown> | null } | null | undefined): string[]; diff --git a/common/lib/report/vertical.mjs b/common/lib/report/vertical.mjs @@ -245,4 +245,91 @@ export function sideSpan(side, seconds) { } /** All of the vertical format's checks. */ -export const validateVerticalFormat = (manifest) => [...validateVerticalRender(manifest), ...validateClipSides(manifest)]; +export const validateVerticalFormat = (manifest) => [...validateVerticalRender(manifest), ...validateDesktopRender(manifest), ...validateClipSides(manifest)]; + +// --------------------------------------------------------------------------- +// THE DESKTOP CLIP (lane clip-kit, slice C): a clip of a take built 16:9 by the same per-clip builder as a short +// (`umtool vertical --desktop`, a batch's `desktop` format) -- for X, which autoplays muted: the picture full frame +// (no letterbox, no header), ONE thin source line on a small plate over it, the words lit as they are said along its +// foot, a code in a corner only when asked. Its knobs are `render.desktop`; absent, the defaults below (the +// "minimal chrome" look). A cut never renders desktop by itself: only a per-clip build asks for it. +// +// render.desktop { tag?, hook?, captions?: {size?, lines?}, safe?: {top?, bottom?, right?, left?}, loudness?, +// maxSeconds?, qr?: false | true | {corner?: "br"|"bl"|"tr"|"tl", size?, links?} } +// --------------------------------------------------------------------------- + +export const DESKTOP_WIDTH = 1920; +export const DESKTOP_HEIGHT = 1080; +export const DESKTOP_CAPTION_SIZES = Object.freeze(["m", "l", "xl"]); +export const DESKTOP_QR_CORNERS = Object.freeze(["br", "bl", "tr", "tl"]); +export const DESKTOP_QR_SIZE = Object.freeze({ min: 0.05, max: 0.2, default: 0.09 }); +export const DESKTOP_SAFE_MAX = 0.25; +export const DESKTOP_DEFAULTS = Object.freeze({ + tag: true, + hook: false, + captions: Object.freeze({ size: "l", lines: 2 }), + safe: Object.freeze({ top: 0.04, bottom: 0.08, right: 0.03, left: 0.03 }), + loudness: -14, + maxSeconds: 140, + qr: false, +}); +export const DESKTOP_KEYS = Object.freeze(Object.keys(DESKTOP_DEFAULTS)); + +/** A desktop clip's knobs: `render.desktop` over the defaults. */ +export function desktopKnobs(render) { + const v = isObj(render?.desktop) ? render.desktop : {}; + return { + tag: typeof v.tag === "boolean" ? v.tag : DESKTOP_DEFAULTS.tag, + hook: v.hook === undefined || v.hook === null ? DESKTOP_DEFAULTS.hook : v.hook, + captions: { ...DESKTOP_DEFAULTS.captions, ...(isObj(v.captions) ? v.captions : {}) }, + safe: { ...DESKTOP_DEFAULTS.safe, ...(isObj(v.safe) ? v.safe : {}) }, + loudness: num(v.loudness) ? v.loudness : DESKTOP_DEFAULTS.loudness, + maxSeconds: num(v.maxSeconds) ? v.maxSeconds : DESKTOP_DEFAULTS.maxSeconds, + qr: v.qr === true || isObj(v.qr) ? v.qr : DESKTOP_DEFAULTS.qr, + }; +} + +/** Each thing wrong with `render.desktop` ([] when fine, or absent). */ +export function validateDesktopRender(manifest) { + const v = manifest?.render?.desktop; + if (v === undefined || v === null) return []; + if (!isObj(v)) return [`render.desktop must be an object of the desktop knobs (${DESKTOP_KEYS.join(", ")})`]; + const errors = []; + for (const k of Object.keys(v)) if (!DESKTOP_KEYS.includes(k)) errors.push(`render.desktop.${k} is not a desktop knob (${DESKTOP_KEYS.join(", ")})`); + if (v.tag !== undefined && typeof v.tag !== "boolean") errors.push("render.desktop.tag must be true or false"); + if (v.hook !== undefined && v.hook !== false) { + if (isObj(v.hook)) { + const t = v.hook.text; + if (Object.keys(v.hook).some((k) => k !== "text") || typeof t !== "string" || !t.trim() || t.length > VERTICAL_HOOK_MAX) errors.push(`render.desktop.hook.text must be a line of 1–${VERTICAL_HOOK_MAX} characters`); + } else if (!VERTICAL_HOOKS.includes(v.hook)) errors.push(`render.desktop.hook must be false, ${VERTICAL_HOOKS.map(q).join(", ")} or {text}`); + } + if (v.captions !== undefined) { + if (!isObj(v.captions)) errors.push("render.desktop.captions must be {size?, lines?}"); + else { + for (const k of Object.keys(v.captions)) if (k !== "size" && k !== "lines") errors.push(`render.desktop.captions.${k} is not a caption knob (size, lines)`); + if (v.captions.size !== undefined && !DESKTOP_CAPTION_SIZES.includes(v.captions.size)) errors.push(`render.desktop.captions.size must be one of ${DESKTOP_CAPTION_SIZES.join(", ")}`); + if (v.captions.lines !== undefined && v.captions.lines !== 1 && v.captions.lines !== 2) errors.push("render.desktop.captions.lines must be 1 or 2"); + } + } + if (v.safe !== undefined) { + if (!isObj(v.safe)) errors.push("render.desktop.safe must be {top?, bottom?, right?, left?}"); + else { + for (const [k, x] of Object.entries(v.safe)) { + if (!["top", "bottom", "right", "left"].includes(k)) errors.push(`render.desktop.safe.${k} is not an edge (top, bottom, right, left)`); + else if (!num(x) || x < 0 || x > DESKTOP_SAFE_MAX) errors.push(`render.desktop.safe.${k} must be a fraction of the frame from 0 to ${DESKTOP_SAFE_MAX}`); + } + } + } + if (v.loudness !== undefined && !(num(v.loudness) && v.loudness >= -30 && v.loudness <= -8)) errors.push("render.desktop.loudness must be a LUFS target from -30 to -8"); + if (v.maxSeconds !== undefined && !(num(v.maxSeconds) && v.maxSeconds >= 5 && v.maxSeconds <= 600)) errors.push("render.desktop.maxSeconds must be 5 to 600 seconds"); + if (v.qr !== undefined && v.qr !== true && v.qr !== false) { + if (!isObj(v.qr)) errors.push("render.desktop.qr is true, false or {corner?, size?, links?}"); + else { + for (const k of Object.keys(v.qr)) if (!VERTICAL_QR_KEYS.includes(k)) errors.push(`render.desktop.qr.${k} is not a key (${VERTICAL_QR_KEYS.join(", ")})`); + if (v.qr.corner !== undefined && !DESKTOP_QR_CORNERS.includes(v.qr.corner)) errors.push(`render.desktop.qr.corner is one of ${DESKTOP_QR_CORNERS.join(", ")}`); + if (v.qr.size !== undefined && !(num(v.qr.size) && v.qr.size >= DESKTOP_QR_SIZE.min && v.qr.size <= DESKTOP_QR_SIZE.max)) errors.push(`render.desktop.qr.size is ${DESKTOP_QR_SIZE.min}–${DESKTOP_QR_SIZE.max} of the frame's width`); + if (v.qr.links !== undefined && !QR_LINKS.includes(v.qr.links)) errors.push(`render.desktop.qr.links is one of ${QR_LINKS.join(", ")}`); + } + } + return errors; +} diff --git a/common/lib/report/videoAssistOps.test.ts b/common/lib/report/videoAssistOps.test.ts @@ -26,7 +26,7 @@ test("the look's rules: one patch function — keys refused, null removes, qr on assert.deepEqual(bad.errors, validateTransitionStyle({ render: { slide: { blur: 9 } } })); assert.deepEqual(applyLookPatch(m, { loudness: { target: -40 } }).errors, validateLook({ render: { loudness: { target: -40 } } })); assert.deepEqual(lookErrors(m), []); - assert.equal(LOOK_KEYS.length, 16); + assert.equal(LOOK_KEYS.length, 17); }); test("render.mode and render.basic: deck is the default (no key), basic the footage alone; the fades checked", () => { diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -1,6 +1,16 @@ # Changelog ## [Unreleased] +- **umtool: desktop clips, 16:9 with minimal chrome, for X.** `umtool vertical … --desktop`, or a batch's `desktop` + format (`umtool shorts … --formats vertical,desktop`), builds a take's clips at 1920x1080 with the builder shorts + use. + - The picture fills the frame, with no letterbox. + - One thin source line ("channel · date") sits on a small plate. + - Captions are lit word by word along the foot, because X autoplays muted. + - There is a code only when asked: `--qr on`, `--qr-corner br|bl|tr|tl`. + - The clip is brought to -14 LUFS. Over 140 s it gets a note. + - Set it in `render.desktop` or the Look panel's **Desktop clips**. A cut never renders desktop by itself. + - `--landscape` (the take's whole 16:9 look) is unchanged. - **umtool: a clip's QR can stand in any corner and link the source at the clip's second.** - `render.qr.corner` is `br` (the default) or `bl`, `tr` or `tl`, so the code can stay off the streamer's camera box. - `render.qr.links` is `cite` (the default), `moment` or `channel`. `moment` links the clip's own recording at the diff --git a/umtool/components/projects/report/LookPanel.tsx b/umtool/components/projects/report/LookPanel.tsx @@ -43,6 +43,7 @@ type Look = { slide?: { travel?: number; blur?: number; grain?: number } | null; blur?: string; intro?: string | { style?: string; [k: string]: unknown } | null; + desktop?: { tag?: boolean; qr?: boolean | { corner?: string; size?: number; links?: string }; captions?: { size?: string; lines?: number }; [k: string]: unknown } | null; }; type Mode = "deck" | "basic"; type View = { look: Look; mode?: Mode; preset?: string | null; deck: boolean; montage: boolean; styles: string[]; introStyles?: string[]; errors: string[]; token: string | null }; @@ -76,8 +77,31 @@ type Draft = { blur: "on" | "off"; intro: string; mode: Mode; + deskTag: boolean; + deskQr: string; + deskSize: string; }; +/** A desktop clip's code as the panel shows it: off, or its corner (br when on with none). */ +const deskQrOf = (d: Look["desktop"]) => (!d?.qr ? "off" : typeof d.qr === "object" ? (d.qr.corner ?? "br") : "br"); + +/** render.desktop as the draft would write it: only what is off its default; null for none. */ +function desktopNext(was: Look["desktop"], d: Draft): Look["desktop"] { + const { tag: _t, qr: _q, captions: _c, ...rest } = was ?? {}; + const next: NonNullable<Look["desktop"]> = { ...rest }; + if (!d.deskTag) next.tag = false; + if (d.deskQr !== "off") { + const old = was?.qr && typeof was.qr === "object" ? was.qr : {}; + const { corner: _k, ...keep } = old; + next.qr = d.deskQr === "br" && !Object.keys(keep).length ? true : { ...keep, ...(d.deskQr !== "br" ? { corner: d.deskQr } : {}) }; + } + const caps = { ...(was?.captions ?? {}) }; + if (d.deskSize === "l") delete caps.size; + else caps.size = d.deskSize; + if (Object.keys(caps).length) next.captions = caps; + return Object.keys(next).length ? next : null; +} + /** One of render.qr's settings (the clip kit: corner, links), or its default. */ const qrField = (qr: unknown, k: "corner" | "links", dflt: string) => qr && typeof qr === "object" && typeof (qr as Record<string, unknown>)[k] === "string" ? String((qr as Record<string, unknown>)[k]) : dflt; @@ -108,6 +132,9 @@ function draftOf(l: Look, mode: Mode = "deck"): Draft { blur: l.blur === "off" ? "off" : "on", intro: introStyleOf(l.intro), mode, + deskTag: l.desktop?.tag !== false, + deskQr: deskQrOf(l.desktop), + deskSize: l.desktop?.captions?.size ?? "l", }; } @@ -157,6 +184,11 @@ function patchOf(was: Look, d: Draft, view: View): Record<string, unknown> { (!on || ((was0?.maxS ?? ROOM.maxS) === maxS && (was0?.minGap ?? ROOM.minGap) === minGap)); if (!same) p.room = next; } + // The desktop clips (render.desktop, the clip kit): the source line, a code, the captions' size. + { + const next = desktopNext(was.desktop, d); + if (JSON.stringify(next ?? null) !== JSON.stringify(was.desktop ?? null)) p.desktop = next; + } // The output mode (render.mode): the writer keeps "deck" as no key unless a look preset's must be beaten. if (d.mode !== (view.mode ?? "deck")) p.mode = d.mode; // The blurred clips (render.blur): "on" is the default, written as no key. @@ -344,6 +376,26 @@ export default function LookPanel({ project }: { project: string }) { </Field> )} </div> + <div className="mt-3 flex flex-wrap items-end gap-x-5 gap-y-2" data-look-desktop=""> + <span className="text-[12.5px] text-text-2" title="umtool vertical --desktop, umtool shorts --formats desktop: 16:9, the picture full frame">Desktop clips</span> + {check("deskTag", "Source line", "data-look-desktop-tag")} + <Field label="QR"> + <Select data-look-desktop-qr="" value={draft.deskQr} disabled={busy} onChange={(e) => set({ deskQr: e.target.value })}> + <option value="off">none</option> + <option value="br">bottom right</option> + <option value="bl">bottom left</option> + <option value="tr">top right</option> + <option value="tl">top left</option> + </Select> + </Field> + <Field label="Captions"> + <Select data-look-desktop-size="" value={draft.deskSize} disabled={busy} onChange={(e) => set({ deskSize: e.target.value })}> + <option value="m">medium</option> + <option value="l">large</option> + <option value="xl">extra large</option> + </Select> + </Field> + </div> {!view.montage && ( <div className="mt-3 flex flex-wrap items-center gap-x-5 gap-y-2" data-look-room=""> <span className="text-[12.5px] text-text-2">Room at the clips&rsquo; edges</span> diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md @@ -274,8 +274,8 @@ 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] [--landscape] [--dry-run] [--intro] [--no-intro] [--no-outro] [--deck stacked\|bare] [--qr on\|off] [--qr-corner tr\|tl]` | a vertical short (1080x1920) of a take's items | form · queued · *project* | -| `shorts <project> --take TAKE [--items ITEMS] [--all] [--again] [--formats FORMATS] [--clip full\|framed\|quote] [--post card\|stack\|media] [--side split\|overlay] [--hook HOOK] [--captions l\|xl] [--lines 1\|2] [--loudness N] [--max-vertical N] [--max-landscape N] [--deck stacked\|bare] [--qr on\|off] [--qr-corner tr\|tl] [--replace] [--dry-run]` | a batch of shorts: each clip of a take in each format, into shorts-<take>/ | 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] [--landscape] [--desktop] [--dry-run] [--intro] [--no-intro] [--no-outro] [--deck stacked\|bare] [--qr on\|off] [--qr-corner tr\|tl\|br\|bl]` | a vertical short (1080x1920) of a take's items | form · queued · *project* | +| `shorts <project> --take TAKE [--items ITEMS] [--all] [--again] [--formats FORMATS] [--clip full\|framed\|quote] [--post card\|stack\|media] [--side split\|overlay] [--hook HOOK] [--captions l\|xl] [--lines 1\|2] [--loudness N] [--max-vertical N] [--max-landscape N] [--max-desktop N] [--deck stacked\|bare] [--qr on\|off] [--qr-corner tr\|tl\|br\|bl] [--replace] [--dry-run]` | a batch of shorts: each clip of a take in each format, into shorts-<take>/ | 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* | @@ -549,6 +549,8 @@ $U vertical emberparadox/mr-obvious --take mid-14 --reel short-die --reframe --j - **The cut itself vertical**: `umtool look <p> format='"vertical"' vertical='{"clip":"framed","post":"card"}'` (or the same keys in a take's patch) renders the whole timeline 9:16 -- `umtool take` as ever. - `--landscape` builds the same items in the take's 16:9 look, to compare (a side post is a panel at the right). +- **`--desktop`** builds the same items 16:9 with minimal chrome for X: the picture full frame, one thin source line, + the words lit along its foot, a code only with `--qr` ([knobs.md](knobs.md#desktop-clips-169-minimal-chrome)). - **A code on the short:** `--qr on` (or `--qr-corner tr|tl`) puts one at the top of the safe area, linking the source at the second each clip plays from ([knobs.md](knobs.md#a-clips-qr-its-corner-and-its-link)). - **Many clips, both formats, one command:** `umtool shorts` ([below](#make-promo-clips-a-batch-of-shorts)). @@ -567,13 +569,15 @@ The clipping job as one command: each listed clip of a take, in each format, thr ```sh U="node umtool/bin/umtool.mjs" -$U shorts my-clips --take kit --items w01,w03,w05 --formats vertical,landscape --clip framed --hook title +$U shorts my-clips --take kit --items w01,w03,w05 --formats vertical,desktop --clip framed --hook title $U shorts my-clips --take kit --all --dry-run # the names and files it would write $U shorts my-clips --take kit --again # the folder's batch.json made again ``` - **Formats.** `vertical` is `umtool vertical`'s 9:16 short (its layouts and flags: `--clip`, `--hook`, `--captions`, …); - `landscape` is the same clip in the take's own 16:9 look (`umtool vertical --landscape`). + `desktop` the same clip 16:9 with minimal chrome (`umtool vertical --desktop`: the X clip); `landscape` the same clip + in the take's own 16:9 look (`umtool vertical --landscape`). A bottom `--qr-corner` is the desktop clips'; a short + keeps its code at the top right (said in its notes). - **Names.** `<name>.<format>.mp4`, each with its record (`.json`): the clip's `name` when it pins one, else its title's slug, else its id. A name another clip of the folder holds gets `-<clip id>` (two clips of one cut often share a title). Once a clip has a name in `batch.json` it keeps it, whatever its title becomes. @@ -581,8 +585,8 @@ $U shorts my-clips --take kit --again # the folder's batch.json - **`batch.json`** names each clip's files, lengths, notes and errors, the knobs it was last built with and its **snapshot** (its framing, `vertical` and `side`, as read). `--again` builds every clip of the folder again with its own formats, knobs and snapshot, so a later edit of the project does not silently change a rebuild. -- **Length.** A vertical over 180 s (`--max-vertical`, Shorts' 3 minutes) or a landscape over 140 s (`--max-landscape`, - X's 2:20) is said so in the record: a note, never a refusal. +- **Length.** A vertical over 180 s (`--max-vertical`, Shorts' 3 minutes) or a desktop or landscape clip over 140 s + (`--max-desktop`, `--max-landscape`, X's 2:20) is said so in the record: a note, never a refusal. - Each build runs in the heavy slot as `umtool vertical`'s does (another job may run between two clips). A clip that fails is recorded with its error and the rest go on; the command exits 1 at the end. - Not `shorts/`: that folder is the clip editor's **Make a short**, whose every mp4 the Deliver tab reads as a clip's. diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -379,6 +379,38 @@ project without the knob. |---|---|---|---| | taller windows | — | `umtool look <p> tallWindows=true` (`false` turns it off) | `PUT /api/report/render {patch: {tallWindows}}` | +## Desktop clips (16:9, minimal chrome) + +A take's clips built 16:9 for X, by the builder a short uses (lane clip-kit; `vertical.mjs` `desktopGeometry`): +`umtool vertical <p> --take <t> --items a --desktop`, or a batch's `desktop` format (`umtool shorts … --formats +vertical,desktop`). X autoplays muted, so the words are on the picture: + +- **the picture full frame**: fitted, never cropped, no header or footer letterboxing it; +- **one thin source line**: "channel · date" on a small plate over the picture, top left of the safe area; +- **the captions** along the foot, at most two lines, each word lit as it is said (the short's captions, laid 16:9); +- **a code** only when asked, in a corner of the safe area (the source at the clip's second by default; [A clip's + QR](#a-clips-qr-its-corner-and-its-link)); a code at a bottom corner narrows the captions on both sides, so they keep + centred and clear of it; one at the top left moves the source line beside it; +- brought to -14 LUFS; over 140 s (X's 2:20) said so in a note, never refused. + +`--landscape` is another thing: the take's whole 16:9 look (its header, its corner code, its deck), to compare. + +| Knob (`render.desktop`) | Values (default) | What it does | +|---|---|---| +| `tag` | `true` · `false` (`true`) | the source line | +| `hook` | `false` · `"title"` · `"section"` · `{text}` (`false`) | a line under the source line, of the cut's own copy | +| `captions` | `{size: "m"\|"l"\|"xl", lines: 1\|2}` (`l`, 2) | the captions' size (3.4 % of the width at `l`) and lines | +| `safe` | `{top, bottom, right, left}` fractions (0.04, 0.08, 0.03, 0.03) | where text keeps inside (X's own controls sit at the foot) | +| `qr` | `false` · `true` · `{corner: br\|bl\|tr\|tl, size: 0.05–0.2, links}` (`false`) | a code; `true` is bottom right at 9 % of the width | +| `loudness` | LUFS -30 … -8 (-14) | the clip brought to it | +| `maxSeconds` | 5 … 600 (140) | over it, a note | + +| | In umtool | From a terminal | +|---|---|---| +| the desktop look | Build, **Look**: **Desktop clips** (Source line, QR, Captions) | `umtool look <p> desktop='{"qr":{"corner":"bl"},"captions":{"size":"xl"}}'` (`desktop=` the defaults) | +| one clip, 16:9 | — | `umtool vertical <p> --take <t> --items a --desktop [--qr on] [--qr-corner bl] [--captions xl]` | +| each clip, every format | the ⌘K form **shorts** | `umtool shorts <p> --take <t> --all --formats vertical,desktop` | + ## A clip's QR: its corner and its link The corner code a cut with no deck draws on each clip (`render.qr`), and the code a short draws (`render.vertical.qr`), @@ -2213,7 +2245,7 @@ byte what it was. | 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`) | | R, recomposed from the master | `umtool vertical <p> --take <t> --reel <r> --reframe` (each item's footage box, card and attachment, the deck's date line; nothing cut again) | | the same items 16:9, to compare | `umtool vertical <p> --take <t> --reel <r> --landscape` | -| each clip of a take in each format, into `shorts-<take>/` (a batch, its record, stable names) | `umtool shorts <p> --take <t> (--items a,b \| --all \| --again) [--formats vertical,landscape] [the vertical flags]` ([cli.md](cli.md#make-promo-clips-a-batch-of-shorts)) | +| each clip of a take in each format, into `shorts-<take>/` (a batch, its record, stable names) | `umtool shorts <p> --take <t> (--items a,b \| --all \| --again) [--formats vertical,desktop,landscape] [the vertical flags]` ([cli.md](cli.md#make-promo-clips-a-batch-of-shorts)) | A clip's `vertical` and `side` are read from the PROJECT's manifest over the take's (they are set after the take was made). The side card is drawn by the post card's own page with the cut's redaction and the authors' pictures; its diff --git a/umtool/lib/cli/verbs.mjs b/umtool/lib/cli/verbs.mjs @@ -322,16 +322,16 @@ export const VERBS = Object.freeze([ form("vertical", "project", "a vertical short (1080x1920) of a take's items", [ 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"), bool("--landscape", "the same items in the take's 16:9 look"), dry(), bool("--intro"), bool("--no-intro"), bool("--no-outro"), - pick("--deck", ["stacked", "bare"]), pick("--qr", ["on", "off"]), pick("--qr-corner", ["tr", "tl"]), + name("--name"), bool("--reframe", "recompose the finished 16:9 master"), bool("--landscape", "the same items in the take's 16:9 look"), bool("--desktop", "the same items 16:9, minimal chrome (render.desktop)"), dry(), bool("--intro"), bool("--no-intro"), bool("--no-outro"), + pick("--deck", ["stacked", "bare"]), pick("--qr", ["on", "off"]), pick("--qr-corner", ["tr", "tl", "br", "bl"], { help: "br and bl: a desktop clip's" }), ], Q), form("shorts", "project", "a batch of shorts: each clip of a take in each format, into shorts-<take>/", [ project(), takeOpt({ required: true, help: "the take" }), opt("--items", { help: "id,id" }), bool("--all", "every clip of the take"), - bool("--again", "the folder's batch.json made again"), opt("--formats", { help: "vertical,landscape (default vertical)" }), + bool("--again", "the folder's batch.json made again"), opt("--formats", { help: "vertical,desktop,landscape (default vertical)" }), 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-vertical", { help: "s (180): over it, a note" }), num("--max-landscape", { help: "s (140): over it, a note" }), pick("--deck", ["stacked", "bare"]), - pick("--qr", ["on", "off"]), pick("--qr-corner", ["tr", "tl"]), + num("--max-vertical", { help: "s (180): over it, a note" }), num("--max-landscape", { help: "s (140): over it, a note" }), num("--max-desktop", { help: "s (140): over it, a note" }), + pick("--deck", ["stacked", "bare"]), pick("--qr", ["on", "off"]), pick("--qr-corner", ["tr", "tl", "br", "bl"], { help: "br and bl: the desktop clips'; a short keeps tr" }), bool("--replace", "set a file there aside and make it again"), dry(), ], Q), diff --git a/umtool/lib/report/look.test.mjs b/umtool/lib/report/look.test.mjs @@ -46,7 +46,7 @@ const read = async (dir) => JSON.parse(await readFile(path.join(dir, MANIFEST_NA test("updateRender: the look's keys only, null removes one, the build's checks refuse a bad value", async () => { const p = await project({ transition: 0.4, crf: 21 }); try { - assert.deepEqual(LOOK_KEYS, ["headerHeight", "footerHeight", "qr", "transition", "transitionStyle", "loudness", "captions", "room", "slide", "blur", "intro", "format", "vertical", "mode", "basic", "tallWindows"]); + assert.deepEqual(LOOK_KEYS, ["headerHeight", "footerHeight", "qr", "transition", "transitionStyle", "loudness", "captions", "room", "slide", "blur", "intro", "format", "vertical", "mode", "basic", "tallWindows", "desktop"]); const token = await manifestToken(p.dir); const r = await updateRender(p.dir, { headerHeight: 0, footerHeight: 0, qr: false, transition: 0.5, transitionStyle: "fadeblack", diff --git a/umtool/lib/report/shortsBatch.mjs b/umtool/lib/report/shortsBatch.mjs @@ -19,9 +19,23 @@ /** The formats a batch builds, each the builder's options and its length note's cap (s; a note, never a refusal). */ export const BATCH_FORMATS = Object.freeze({ - vertical: Object.freeze({ landscape: false, maxSeconds: 180 }), - landscape: Object.freeze({ landscape: true, maxSeconds: 140 }), + vertical: Object.freeze({ landscape: false, desktop: false, maxSeconds: 180 }), + // 16:9 with minimal chrome (slice C, vertical.mjs desktopGeometry): the X clip. + desktop: Object.freeze({ landscape: false, desktop: true, maxSeconds: 140 }), + landscape: Object.freeze({ landscape: true, desktop: false, maxSeconds: 140 }), }); + +/** + * The knobs one format is built with: a short keeps its code at the top (tr, unless tl) -- a bottom corner asked for + * the desktop clips is the short's default corner. Returns `{knobs, note}`. + */ +export function knobsForFormat(knobs, format) { + const qr = knobs?.qr; + if (format === "vertical" && qr && typeof qr === "object" && !["tr", "tl"].includes(qr.corner)) { + return { knobs: { ...knobs, qr: true }, note: `its code at the top right (a short's captions run along its foot; ${qr.corner} is a desktop clip's corner)` }; + } + return { knobs: { ...(knobs ?? {}) }, note: null }; +} export const FORMAT_NAMES = Object.freeze(Object.keys(BATCH_FORMATS)); /** The folder a take's batch lands in. */ diff --git a/umtool/lib/report/shortsCli.mjs b/umtool/lib/report/shortsCli.mjs @@ -15,27 +15,28 @@ import path from "node:path"; import { REPORTS_ROOT, resolveProject } from "../projects/core.mjs"; import { kindMakesTakes } from "../projects/kinds.mjs"; import { deliverableDir } from "./storage.mjs"; -import { BATCH_FILE, BATCH_FORMATS, FORMAT_NAMES, againOf, asideName, assignNames, batchDirName, batchItems, parseFormats, rowAfter, snapshotOf } from "./shortsBatch.mjs"; +import { BATCH_FILE, BATCH_FORMATS, FORMAT_NAMES, againOf, asideName, assignNames, batchDirName, batchItems, knobsForFormat, parseFormats, rowAfter, snapshotOf } from "./shortsBatch.mjs"; import { CliError, buildShort, isRefusal, knobsOfFlags, takeManifestOf } from "./verticalCli.mjs"; export const SHORTS_USAGE = [ - "usage: umtool shorts <project> --take <t> (--items <id>,<id>… | --all | --again) [--formats vertical,landscape]", + "usage: umtool shorts <project> --take <t> (--items <id>,<id>… | --all | --again) [--formats vertical,desktop,landscape]", " [--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-vertical 180] [--max-landscape 140] [--deck stacked|bare]", - " [--qr on|off] [--qr-corner tr|tl] [--replace] [--dry-run] [--json]", + " [--loudness -14] [--max-vertical 180] [--max-desktop 140] [--max-landscape 140]", + " [--deck stacked|bare] [--qr on|off] [--qr-corner tr|tl|br|bl] [--replace] [--dry-run] [--json]", "", "A batch of shorts: each clip (--items, or --all of the take's) in each format -- vertical (1080x1920, the", - "`umtool vertical` layouts and flags) and landscape (the take's own 16:9 look) -- into the project's", + "`umtool vertical` layouts and flags), desktop (1920x1080, minimal chrome: `umtool vertical --desktop`) and", + "landscape (the take's own 16:9 look) -- into the project's", "shorts-<take>/ as <name>.<format>.mp4, each with its record, and batch.json. A clip's name is its own `name`, else", "its title's slug, else its id; one another clip holds already gets -<clip id>; once given, it is kept. A file", "there is not replaced unless --replace (the old one set aside as <name>.<format>.<stamp>.mp4). --again builds the", "folder's batch.json again: its clips, formats and knobs, each clip framed as the record saw it. Over its length", - "(--max-vertical 180 s, --max-landscape 140 s) a short is said so: a note, never a refusal. Each build runs in the", + "(--max-vertical 180 s, --max-desktop and --max-landscape 140 s) a short is said so: a note, never a refusal. Each build runs in the", "heavy slot, as `umtool vertical`'s does; a clip that fails is recorded and the rest go on (exit 1 at the end).", ].join("\n"); -const VALUED = new Set(["--take", "--items", "--formats", "--clip", "--post", "--side", "--hook", "--captions", "--lines", "--loudness", "--max-vertical", "--max-landscape", "--deck", "--qr", "--qr-corner"]); +const VALUED = new Set(["--take", "--items", "--formats", "--clip", "--post", "--side", "--hook", "--captions", "--lines", "--loudness", "--max-vertical", "--max-landscape", "--max-desktop", "--deck", "--qr", "--qr-corner"]); const BOOL = new Set(["--all", "--again", "--replace", "--dry-run", "--json", "--help"]); function parse(args) { @@ -128,6 +129,7 @@ export async function shortsCommand(args, { reportsRoot = REPORTS_ROOT, log = co const caps = { vertical: p.flags["--max-vertical"] !== undefined ? Number(p.flags["--max-vertical"]) : BATCH_FORMATS.vertical.maxSeconds, landscape: p.flags["--max-landscape"] !== undefined ? Number(p.flags["--max-landscape"]) : BATCH_FORMATS.landscape.maxSeconds, + desktop: p.flags["--max-desktop"] !== undefined ? Number(p.flags["--max-desktop"]) : BATCH_FORMATS.desktop.maxSeconds, }; for (const [f, n] of Object.entries(caps)) if (!(Number.isFinite(n) && n >= 5 && n <= 600)) throw new CliError(`--max-${f} is 5 to 600 seconds`); @@ -175,12 +177,13 @@ export async function shortsCommand(args, { reportsRoot = REPORTS_ROOT, log = co await rename(file.replace(/\.mp4$/, ".json"), aside.replace(/\.mp4$/, ".json")).catch(() => {}); } say(`shorts: ${c.id} (${c.name}) ${f} …`); + const fk = knobsForFormat(c.knobs, f); const done = await build( - { project: r.project.id, take, items: [c.id], knobs: { ...c.knobs, maxSeconds: caps[f] }, name: "shorts", out: file, landscape: BATCH_FORMATS[f].landscape, overrides: { [c.id]: c.snapshot } }, + { project: r.project.id, take, items: [c.id], knobs: { ...fk.knobs, maxSeconds: caps[f] }, name: "shorts", out: file, landscape: BATCH_FORMATS[f].landscape, desktop: BATCH_FORMATS[f].desktop, overrides: { [c.id]: c.snapshot } }, { reportsRoot, say }, ); const rec = "record" in done ? done.record : null; - row = rowAfter(record.clips.find((x) => x.id === c.id) ?? null, { ...base, file: c.files[f], seconds: rec?.seconds ?? null, notes: rec?.notes ?? [] }); + row = rowAfter(record.clips.find((x) => x.id === c.id) ?? null, { ...base, file: c.files[f], seconds: rec?.seconds ?? null, notes: [...(fk.note ? [fk.note] : []), ...(rec?.notes ?? [])] }); } catch (e) { if (!(e instanceof Error)) throw e; failed += 1; diff --git a/umtool/lib/report/verticalCli.mjs b/umtool/lib/report/verticalCli.mjs @@ -27,7 +27,7 @@ export const VERTICAL_USAGE = [ "usage: umtool vertical <project> --take <t> (--reel <r> | --beats FILE | --items <id>,<id>…)", " [--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 | --landscape] [--dry-run] [--json]", + " [--loudness -14] [--max 60] [--name N] [--out FILE] [--reframe | --landscape | --desktop] [--dry-run] [--json]", " [--intro | --no-intro] [--no-outro] [--deck stacked|bare] [--qr on|off] [--qr-corner tr|tl]", "", "A vertical short (1080x1920, the take's fps) of a take's items: a reel's beats (promo/<r>-beats.json, as", @@ -43,6 +43,8 @@ export const VERTICAL_USAGE = [ "manifest over the take's. The hook only ever says the cut's own words: a clip's title, its section's title,", "or a line you give it from the cut's copy.", "--landscape builds the same items in the take's own 16:9 look instead (its header, QR and deck), to compare.", + "--desktop builds them 16:9 with minimal chrome (render.desktop): the picture full frame, one thin source line on a", + "plate, the words lit along its foot, a code in a corner only with --qr (--qr-corner br|bl|tr|tl); -14 LUFS.", "--reframe recomposes the take's finished 16:9 master instead (each item's region -- the footage, the post's", "card and attachment, the deck's date line -- laid out 9:16): nothing is cut again, any finished take.", "Writes takes/<t>/out/<slug>.<name>.<layout>.vertical.mp4 (--out: that file) and a .json beside it. The build", @@ -61,7 +63,7 @@ export const VERTICAL_USAGE = [ export class CliError extends Error {} const VALUED = new Set(["--take", "--reel", "--beats", "--items", "--clip", "--post", "--side", "--hook", "--captions", "--lines", "--loudness", "--max", "--name", "--out", "--deck", "--qr", "--qr-corner"]); -const BOOL = new Set(["--reframe", "--landscape", "--dry-run", "--json", "--help", "--intro", "--no-intro", "--no-outro"]); +const BOOL = new Set(["--reframe", "--landscape", "--desktop", "--dry-run", "--json", "--help", "--intro", "--no-intro", "--no-outro"]); export function parse(args) { /** @type {Record<string, string>} */ @@ -107,6 +109,26 @@ export function knobsOfFlags(flags) { const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v); /** + * The desktop knobs (render.desktop's shape) the flags ask for: their captions, hook, loudness, length and code. A + * caption size or corner only a short has is left to the desktop's own default. + */ +export function desktopKnobsOf(knobs = {}) { + /** @type {Record<string, any>} */ + const d = {}; + if (knobs.hook !== undefined) d.hook = knobs.hook; + if (isObj(knobs.captions)) { + const c = {}; + if (["m", "l", "xl"].includes(knobs.captions.size)) c.size = knobs.captions.size; + if (knobs.captions.lines !== undefined) c.lines = knobs.captions.lines; + if (Object.keys(c).length) d.captions = c; + } + if (knobs.loudness !== undefined) d.loudness = knobs.loudness; + if (knobs.maxSeconds !== undefined) d.maxSeconds = knobs.maxSeconds; + if (knobs.qr !== undefined) d.qr = knobs.qr; + return d; +} + +/** * A short's 9:16 end card (outro.mjs) -- the archive's link as a QR and the short's sources, each clip's date, channel * and time from the stacked deck's schedule -- or null: a short that keeps no deck (`--deck bare`, a cut without one) * ends on the outro card it always did. @@ -154,6 +176,7 @@ export function shortOptionsOf(p) { out: p.flags["--out"] ?? null, reframe: p.has("--reframe"), landscape: p.has("--landscape"), + desktop: p.has("--desktop"), dryRun: p.has("--dry-run"), intro: p.has("--intro"), noIntro: p.has("--no-intro"), @@ -211,16 +234,24 @@ export async function buildShort(o, { reportsRoot = REPORTS_ROOT, say = () => {} const sourced = path.join(outDir, "sourced"); const schedule = await readJson(path.join(sourced, "schedule.json")); const knobs = o.knobs ?? {}; - const errors = V.validateVerticalRender({ render: { format: "vertical", vertical: { ...(takeManifest.render?.vertical ?? {}), ...knobs } } }); + // A desktop build reads its own knobs (render.desktop: a corner a short does not have is one it does). + const errors = o.desktop ? [] : V.validateVerticalRender({ render: { format: "vertical", vertical: { ...(takeManifest.render?.vertical ?? {}), ...knobs } } }); if (errors.length) throw new CliError(errors.join("; ")); const name = P.shortName({ reel, name: o.name ?? null }); const reframe = !!o.reframe; // `landscape`: the same items in the take's own 16:9 look (a side post as a panel), for comparison. const landscape = !!o.landscape; - if (landscape && reframe) throw new CliError("--landscape or --reframe, not both"); - const tag = landscape ? "landscape" : P.layoutTag(knobs, { reframe }); + // `desktop` (lane clip-kit): the same clips 16:9 with minimal chrome, by this builder (vertical.mjs desktopGeometry). + const desktop = !!o.desktop; + if ([landscape, reframe, desktop].filter(Boolean).length > 1) throw new CliError("one of --landscape, --desktop and --reframe"); + const dknobs = desktop ? desktopKnobsOf(knobs) : null; + if (desktop) { + const derr = V.validateDesktopRender({ render: { desktop: { ...(takeManifest.render?.desktop ?? {}), ...dknobs } } }); + if (derr.length) throw new CliError(derr.join("; ")); + } + const tag = landscape ? "landscape" : desktop ? "desktop" : P.layoutTag(knobs, { reframe }); const slug = takeManifest.slug ?? r.project.id.split("/").pop(); - const outFile = o.out ? path.resolve(o.out) : path.join(outDir, `${slug}.${name}.${tag}${landscape ? "" : ".vertical"}.mp4`); + const outFile = o.out ? path.resolve(o.out) : path.join(outDir, `${slug}.${name}.${tag}${landscape || desktop ? "" : ".vertical"}.mp4`); const cuts = new Map(); for (const e of takeManifest.timeline ?? []) { if (e?.type !== "clip") continue; @@ -259,6 +290,27 @@ export async function buildShort(o, { reportsRoot = REPORTS_ROOT, say = () => {} await mkdir(path.dirname(outFile), { recursive: true }); await writeFile(outFile, await readFile(path.join(own, `${slug}.mp4`))); made = { seconds: await RF.probeSeconds(outFile), loudness: null }; + } else if (desktop) { + // The desktop build (build-video --desktop): the take's render, the planned items, the desktop knobs over its own. + const renderPath = path.join(dir, `.desktop-${take}-${name}.render.json`); + await writeFile(renderPath, JSON.stringify({ ...takeManifest, render: P.renderForPart(takeManifest.render, plan.timeline), timeline: plan.timeline }, null, 2) + "\n", "utf8"); + const work = `desktop-${name}`; + const built = path.join(outDir, `${slug}.${name}.desktop-build.mp4`); + const sections = V.sectionTitlesOf(takeManifest); + const argv = [ + process.execPath, path.join(PIPELINE_DIR, "build-video.mjs"), renderPath, "--out", outDir, + "--skip-fetch", "--no-chapters", "--desktop", "--desktop-knobs", JSON.stringify(dknobs), "--vertical-work", work, "--vertical-out", built, + "--vertical-sections", JSON.stringify(Object.fromEntries(plan.timeline.map((e) => [e.id, sections.get(e.id.replace(/~\d+$/, "")) ?? null]))), + ]; + say(`vertical --desktop: building ${plan.timeline.length} item(s) 16:9 in the heavy slot …`); + const code = await run(argv, { cwd: path.join(UMTOOL_DIR, ".."), log: say }).finally(() => rm(renderPath, { force: true })); + if (code !== 0) throw new CliError(`the desktop build exited ${code}`); + const RF = await import("umtool-report-to-video/reframe"); + const dk = V.desktopKnobs({ desktop: { ...(takeManifest.render?.desktop ?? {}), ...dknobs } }); + made = await RF.assembleShort({ + pieces: plan.pieces, segmentsDir: path.join(outDir, work, "segments"), built, outFile, schedule: null, + render: { ...takeManifest.render, vertical: { loudness: dk.loudness } }, log: say, + }); } else { // The build's manifest: the take's render, the planned items; beside the project's manifest, so its files resolve. const renderPath = path.join(dir, `.vertical-${take}-${name}.render.json`); @@ -288,7 +340,7 @@ export async function buildShort(o, { reportsRoot = REPORTS_ROOT, say = () => {} } // The intro before and the card after, in one pass, in the heavy slot (the intro is a HyperFrames render, cached). let wrapped = { intro: null, outro: null }; - if ((introSpec || outro) && !landscape) { + if ((introSpec || outro) && !landscape && !desktop) { const { wrapShort } = await import("umtool-report-to-video/reel-intro"); const RF = await import("umtool-report-to-video/reframe"); const slot = await heavySlot(); @@ -306,7 +358,7 @@ export async function buildShort(o, { reportsRoot = REPORTS_ROOT, say = () => {} const record = { version: 1, kind: "vertical-short", project: r.project.id, take, name, layout: tag, reframe, knobs, pieces: plan.pieces, ...(wrapped.intro ? { intro: wrapped.intro } : {}), ...(wrapped.outro ? { outro: wrapped.outro } : {}), seconds: made.seconds, loudness: made.loudness ?? null, - notes: V.verticalNotes({ format: "vertical", vertical: knobs }, made.seconds), out: outFile, + notes: V.verticalNotes({ format: "vertical", vertical: desktop ? { maxSeconds: V.desktopKnobs({ desktop: { ...(takeManifest.render?.desktop ?? {}), ...dknobs } }).maxSeconds } : knobs }, made.seconds), out: outFile, madeAt: new Date().toISOString(), buildSeconds: Math.round((Date.now() - started) / 1000), }; await writeFile(outFile.replace(/\.mp4$/, ".json"), JSON.stringify(record, null, 2) + "\n", "utf8"); @@ -348,7 +400,7 @@ export async function verticalCommand(args, { reportsRoot = REPORTS_ROOT, log = if (json) log(JSON.stringify(record, null, 2)); else { for (const n of record.notes) log(`note: ${n}`); - log(`wrote ${record.out} (${record.seconds.toFixed(1)} s, ${record.layout === "landscape" ? "1920x1080" : "1080x1920"})`); + log(`wrote ${record.out} (${record.seconds.toFixed(1)} s, ${record.layout === "landscape" || record.layout === "desktop" ? "1920x1080" : "1080x1920"})`); } return 0; } catch (e) { diff --git a/umtool/report-to-video/build-video.mjs b/umtool/report-to-video/build-video.mjs @@ -232,10 +232,11 @@ import { clipGeometry, clipVerticalLayout, landscapeSideGeometry, landscapeSideOverlay, sidePostOf, sideSpan, sourceTagText, sectionTitlesOf, validateVerticalRender, verticalAss, verticalClipGraph, verticalHookOf, verticalNotes, verticalOn, verticalPostBox, verticalPostEntry, verticalRender, safeArea, + desktopGeometry, desktopHookOf, desktopKnobs, desktopRender, desktopSafeArea, validateDesktopRender, } from "./vertical.mjs"; import { renderSideCard, sideFitFilter } from "./side-card.mjs"; // THE CLIP KIT (lane clip-kit): a per-clip build's code -- its corner, its link (clip-kit.mjs). -import { clipQrUrl, cornerOverlayXY, cornerQrOf, validateClipKit, verticalQrBox, verticalQrOf } from "./clip-kit.mjs"; +import { clipQrUrl, cornerOverlayXY, cornerQrOf, desktopQrBox, desktopQrOf, validateClipKit, verticalQrBox, verticalQrOf } from "./clip-kit.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"; @@ -1822,8 +1823,12 @@ async function buildClipSegment(entry, meta, render, dirs, opts, chrome, nodes, // 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 && !dirs.vertical.stacked && media.hasVideo) { - const layout = clipVerticalLayout(entry, render); - const geo = clipGeometry(layout, render, width, height); + const isDesktop = dirs.vertical.desktop === true; + const layout = isDesktop ? "desktop" : clipVerticalLayout(entry, render); + // A desktop clip's code first: its corner narrows the captions (vertical.mjs desktopGeometry). + const dqr = isDesktop ? desktopQrOf(entry, render) : null; + const dqrBox = dqr ? desktopQrBox(dqr, { W: width, safe: desktopSafeArea(render, width, height) }) : null; + const geo = isDesktop ? desktopGeometry(render, width, height, { qr: dqrBox }) : clipGeometry(layout, render, width, height); const [sw, sh] = await probeDims(raw); const inputs = cutArgs(raw, segA, segB); let next = 1; @@ -1841,9 +1846,9 @@ async function buildClipSegment(entry, meta, render, dirs, opts, chrome, nodes, } // The short's code (clip-kit.mjs, render.vertical.qr): the source at the second it plays from, at the top of the // safe area -- off unless the cut or the command asks. Its PNG the input after the rest. - const vqr = verticalQrOf(entry, render); + const vqr = isDesktop ? dqr : verticalQrOf(entry, render); const qrPng = vqr ? await qrForEntry(entry, provenance, render, outDir, { links: vqr.links, at: cutRecord.start, webpageUrl: meta.webpageUrl ?? null }) : null; - const qrBox = qrPng ? verticalQrBox(vqr, { W: width, safe: safeArea(render, width, height), tag: geo.tag }) : null; + const qrBox = !qrPng ? null : isDesktop ? dqrBox : verticalQrBox(vqr, { W: width, safe: safeArea(render, width, height), tag: geo.tag }); let qrIdx = null; if (qrBox) { inputs.push("-i", qrPng.png); @@ -1855,11 +1860,15 @@ async function buildClipSegment(entry, meta, render, dirs, opts, chrome, nodes, geo, srcW: sw, srcH: sh, crop: entry.vertical?.crop ?? null, blur: await blurPicture(sw, sh), side, fps: render.fps, W: width, H: height, }); const tag = sourceTagText({ channel: channelName(entry, meta, provenance), date: entry.date ?? uploadDateToIso(meta.uploadDate) }); - // A code at the top of a full layout pushes its hook band down below it. - const capGeo = qrBox && geo.hook?.top !== undefined ? { ...geo, hook: { ...geo.hook, top: Math.max(geo.hook.top, qrBox.y + qrBox.size + Math.round(height * 0.012)) } } : geo; + // A code at the top of a full layout pushes its hook band down below it (a desktop clip's is laid out already). + const capGeo = !isDesktop && qrBox && geo.hook?.top !== undefined ? { ...geo, hook: { ...geo.hook, top: Math.max(geo.hook.top, qrBox.y + qrBox.size + Math.round(height * 0.012)) } } : geo; const cap = await segmentCaptions({ entry, provenance, look: dirs.look, render, outDir, from: cutRecord.start, seconds: segSeconds, bottom: 0, gaps: cutRecord.gaps ?? [], - vertical: { geo: capGeo, tag, hook: verticalHookOf(entry, render, dirs.vertical.sections), side: sideUp }, + vertical: { + geo: capGeo, tag, side: sideUp, + hook: isDesktop ? desktopHookOf(entry, render, dirs.vertical.sections) : verticalHookOf(entry, render, dirs.vertical.sections), + ...(isDesktop ? { knobs: desktopKnobs(render) } : {}), + }, }); cutRecord.vertical = { layout, crop: entry.vertical?.crop ?? null, width, height, ...(cap ? { captions: cap.lines } : {}), ...(qrBox ? { qr: { url: qrPng.url, corner: vqr.corner, ...qrBox } } : {}) }; const qrParts = qrBox @@ -2235,7 +2244,7 @@ async function segmentCaptions({ entry, provenance, look, render, outDir, from, if (vertical) { const file = path.join(outDir, "segments", `${entry.id}.vertical.ass`); const words = src.words.map(rel); - await replaceFile(file, verticalAss({ geo: vertical.geo, render, words, seconds, tag: vertical.tag, hook: vertical.hook, side: vertical.side, W: render.width, H: render.height })); + await replaceFile(file, verticalAss({ geo: vertical.geo, render, words, seconds, tag: vertical.tag, hook: vertical.hook, side: vertical.side, W: render.width, H: render.height, ...(vertical.knobs ? { knobs: vertical.knobs } : {}) })); return { filter: assFilter(file, FONTS_DIR), lines: words.length, wordsFrom: src.wordsFrom }; } const size = render.captions?.size ?? "m"; @@ -6833,7 +6842,7 @@ export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly const basic = basicOn(manifest.render); if (basic) { const asked = [ - [opts.short, "--short"], [opts.vertical || verticalOn(manifest.render), "--vertical (render.format vertical)"], [opts.joinPreview, "--join-preview"], + [opts.short, "--short"], [opts.vertical || verticalOn(manifest.render), "--vertical (render.format vertical)"], [opts.desktop, "--desktop"], [opts.joinPreview, "--join-preview"], [opts.chromeOnly, "--chrome-only"], [opts.chromePreview, "--chrome-preview"], [opts.clipPreview, "--clip-preview"], [opts.railOnly, "--rail-only / --preview"], [opts.thumbnailOnly, "--thumbnail"], [opts.chaptersOnly, "--chapters-only"], ].filter(([on]) => on).map(([, flag]) => flag); @@ -6861,6 +6870,19 @@ export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly const landscape = manifest.timeline.filter((e) => e?.type === "analysis").map((e) => e.id); if (landscape.length) throw new Error(`vertical: ${landscape.join(", ")} ${landscape.length > 1 ? "are analysis items" : "is an analysis item"}, which has no vertical form -- take it out of the vertical cut`); } + // A DESKTOP build (lane clip-kit): a take's clips 16:9 with minimal chrome, by the per-clip builder a short uses. + const desktop = !!opts.desktop; + if (desktop) { + if (opts.short || vertical) throw new Error("--desktop builds the clips 16:9: not with --short or --vertical"); + const knobs = opts.desktopKnobs && typeof opts.desktopKnobs === "object" ? opts.desktopKnobs : null; + const asked = { ...(manifest.render ?? {}), ...(knobs ? { desktop: { ...(manifest.render?.desktop ?? {}), ...knobs } } : {}) }; + const errors = validateDesktopRender({ render: asked }); + if (errors.length) throw new Error(`desktop: ${errors.join("; ")}`); + manifest.render = { ...desktopRender(asked), desktop: asked.desktop ?? {} }; + manifest.timeline = (manifest.timeline ?? []).filter((e) => !isIntro(e)); + const analysis = manifest.timeline.filter((e) => e?.type === "analysis").map((e) => e.id); + if (analysis.length) throw new Error(`desktop: ${analysis.join(", ")} is an analysis item, which a desktop clip build does not draw -- take it out`); + } // A join preview (release 38, join-preview.mjs): the first few joins of // the cut, each clip shortened to a few seconds at the join, in the cut's look. if (opts.joinPreview) { @@ -6959,6 +6981,11 @@ export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly dirs.dir = path.join(outRoot, opts.verticalWork ?? "vertical"); dirs.final = opts.verticalOut ? path.resolve(opts.verticalOut) : path.join(outRoot, `${manifest.slug}.vertical.mp4`); } + // A desktop build likewise (the same flags name its work dir and its file). + if (desktop) { + dirs.dir = path.join(outRoot, opts.verticalWork ?? "desktop"); + dirs.final = opts.verticalOut ? path.resolve(opts.verticalOut) : path.join(outRoot, `${manifest.slug}.desktop.mp4`); + } // A join preview's too: its own work dir and file, the cut's out/ untouched. if (opts.joinPreview) { dirs.dir = path.join(outRoot, "join-preview-work"); @@ -7004,6 +7031,8 @@ export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly // 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), stacked: stackedOn(render) }; + // A desktop clip is drawn by the same per-clip branch, in its own geometry (vertical.mjs desktopGeometry). + if (desktop) dirs.vertical = { on: true, desktop: true, sections: opts.verticalSections ? new Map(Object.entries(opts.verticalSections)) : sectionTitlesOf(whole), stacked: false }; // 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 @@ -8054,6 +8083,7 @@ async function main() { " [--only <id>] [--fetch-only <id>] [--short <id>] (a vertical short of one clip: <project>/shorts/<id>.mp4)\n" + " [--join-preview [--join-from <id>]] (the first few joins, a few seconds each side: out/join-preview.mp4)\n" + " [--vertical [--vertical-knobs <json>] [--vertical-work <dir>] [--vertical-out <file>]] (the cut 9:16: out/<slug>.vertical.mp4)\n" + + " [--desktop [--desktop-knobs <json>] [--vertical-work <dir>] [--vertical-out <file>]] (the clips 16:9, minimal chrome: out/<slug>.desktop.mp4)\n" + " [--pad <s>] [--pad-before <s>] [--pad-after <s>] [--skip-fetch] [--no-network] [--audio-fallback] [--no-xfade] [--no-chapters] [--chapters-only]\n" + " [--progress ndjson] [--continue-on-error] [--no-reuse] [--no-segment-cache]\n" + " [--no-rail] [--rail-only] [--preview <start> <dur>]\n" + @@ -8115,6 +8145,11 @@ async function main() { verticalWork: flag("--vertical-work") ?? null, verticalOut: flag("--vertical-out") ?? null, verticalSections: flag("--vertical-sections") ? JSON.parse(flag("--vertical-sections")) : null, + // A DESKTOP build of the cut's clips (lane clip-kit; vertical.mjs desktopRender): 1920x1080, the picture full frame, + // a thin source line, words lit along its foot -- its knobs over the cut's render.desktop; the vertical's work + // dir and file flags name its own. + desktop: argv.includes("--desktop"), + desktopKnobs: flag("--desktop-knobs") ? JSON.parse(flag("--desktop-knobs")) : null, }; try { Object.assign(opts, chromeFlags(argv)); diff --git a/umtool/report-to-video/clip-kit-render.test.mjs b/umtool/report-to-video/clip-kit-render.test.mjs @@ -0,0 +1,131 @@ +// The clip kit, rendered for real (lane clip-kit): a desktop clip (slice C) and a short's code (slice B) on a +// synthetic window -- the frame's size, the code where it is said to stand, the source line's plate -- and, with +// none of the kit's keys, a short built exactly as before. +// +// Run with: pnpm test:scripts +import assert from "node:assert/strict"; +import { spawnSync } from "node:child_process"; +import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs"; +import { readFile, rm, writeFile } from "node:fs/promises"; +import os from "node:os"; +import path from "node:path"; +import test from "node:test"; + +// The corpus the build reads metadata and cues from: set before build-video (cues.mjs) is loaded. +const CORPUS = mkdtempSync(path.join(os.tmpdir(), "rtv-kit-corpus-")); +process.env.CHANNELS_DIR = CORPUS; + +const { buildVideo, setProgressMode } = await import("./build-video.mjs"); +const { MONO_BOLD_FONT_FILE, MONO_FONT_FILE } = await import("./brand.mjs"); +const { desktopQrBox, verticalQrBox } = await import("./clip-kit.mjs"); +const { clipGeometry, desktopSafeArea, safeArea } = await import("./vertical.mjs"); + +test.after(() => rm(CORPUS, { recursive: true, force: true })); + +const have = ["ffmpeg", "ffprobe", "qrencode"].every((b) => spawnSync(b, b === "qrencode" ? ["--version"] : ["-version"]).status === 0); +const FPS = 30; +const PALETTE = { bg: "#000000", fg: "#ffffff", muted: "#888888", accent: "#c8752a", amber: "#ffc860" }; +const RENDER = { + width: 1920, height: 1080, fps: FPS, audioRate: 48000, audioChannels: 2, preset: "ultrafast", transition: 0, + headerHeight: 0, footerHeight: 0, palette: PALETTE, fontRegular: MONO_FONT_FILE, fontBold: MONO_BOLD_FONT_FILE, + fetchPad: 0, snapWindow: 0.05, silenceMinDur: 0.1, +}; +const CHANNEL = "synth"; +const VIDEO = "vid-0123456789"; +{ + const dir = path.join(CORPUS, CHANNEL, "data", VIDEO); + mkdirSync(dir, { recursive: true }); + writeFileSync(path.join(CORPUS, CHANNEL, "config.json"), JSON.stringify({ name: "Synth" })); + writeFileSync(path.join(dir, "transcript.cues.json"), JSON.stringify({ id: VIDEO, title: "Synthetic", duration: 6, uploadDate: "20240102", cues: [{ start: 0.2, end: 5.8, text: "a line said over the clip" }] })); + writeFileSync(path.join(dir, "metadata.info.json"), JSON.stringify({ id: VIDEO, title: "Synthetic", duration: 6, webpage_url: `https://kick.com/synth/videos/${VIDEO}` })); +} + +/** A project: one clip, 1–4 s of a 6 s grey 1920x1080 window with a tone. */ +async function project({ clip = {}, render = {} } = {}) { + const root = mkdtempSync(path.join(os.tmpdir(), "rtv-kit-")); + mkdirSync(path.join(root, "out", "clips-raw"), { recursive: true }); + const raw = path.join(root, "out", "clips-raw", `${VIDEO}_0.00-6.00.mp4`); + const r = spawnSync("ffmpeg", [ + "-v", "error", "-y", "-f", "lavfi", "-i", `color=c=gray:s=1920x1080:r=${FPS}:d=6`, + "-f", "lavfi", "-i", "sine=frequency=440:sample_rate=48000:duration=6", + "-map", "0:v", "-map", "1:a", "-c:v", "libx264", "-preset", "ultrafast", "-c:a", "aac", "-shortest", raw, + ]); + assert.equal(r.status, 0, String(r.stderr)); + const manifestPath = path.join(root, "video.manifest.json"); + await writeFile(manifestPath, JSON.stringify({ + slug: "kit", title: "Kit", + provenance: { channelSlug: CHANNEL, channelsDir: CORPUS, siteOrigin: "" }, + render: { ...RENDER, ...render }, + timeline: [{ type: "clip", id: "c1", channel: CHANNEL, video: VIDEO, start: 1, end: 4, cite: 1, quote: "q", citeUrl: `https://kick.com/synth/videos/${VIDEO}`, ...clip }], + })); + return { root, manifestPath }; +} + +const quiet = () => setProgressMode(() => {}); +/** The picture's size. */ +function dims(file) { + const r = spawnSync("ffprobe", ["-v", "error", "-select_streams", "v:0", "-show_entries", "stream=width,height", "-of", "csv=p=0", file]); + return String(r.stdout).trim(); +} +/** The luma's min and max over a box of a frame `t` s in: a code is black and white, the grey ground is neither. */ +function range(file, box, t = 1) { + const r = spawnSync("ffmpeg", ["-v", "error", "-ss", String(t), "-i", file, "-frames:v", "1", "-vf", `crop=${box.w}:${box.h}:${box.x}:${box.y},signalstats,metadata=print:file=-`, "-f", "null", "-"], { maxBuffer: 1 << 24 }); + const out = String(r.stdout); + const get = (k) => Number((new RegExp(`lavfi\\.signalstats\\.${k}=([0-9.]+)`).exec(out) ?? [])[1]); + return { min: get("YMIN"), max: get("YMAX") }; +} +const md5 = (f) => spawnSync("md5sum", [f]).stdout.toString().split(" ")[0]; + +test("a desktop clip: 1920x1080, the picture full frame, the code in its corner, the source line on its plate", { skip: !have && "needs ffmpeg and qrencode" }, async () => { + quiet(); + const p = await project(); + try { + const out = path.join(p.root, "out", "kit.desktop.mp4"); + await buildVideo({ manifestPath: p.manifestPath, opts: { noNetwork: true, desktop: true, desktopKnobs: { qr: { corner: "br" } }, verticalOut: out } }); + assert.equal(dims(out), "1920,1080"); + const seg = path.join(p.root, "out", "desktop", "segments", "c1.mp4"); + const rec = JSON.parse(await readFile(seg.replace(/\.mp4$/, ".cut.json"), "utf8")); + assert.equal(rec.vertical.layout, "desktop"); + assert.equal(rec.vertical.qr.url, `https://kick.com/synth/videos/${VIDEO}?t=1`, "the source at the clip's second"); + const box = desktopQrBox({ corner: "br", size: 0.09 }, { W: 1920, safe: desktopSafeArea({}, 1920, 1080) }); + assert.deepEqual([rec.vertical.qr.x, rec.vertical.qr.y, rec.vertical.qr.size], [box.x, box.y, box.size]); + const inQr = range(seg, { x: box.x + 8, y: box.y + 8, w: box.size - 16, h: box.size - 16 }); + assert.ok(inQr.min < 40 && inQr.max > 215, `the code is drawn there (${JSON.stringify(inQr)})`); + // The opposite corner: the grey picture alone (no letterbox, nothing drawn). + const bare = range(seg, { x: 60, y: 1080 - box.size - 90, w: box.size, h: box.size }); + assert.ok(bare.min > 100 && bare.max < 150, `the picture full frame there (${JSON.stringify(bare)})`); + // The source line: its plate darkens the top left of the safe area. + const s = desktopSafeArea({}, 1920, 1080); + const plate = range(seg, { x: s.x0 + 4, y: s.y0 + 4, w: 40, h: 16 }); + assert.ok(plate.min < 110, `the source line's plate (${JSON.stringify(plate)})`); + } finally { + await rm(p.root, { recursive: true, force: true }); + } +}); + +test("a short's code: at the top right of the safe area; none unless asked, the short as it was", { skip: !have && "needs ffmpeg and qrencode" }, async () => { + quiet(); + const ps = [await project(), await project({ render: { vertical: { qr: false } } }), await project()]; + try { + const outs = ps.map((p) => path.join(p.root, "out", "kit.vertical.mp4")); + await buildVideo({ manifestPath: ps[0].manifestPath, opts: { noNetwork: true, vertical: true, verticalOut: outs[0] } }); + await buildVideo({ manifestPath: ps[1].manifestPath, opts: { noNetwork: true, vertical: true, verticalOut: outs[1] } }); + await buildVideo({ manifestPath: ps[2].manifestPath, opts: { noNetwork: true, vertical: true, verticalKnobs: { qr: true }, verticalOut: outs[2] } }); + const segs = ps.map((p) => path.join(p.root, "out", "vertical", "segments", "c1.mp4")); + // No code asked (absent, or false): the same segment, its record naming none. + assert.equal(md5(segs[0]), md5(segs[1])); + const rec0 = JSON.parse(await readFile(segs[0].replace(/\.mp4$/, ".cut.json"), "utf8")); + assert.equal(rec0.vertical.qr, undefined); + assert.equal(dims(outs[2]), "1080,1920"); + const rec = JSON.parse(await readFile(segs[2].replace(/\.mp4$/, ".cut.json"), "utf8")); + const geo = clipGeometry("full", { format: "vertical" }, 1080, 1920); + const box = verticalQrBox({ corner: "tr", size: 0.16 }, { W: 1080, safe: safeArea({ format: "vertical" }, 1080, 1920), tag: geo.tag }); + assert.deepEqual([rec.vertical.qr.x, rec.vertical.qr.y, rec.vertical.qr.corner], [box.x, box.y, "tr"]); + const inQr = range(segs[2], { x: box.x + 8, y: box.y + 8, w: box.size - 16, h: box.size - 16 }); + assert.ok(inQr.min < 40 && inQr.max > 215, `the code is drawn there (${JSON.stringify(inQr)})`); + const without = range(segs[0], { x: box.x + 8, y: box.y + 8, w: box.size - 16, h: box.size - 16 }); + assert.ok(without.max < 200, `no code without one asked (${JSON.stringify(without)})`); + } finally { + for (const p of ps) await rm(p.root, { recursive: true, force: true }); + } +}); diff --git a/umtool/report-to-video/clip-kit.mjs b/umtool/report-to-video/clip-kit.mjs @@ -21,7 +21,7 @@ // PURE: no fs, no ffmpeg. import { watchUrlAt } from "yt-dlp-transcript-common/lib/clips/assist.mjs"; import { VOD_RETENTION_DAYS, seekPlatformOfUrl } from "yt-dlp-transcript-common/lib/platformSeek.mjs"; -import { QR_LINKS, VERTICAL_QR_CORNERS, VERTICAL_QR_KEYS, VERTICAL_QR_SIZE, verticalQrErrors } from "yt-dlp-transcript-common/lib/report/vertical.mjs"; +import { DESKTOP_QR_CORNERS, DESKTOP_QR_SIZE, QR_LINKS, VERTICAL_QR_CORNERS, VERTICAL_QR_KEYS, VERTICAL_QR_SIZE, desktopKnobs, verticalQrErrors } from "yt-dlp-transcript-common/lib/report/vertical.mjs"; import { archiveMomentUrl } from "./site-links.mjs"; const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v); @@ -118,6 +118,24 @@ export function verticalQrOf(entry, render) { return { corner, size: cut.size ?? VERTICAL_QR_SIZE.default, links: own.links ?? cut.links ?? "moment" }; } +/** A desktop clip's code (render.desktop.qr): null when off (the default), else `{corner, size, links}`; a clip's `qr` speaks over it. */ +export function desktopQrOf(entry, render) { + const v = desktopKnobs(render).qr; + if (!v || entry?.qr === false) return null; + const cut = isObj(v) ? v : {}; + const own = isObj(entry?.qr) ? entry.qr : {}; + const corner = DESKTOP_QR_CORNERS.includes(own.corner) ? own.corner : cut.corner ?? "br"; + return { corner, size: cut.size ?? DESKTOP_QR_SIZE.default, links: own.links ?? cut.links ?? "moment" }; +} + +/** Where a desktop clip's code stands, px: in its corner of the safe area (`safe` vertical.mjs desktopSafeArea's). */ +export function desktopQrBox(qr, { W, safe }) { + const size = Math.max(2, 2 * Math.round((W * qr.size) / 2)); + const x = qr.corner === "bl" || qr.corner === "tl" ? safe.x0 : safe.x1 - size; + const y = qr.corner === "tl" || qr.corner === "tr" ? safe.y0 : safe.y1 - size; + return { x, y, size }; +} + /** * The link a clip's code carries. `links` "cite" is the corner code's link as it always was (the citeUrl, else the * clip's moment on the archive); "moment" the source at `at` (momentLinkOf), falling back to that; "channel" the diff --git a/umtool/report-to-video/clip-kit.test.mjs b/umtool/report-to-video/clip-kit.test.mjs @@ -112,3 +112,67 @@ test("a moment code to a Kick or Twitch VOD is a NOTE naming the expiry; a chann const short = lintManifest({ ...base, render: { width: 1080, height: 1920, format: "vertical", qr: false, vertical: { qr: true } }, timeline: [clip({ citeUrl: KICK })] }, { validators: false }); assert.ok(short.warnings.some((w) => /timeline w01 \(its QR\): its QR links a Kick VOD/.test(w)), short.warnings.join("\n")); }); + +// ---- slice C: the desktop clip -------------------------------------------------------------------------------------- +import { desktopGeometry, desktopRender, desktopSafeArea, verticalAss } from "./vertical.mjs"; +import { DESKTOP_DEFAULTS, desktopKnobs, validateDesktopRender } from "yt-dlp-transcript-common/lib/report/vertical.mjs"; +import { desktopQrBox, desktopQrOf } from "./clip-kit.mjs"; +import { knobsForFormat } from "../lib/report/shortsBatch.mjs"; +import { desktopKnobsOf } from "../lib/report/verticalCli.mjs"; + +test("desktop: the knobs' defaults are minimal chrome; the rules refuse by name", () => { + assert.deepEqual(desktopKnobs({}), { ...DESKTOP_DEFAULTS, captions: { ...DESKTOP_DEFAULTS.captions }, safe: { ...DESKTOP_DEFAULTS.safe } }); + assert.equal(desktopKnobs({}).qr, false); + assert.equal(desktopKnobs({}).maxSeconds, 140, "X's 2:20"); + assert.deepEqual(validateDesktopRender({ render: { desktop: { qr: { corner: "bl", size: 0.1, links: "moment" }, captions: { size: "m", lines: 1 }, hook: "title" } } }), []); + assert.match(validateDesktopRender({ render: { desktop: { qr: { corner: "middle" } } } }).join(), /render\.desktop\.qr\.corner is one of br, bl, tr, tl/); + assert.match(validateDesktopRender({ render: { desktop: { wide: true } } }).join(), /render\.desktop\.wide is not a desktop knob/); + assert.match(validateDesktopRender({ render: { desktop: { safe: { top: 0.5 } } } }).join(), /safe\.top must be a fraction/); + assert.deepEqual(validateDesktopRender({ render: {} }), []); + // The render: 1920x1080, nothing over the picture but what the clip draws, the desktop's loudness; marked a desktop build. + const r = desktopRender({ width: 1280, height: 720, headerHeight: 56, qr: { corner: "tl" }, chrome: { deck: {} }, intro: "boot", desktop: { loudness: -16 } }); + assert.deepEqual([r.width, r.height, r.headerHeight, r.footerHeight, r.qr, r.chrome, r.intro, r.desktopBuild], [1920, 1080, 0, 0, false, undefined, undefined, true]); + assert.deepEqual(r.loudness, { target: -16 }); +}); + +test("desktop: every text inside the safe area; a bottom code narrows the captions both sides; a top-left code moves the source line", () => { + const W = 1920, H = 1080; + const a = desktopSafeArea({}, W, H); + const g = desktopGeometry({}, W, H); + assert.deepEqual(g.video, { x: 0, y: 0, w: W, h: H, aspect: W / H, fill: "fit" }, "the picture full frame, never cropped"); + assert.ok(g.tag.x >= a.x0 && g.tag.y >= a.y0); + assert.equal(g.captions.marginV, H - a.y1); + assert.equal(g.captions.marginL, a.x0); + const qr = desktopQrBox({ corner: "br", size: 0.09 }, { W, safe: a }); + assert.ok(qr.x + qr.size <= a.x1 && qr.y + qr.size <= a.y1 && qr.x >= a.x0); + const gq = desktopGeometry({}, W, H, { qr }); + assert.equal(gq.captions.marginL - g.captions.marginL, gq.captions.marginR - g.captions.marginR, "centred"); + assert.ok(W - gq.captions.marginR <= qr.x, "the captions end before the code"); + const tl = desktopQrBox({ corner: "tl", size: 0.09 }, { W, safe: a }); + assert.ok(desktopGeometry({}, W, H, { qr: tl }).tag.x >= tl.x + tl.size, "the source line beside the code"); + // A clip's own corner over the cut's; the moment by default; off unless asked. + assert.equal(desktopQrOf({ type: "clip" }, {}), null); + assert.deepEqual(desktopQrOf({ type: "clip", qr: { corner: "tl" } }, { desktop: { qr: true } }), { corner: "tl", size: 0.09, links: "moment" }); + assert.equal(desktopQrOf({ type: "clip", qr: false }, { desktop: { qr: true } }), null); +}); + +test("desktop: the ASS reads the desktop's lines and tag; the vertical's are unchanged without knobs", () => { + const words = [{ text: "one", start: 0.1, end: 0.4 }, { text: "two", start: 0.5, end: 0.8 }]; + const g = desktopGeometry({}, 1920, 1080); + const doc = verticalAss({ geo: g, render: {}, words, seconds: 2, tag: "Synth · 2 Jan 2024", W: 1920, H: 1080, knobs: desktopKnobs({ desktop: { tag: false } }) }); + assert.match(doc, /PlayResX: 1920\nPlayResY: 1080/); + assert.ok(!/,tag,,0,0,0,,Synth/.test(doc), "the desktop's tag: false is read"); + assert.match(verticalAss({ geo: g, render: {}, words, seconds: 2, tag: "Synth", W: 1920, H: 1080, knobs: desktopKnobs({}) }), /,tag,,0,0,0,,Synth/); + // Without knobs: the vertical's, exactly the document it always wrote. + const vg = clipGeometry("full", {}, 1080, 1920); + assert.equal(verticalAss({ geo: vg, render: {}, words, seconds: 2, tag: "Synth" }), verticalAss({ geo: vg, render: {}, words, seconds: 2, tag: "Synth", knobs: null })); +}); + +test("desktop: the flags' knobs; a batch keeps a short's code at the top", () => { + assert.deepEqual(desktopKnobsOf({ clip: "framed", hook: "title", captions: { size: "xl", lines: 1 }, loudness: -16, maxSeconds: 140, qr: { corner: "bl" } }), { hook: "title", captions: { size: "xl", lines: 1 }, loudness: -16, maxSeconds: 140, qr: { corner: "bl" } }); + assert.deepEqual(knobsForFormat({ qr: { corner: "bl" } }, "desktop"), { knobs: { qr: { corner: "bl" } }, note: null }); + const v = knobsForFormat({ qr: { corner: "bl" }, clip: "framed" }, "vertical"); + assert.deepEqual(v.knobs, { qr: true, clip: "framed" }); + assert.match(v.note, /top right/); + assert.deepEqual(knobsForFormat({ qr: { corner: "tl" } }, "vertical").knobs, { qr: { corner: "tl" } }); +}); diff --git a/umtool/report-to-video/lint.mjs b/umtool/report-to-video/lint.mjs @@ -123,7 +123,7 @@ import { ENLARGE_WARN, STACKED_QR_SHARE, STACKED_QR_SMALL_SHARE, clipTwoCrop, st import { roomWindowWarnings } from "./room.mjs"; import { qrUrlFor } from "./render-cards.mjs"; import { archiveMomentUrl } from "./site-links.mjs"; -import { clipQrUrl, cornerQrOf, expiringLinkNote, validateClipKit, verticalQrOf } from "./clip-kit.mjs"; +import { clipQrUrl, cornerQrOf, desktopQrOf, expiringLinkNote, validateClipKit, verticalQrOf } from "./clip-kit.mjs"; import { cardNarrationSeconds, hasNarration, narrationsOf, validateNarration } from "./narration.mjs"; import { validatePodcast } from "./build-podcast.mjs"; import { draftsReviewFromNarration, draftsReviewProblems, readDraftsReview } from "./drafts-review.mjs"; @@ -229,6 +229,15 @@ export function qrsOf(manifest, { only = null, metaOf = null } = {}) { if (url) out.push({ where: `timeline ${e.id} (its QR)`, id: e.id, source: "entry", url, links: vq.links, px: Math.round((Number(render.width) || 1080) * vq.size) }); } } + // A desktop clip's code (vertical.mjs desktopRender; render.desktop.qr), in its corner. + if (render.desktopBuild === true) { + for (const e of timeline) { + const dq = e.type === "clip" ? desktopQrOf(e, render) : null; + if (!dq || (e.src != null && !e.citeUrl)) continue; + const url = clipQrUrl(e, provenance, { links: dq.links, at: e.cutStart ?? e.start, channelUrl: render.promo?.url ?? null, webpageUrl: metaOf?.(e)?.webpageUrl ?? null }); + if (url) out.push({ where: `timeline ${e.id} (its QR)`, id: e.id, source: "entry", url, links: dq.links, px: Math.round((Number(render.width) || 1920) * dq.size) }); + } + } if (render.qr === false) return out; if (render.rail) { // The rail's foot: a tile per entry (a card's is the sweep's link), the diff --git a/umtool/report-to-video/vertical.mjs b/umtool/report-to-video/vertical.mjs @@ -22,7 +22,7 @@ // command (lib/report/verticalCli.mjs) call it. import { - VERTICAL_HEIGHT, VERTICAL_WIDTH, clipLayoutOf, sidePostOf, sideSpan, stackedDeckWanted, verticalKnobs, verticalOn, + DESKTOP_HEIGHT, DESKTOP_WIDTH, VERTICAL_HEIGHT, VERTICAL_WIDTH, clipLayoutOf, desktopKnobs, sidePostOf, sideSpan, stackedDeckWanted, verticalKnobs, verticalOn, } from "yt-dlp-transcript-common/lib/report/vertical.mjs"; import { assColour, assTime, captionText, cropPixels } from "./look.mjs"; @@ -32,6 +32,7 @@ export { VERTICAL_DEFAULTS, VERTICAL_HEIGHT, VERTICAL_HOOKS, VERTICAL_KEYS, VERTICAL_POST_LAYOUTS, VERTICAL_SIDE_LAYOUTS, VERTICAL_WIDTH, clipLayoutOf, sideErrors, sidePostOf, sideSpan, validateClipSides, validateVerticalFormat, validateVerticalRender, verticalKnobs, verticalOn, + DESKTOP_CAPTION_SIZES, DESKTOP_DEFAULTS, DESKTOP_HEIGHT, DESKTOP_KEYS, DESKTOP_QR_CORNERS, DESKTOP_QR_SIZE, DESKTOP_WIDTH, desktopKnobs, validateDesktopRender, } from "yt-dlp-transcript-common/lib/report/vertical.mjs"; const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v); @@ -77,6 +78,65 @@ export function verticalRender(render = {}) { }; } +/** + * The render a DESKTOP clip is built with (lane clip-kit): 1920x1080 at the cut's fps, the picture full frame -- no + * header, footer, corner QR, rail, deck, montage or intro -- the cut's palette, fonts and caption labels kept, its + * loudness the desktop knobs'. `render.desktop` stays: the geometry reads it. + */ +export function desktopRender(render = {}) { + const { chrome: _c, rail: _r, chromeEngine: _e, brand: _b, montage: _m, intro: _i, room: _ro, format: _f, ...rest } = render; + const k = desktopKnobs(render); + return { + ...rest, + width: DESKTOP_WIDTH, + height: DESKTOP_HEIGHT, + headerHeight: 0, + footerHeight: 0, + qr: false, + captions: { style: "speakers", ...(isObj(render.captions?.labels) ? { labels: render.captions.labels } : {}), size: "l" }, + loudness: { target: k.loudness }, + // What says this render IS a desktop build (the lint measures its code): `render.desktop` alone is a look key a + // landscape cut may carry for its batch. + desktopBuild: true, + }; +} + +/** The desktop clip's safe area in px (render.desktop.safe): every text keeps inside it. */ +export function desktopSafeArea(render, W = DESKTOP_WIDTH, H = DESKTOP_HEIGHT) { + const s = desktopKnobs(render).safe; + return { x0: Math.round(W * s.left), x1: Math.round(W * (1 - s.right)), y0: Math.round(H * s.top), y1: Math.round(H * (1 - s.bottom)) }; +} + +/** The desktop caption face's size (px) for its caption size. */ +export const desktopCaptionSize = (render, W = DESKTOP_WIDTH) => Math.round(W * ({ m: 0.028, l: 0.034, xl: 0.04 }[desktopKnobs(render).captions.size] ?? 0.034)); + +/** + * A desktop clip's geometry: the picture full frame (fitted, never cropped), the source line top-left on a plate, + * the hook under it, the captions along the foot of the safe area; `qr` (clip-kit.mjs desktopQrBox) at a bottom + * corner narrows the captions on both sides so they keep centred and clear of it. + */ +export function desktopGeometry(render, W = DESKTOP_WIDTH, H = DESKTOP_HEIGHT, { qr = null } = {}) { + const a = desktopSafeArea(render, W, H); + const size = desktopCaptionSize(render, W); + // A code at the top left: the source line stands to its right. + const topLeftQr = qr && qr.x <= a.x0 + 1 && qr.y <= a.y0 + 1; + const tag = { x: topLeftQr ? qr.x + qr.size + Math.round(W * 0.012) : a.x0, y: a.y0, size: Math.round(W * 0.016) }; + const bottomQr = qr && qr.y + qr.size > a.y1 - Math.round(H * 0.25); + const inset = bottomQr ? qr.size + Math.round(W * 0.015) : 0; + return { + layout: "desktop", size, tag, safe: a, + video: { x: 0, y: 0, w: W, h: H, aspect: W / H, fill: "fit" }, + background: false, + hook: { top: tag.y + Math.round(tag.size * 2.2), size: Math.round(W * 0.026) }, + captions: { align: 2, marginL: a.x0 + inset, marginR: W - a.x1 + inset, marginV: H - a.y1 }, + }; +} + +/** The desktop clip's hook (render.desktop.hook, from the cut's own copy only), or null. */ +export function desktopHookOf(entry, render, sections = null) { + return hookText(desktopKnobs(render).hook, { entry, sectionTitle: sections?.get?.(entry?.id) ?? null }); +} + /** The safe area in px: text keeps inside x0..x1, y0..y1. */ export function safeArea(render, W = VERTICAL_WIDTH, H = VERTICAL_HEIGHT) { const s = verticalKnobs(render).safe; @@ -312,8 +372,9 @@ export function hookText(hook, { entry = null, sectionTitle = null } = {}) { * citation. `words` in segment seconds; `hook` the line (verticalHookOf), `side` the side post's span (captions * move above an overlay card while it is up). */ -export function verticalAss({ geo, render, words = [], seconds, tag = null, hook = null, side = null, W = VERTICAL_WIDTH, H = VERTICAL_HEIGHT, font = VERTICAL_FONT }) { - const k = verticalKnobs(render); +export function verticalAss({ geo, render, words = [], seconds, tag = null, hook = null, side = null, W = VERTICAL_WIDTH, H = VERTICAL_HEIGHT, font = VERTICAL_FONT, knobs = null }) { + // `knobs` (a desktop clip's: desktopKnobs) speak over the vertical ones for its lines and its tag. + const k = knobs ?? verticalKnobs(render); const quote = geo.layout === "quote"; const size = geo.size; const width = W - geo.captions.marginL - geo.captions.marginR;