commit 78a5b57db6a9a47e48738f91337cb579c6618460
parent 86f940c37ac697b071412b674618be214ba04f47
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Thu, 5 Nov 2026 18:14:53 -0500
umtool: Shorts get the brand intro 9:16 and the reel's outro card; the Trailer page sets the outro
`umtool vertical … --intro` opens a short on the brand intro re-laid for
1080x1920 -- the same style, mark, sound, timing and site swap, the drawing
centred in the Shorts safe area (between the top 8 % and the bottom 20 %,
inside 12 % either side; chrome-intro.mjs PORTRAIT_SAFE_CENTRE/WIDTH). A
reel whose `intro` is on does the same (its own intro when it has one;
--no-intro), and a reel whose `outro` is on ends on its card laid out 9:16
inside the safe area (--no-outro). Both are joined in one pass after the
short is made (reel-intro.mjs wrapShort), in the heavy slot, and named in
the short's record. A landscape intro's page is unchanged byte for byte
(its cached renders stay).
The Trailer page has "end on the outro card" beside "open on the brand
intro", with the title, call to action, image and seconds fields; the
route's settings op takes `outro`. e2e: the outro on/off case.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
10 files changed, 306 insertions(+), 10 deletions(-)
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md
@@ -1,7 +1,7 @@
# Changelog
## [Unreleased]
-- **umtool: a reel can end on an outro card, and open on an intro its master does not have.** A trailer stopped on its last beat, and a reel with "open on the brand intro" was refused when the take had been rendered without one (the Mr. Obvious X trailer). `umtool trailer-beats <p> --reel <r> outro '{"title":"…","image":"promo/thumbnail.jpg"}'` (`on`, `off`, `none`) ends the reel on a card: the full video's title large (default the reel's title, else the project's), "Full video on the channel" under it (`text`), the site's name small in its accent, over the image blurred and darkened (or the dark ground), 3.5 s (`seconds`) with a 0.5 s fade in from the last beat while its sound fades out, then held to the end; `ls` says `· outro 3.5 s` and the length against the limit counts it. With `intro on` and no intro in the master, the take's `render.intro` (else the dark boot with the mark on the chime) is rendered for the reel; `intro '{"style":"boot-dark","mark":"chime","site":"anilyzer"}'` gives a reel an intro of its own. `umtool trailer --reel` cuts both in; a reel with neither is cut exactly as before.
+- **umtool: a reel can end on an outro card, and open on an intro its master does not have.** A trailer stopped on its last beat, and a reel with "open on the brand intro" was refused when the take had been rendered without one (the Mr. Obvious X trailer). `umtool trailer-beats <p> --reel <r> outro '{"title":"…","image":"promo/thumbnail.jpg"}'` (`on`, `off`, `none`) ends the reel on a card: the full video's title large (default the reel's title, else the project's), "Full video on the channel" under it (`text`), the site's name small in its accent, over the image blurred and darkened (or the dark ground), 3.5 s (`seconds`) with a 0.5 s fade in from the last beat while its sound fades out, then held to the end; `ls` says `· outro 3.5 s` and the length against the limit counts it. With `intro on` and no intro in the master, the take's `render.intro` (else the dark boot with the mark on the chime) is rendered for the reel; `intro '{"style":"boot-dark","mark":"chime","site":"anilyzer"}'` gives a reel an intro of its own. `umtool trailer --reel` cuts both in; a reel with neither is cut exactly as before. The Trailer page has **end on the outro card** and its fields beside **open on the brand intro**. Shorts get both too: `umtool vertical … --intro` opens a short on the brand intro re-laid 9:16 (the drawing centred between the Shorts overlays: the top 8 %, the bottom 20 %, 12 % either side), a reel's `intro` on does the same, and a reel's outro card is laid out 9:16 inside that safe area (`--no-intro`, `--no-outro`). A landscape intro is unchanged.
- **umtool: the background no longer changes shade between post items.** In a render, the page behind a post's card brightened at the cut from a post with a JPEG picture to a plain text post (the Mr. Obvious cut, at 37:00). ffmpeg had encoded the item with the picture in full range, every other item in limited range, and a player reads one range for the whole video. Every post item and combo badge is now encoded in limited range, so the page is the palette's background in every item; the items built full range before are rebuilt on the next render, and nothing else is.
- **umtool: a report video can end on a video of the project, full frame, with its own sound.** A meme the subject posted (the Puss in Boots clip of the Mr. Obvious cut) could not be played as itself: `image` is a still and a clip is a corpus window inside the deck. A `video` timeline entry plays a project file's span (`from`, `to`; absent: the file's end) as the whole frame (`fit: contain`, pillarboxed on black, or `cover`), with NOTHING drawn over it -- no deck, header, QR, rail, counters, captions or any overlay layer, in the render and in Play. The item before it (its chrome too) fades to black and the video fades up (`enter`, 0.5 s each; `"cut"` opts out), without shortening the video; as the last entry the cut ends on its final frame (no end fade). Its sound is levelled like a clip's, with an optional bass boost before the level (`audio.bass`, dB). `umtool timeline <p> [--take <t>] add-video <src> --from 32.26 --bass 8` adds one; `set-video <id> key=value` sets its knobs.
- **`posts reread --pause "@71.2=0.45"`: a pause at a time of the take.** A read whose word timings drift (a script word said as several -- "45" as "forty-five") put a word-named pause inside the next word. `@<seconds>` names the time instead; the cut is the quietest point within 0.15 s of it, kept on later re-cuts.
diff --git a/umtool/components/projects/TrailerBeatsEditor.tsx b/umtool/components/projects/TrailerBeatsEditor.tsx
@@ -35,6 +35,9 @@ type View = {
xfade: number;
intro: boolean;
introSeconds: number | null;
+ introOwn?: { style?: string; site?: unknown } | null;
+ outro?: { title: string; text: string; image: string | null; seconds: number } | null;
+ outroSetting?: { on: boolean; title?: string; text?: string; image?: string; seconds?: number } | null;
total: number;
remaining: number;
over: boolean;
@@ -122,7 +125,7 @@ export default function TrailerBeatsEditor({ project, reel = "trailer" }: { proj
<span className="text-[12px] text-[var(--color-dim)]">
of {clock(view.limit)} ·{" "}
{view.over ? <span className="text-[var(--color-bad)]">over by {(view.total - view.limit).toFixed(1)} s</span> : `${view.remaining.toFixed(1)} s to spare`} · {view.rows.length} beat
- {view.rows.length === 1 ? "" : "s"} · crossfade {view.xfade} s{view.intro ? ` · intro ${view.introSeconds ?? "?"} s` : ""}
+ {view.rows.length === 1 ? "" : "s"} · crossfade {view.xfade} s{view.intro ? ` · intro ${view.introSeconds ?? "?"} s` : ""}{view.outro ? ` · outro ${view.outro.seconds} s` : ""}
</span>
{view.confirmed > 0 && (
<span data-testid="trailer-confirmed" className="text-[12px] text-[var(--color-dim)]">
@@ -183,7 +186,64 @@ export default function TrailerBeatsEditor({ project, reel = "trailer" }: { proj
<label className="inline-flex items-center gap-1">
<input type="checkbox" data-testid="trailer-intro" checked={view.intro} disabled={busy} onChange={(e) => void op("settings", { intro: e.target.checked })} />
open on the brand intro
+ {view.introOwn ? (
+ <span data-testid="trailer-intro-own" className="text-[var(--color-dim)]" title="the reel's own intro (umtool trailer-beats … intro '<JSON>'); unticking turns it off">
+ (its own: {view.introOwn.style}
+ {typeof view.introOwn.site === "string" ? `, ${view.introOwn.site}` : ""})
+ </span>
+ ) : null}
</label>
+ <span className="inline-flex flex-wrap items-center gap-1" data-testid="trailer-outro-fields">
+ <label className="inline-flex items-center gap-1" title="end on a card: the full video's title, a call to action, the site's name; faded in from the last beat and held">
+ <input type="checkbox" data-testid="trailer-outro" checked={!!view.outro} disabled={busy} onChange={(e) => void op("settings", { outro: e.target.checked })} />
+ end on the outro card
+ </label>
+ {(view.outro || view.outroSetting) && (
+ <>
+ <input
+ data-testid="trailer-outro-title"
+ aria-label="outro title"
+ defaultValue={view.outroSetting?.title ?? ""}
+ key={`ot-${view.outroSetting?.title ?? ""}`}
+ placeholder={view.outro?.title || "the full video's title"}
+ onKeyDown={(e) => e.key === "Enter" && void op("settings", { outro: { title: (e.target as HTMLInputElement).value || null } })}
+ className={`${input} w-56`}
+ />
+ <input
+ data-testid="trailer-outro-text"
+ aria-label="outro call to action"
+ defaultValue={view.outroSetting?.text ?? ""}
+ key={`ox-${view.outroSetting?.text ?? ""}`}
+ placeholder="Full video on the channel"
+ onKeyDown={(e) => e.key === "Enter" && void op("settings", { outro: { text: (e.target as HTMLInputElement).value || null } })}
+ className={`${input} w-44`}
+ />
+ <input
+ data-testid="trailer-outro-image"
+ aria-label="outro image (a file of the project)"
+ defaultValue={view.outroSetting?.image ?? ""}
+ key={`oi-${view.outroSetting?.image ?? ""}`}
+ placeholder="promo/thumbnail.jpg"
+ onKeyDown={(e) => e.key === "Enter" && void op("settings", { outro: { image: (e.target as HTMLInputElement).value || null } })}
+ className={`${input} w-40`}
+ />
+ <input
+ data-testid="trailer-outro-seconds"
+ aria-label="outro seconds"
+ defaultValue={view.outroSetting?.seconds ?? ""}
+ key={`os-${view.outroSetting?.seconds ?? ""}`}
+ placeholder="3.5"
+ onKeyDown={(e) => {
+ if (e.key !== "Enter") return;
+ const v = (e.target as HTMLInputElement).value;
+ void op("settings", { outro: { seconds: v ? Number(v) : null } });
+ }}
+ className={`${input} w-12`}
+ />
+ s
+ </>
+ )}
+ </span>
<label className="inline-flex items-center gap-1">
title
<input
diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md
@@ -279,6 +279,12 @@ $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).
+- **The intro and the outro card.** `--intro` opens the short on the brand intro re-laid 9:16 -- the same style,
+ sound, timing and site swap, the drawing centred in the safe area -- from the take's `render.intro`, 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 (`trailer-beats … outro …`) ends on its card laid out 9:16 inside the
+ safe area (`--no-outro`: not). Both are added in one pass after the short is made, in the heavy slot, and the
+ record names them (`intro`, `outro`).
- Hooks only ever say the cut's own words: a clip's title, its section's title (the deck's marker), or a line you give.
## `check` is the one to run before every build
diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md
@@ -1171,8 +1171,8 @@ length here ([report-video.md](report-video.md#trailer-from-the-master)).
| a beat's seconds; pull it inside its clip | the row's from–to; **fit to clip** | `umtool trailer-beats <p> set <n> <from>-<to> [--label L]` | `{op: "set", index, patch}` |
| move, remove, the cut's order | ↑ ↓ **remove**; **Order by the cut** | `move <n> --to <m>` · `remove <n>` · `order` | `{op: "move", index, to}` · `{op: "remove", index}` · `{op: "order"}` |
| the limit, the crossfade, the intro | **limit** (a platform, or seconds), **crossfade**, **open on the brand intro** | `limit <s\|m:ss\|x\|instagram\|shorts\|tiktok\|default>` · `xfade <s>` · `intro on\|off` | `{op: "settings", limit?, xfade?, intro?}` |
-| the reel's own intro (render.intro's shape -- style, mark, seconds, site…): rendered for the reel at the take's size and encode, whatever the master opens on; `intro on` with a master that has no brand intro renders the take's `render.intro` for it, else the default (`boot-dark`, mark `chime`, site `auto`) -- no longer refused | -- | `intro '{"style":"boot-dark","mark":"chime","seconds":4.75,"site":"anilyzer"}'` | `{op: "settings", intro: {…}}` |
-| the **outro card** the reel ends on: the full video's title large (default the reel's `title`, else the project's), a call to action (default "Full video on the channel"), an image of the project's under it blurred and darkened (none: the dark ground), the site's name small (the intro's site, else the cut's `siteOrigin`'s, else Archilyzer) in its accent; `seconds` 1.5–10 (3.5), its 0.5 s fade in from the last beat included (the beat's sound fades out under it, silence after); the reel holds the card to its end; counted in the length (its seconds less the fade; `ls` says `· outro 3.5 s`) | -- | `outro on\|off\|none` · `outro '{"title":"…","text":"…","image":"promo/thumb.jpg","seconds":3.5}'` (merges; a key `null` drops it; `off` keeps the words) | `{op: "settings", outro: true\|false\|{…}\|null}` |
+| the reel's own intro (render.intro's shape -- style, mark, seconds, site…): rendered for the reel at the take's size and encode, whatever the master opens on; `intro on` with a master that has no brand intro renders the take's `render.intro` for it, else the default (`boot-dark`, mark `chime`, site `auto`) -- no longer refused | **open on the brand intro** says "(its own: …)" | `intro '{"style":"boot-dark","mark":"chime","seconds":4.75,"site":"anilyzer"}'` | `{op: "settings", intro: {…}}` |
+| the **outro card** the reel ends on: the full video's title large (default the reel's `title`, else the project's), a call to action (default "Full video on the channel"), an image of the project's under it blurred and darkened (none: the dark ground), the site's name small (the intro's site, else the cut's `siteOrigin`'s, else Archilyzer) in its accent; `seconds` 1.5–10 (3.5), its 0.5 s fade in from the last beat included (the beat's sound fades out under it, silence after); the reel holds the card to its end; counted in the length (its seconds less the fade; `ls` says `· outro 3.5 s`); `umtool vertical --reel` lays it out 9:16 inside the safe area | the Trailer page's **end on the outro card**, and beside it the title, the call to action, the image (a project path) and the seconds (Enter saves each; blank is the default) | `outro on\|off\|none` · `outro '{"title":"…","text":"…","image":"promo/thumb.jpg","seconds":3.5}'` (merges; a key `null` drops it; `off` keeps the words) | `{op: "settings", outro: true\|false\|{…}\|null}` |
| the walk's ★ clips | **★ from the walk**: each **Add** | `umtool trailer-beats <p> candidates [--add]` | `GET` (`candidates`) |
| undo the last write (every write is an undo point) | **Undo** (the beats); **Undo last write** / `U` (the reel's walk) | `umtool trailer-beats <p> undo` | `{op: "undo"}` |
@@ -1299,6 +1299,7 @@ byte what it was.
| the cut 9:16 | `umtool look <p> format='"vertical"' vertical='{"clip":"framed","hook":"section"}'` (`format='"landscape"'` back) |
| 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`) |
| 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` |
diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md
@@ -3281,6 +3281,12 @@ The validators refuse an unknown style, ground, length or key by name
(`validateLook`, so the Look panel, `umtool look`, a take and the build all
refuse the same thing).
+**Portrait (a Short).** At a 9:16 size (`--width 1080 --height 1920`, or `umtool vertical … --intro`) the
+same intro -- style, mark, sound, timing, site swap -- is drawn centred in the Shorts safe area (between the top
+8 % and the bottom 20 %, inside 12 % of either side: `PORTRAIT_SAFE_CENTRE` / `PORTRAIT_SAFE_WIDTH` in
+chrome-intro.mjs), the URLs hanging below it as in 16:9. A landscape intro's page is unchanged, byte for byte, so
+its cached renders stay.
+
**Judging styles outside a cut.**
`node umtool/report-to-video/intro.mjs render --style boot-mark [--ground light] --out x.mp4`
renders one at 1920×1080 30 fps through the heavy slot.
diff --git a/umtool/e2e/trailer-beats.spec.ts b/umtool/e2e/trailer-beats.spec.ts
@@ -105,3 +105,21 @@ test("add a beat from a clip, edit its seconds, move it and remove it", async ({
await page.locator("[data-beat-remove='1']").click();
await expect.poll(() => beats().map((b) => b.id)).toEqual(["c03", "c05", "c02"]);
});
+
+test("the outro card: on adds its 3 s to the running length; its title written through the writer; off keeps the words", async ({ page }) => {
+ await open(page);
+ await expect(page.getByTestId("trailer-total")).toHaveText("0:03.9");
+ await expect(page.getByTestId("trailer-outro-title")).toHaveCount(0);
+ await page.getByTestId("trailer-outro").click();
+ await expect.poll(() => doc().outro).toEqual({ on: true });
+ // 3.9 s of beats, then the card's 3.5 s less its 0.5 s fade in.
+ await expect(page.getByTestId("trailer-total")).toHaveText("0:06.9");
+ await expect(page.getByTestId("trailer-editor")).toContainText("outro 3.5 s");
+ await page.getByTestId("trailer-outro-title").fill("The Whole Story");
+ await page.getByTestId("trailer-outro-title").press("Enter");
+ await expect.poll(() => doc().outro).toEqual({ on: true, title: "The Whole Story" });
+ await page.getByTestId("trailer-outro").click();
+ await expect.poll(() => doc().outro).toEqual({ on: false, title: "The Whole Story" });
+ await expect(page.getByTestId("trailer-total")).toHaveText("0:03.9");
+ await expect(page.getByTestId("trailer-outro-title")).toHaveValue("The Whole Story");
+});
diff --git a/umtool/lib/report/verticalCli.mjs b/umtool/lib/report/verticalCli.mjs
@@ -20,6 +20,7 @@ import { REPORTS_ROOT, resolveProject } from "../projects/core.mjs";
import { kindMakesTakes } from "../projects/kinds.mjs";
import { takesDirOf } from "./takes.mjs";
import { readTrailerBeats, reelFileOf } from "./trailerBeats.mjs";
+import { resolveOutro } from "umtool-report-to-video/outro";
import { PIPELINE_DIR, UMTOOL_DIR } from "./driver.mjs";
export const VERTICAL_USAGE = [
@@ -27,6 +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]",
"",
"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",
@@ -44,12 +46,16 @@ export const VERTICAL_USAGE = [
"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",
"runs in the heavy slot, as a take's does.",
+ "--intro opens the short on the brand intro re-laid 9:16 (centred in the safe area; the take's render.intro,",
+ "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.",
].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 BOOL = new Set(["--reframe", "--landscape", "--dry-run", "--json", "--help"]);
+const BOOL = new Set(["--reframe", "--landscape", "--dry-run", "--json", "--help", "--intro", "--no-intro", "--no-outro"]);
function parse(args) {
/** @type {Record<string, string>} */
@@ -86,6 +92,15 @@ export function knobsOfFlags(flags) {
return k;
}
+const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
+
+/** The heavy slot (report-to-video/heavy-gate.mjs), loaded at run time: `(cmd, fn) => …` with a declared estimate. */
+async function heavySlot() {
+ const gate = new URL("./heavy-gate.mjs", import.meta.resolve("umtool-report-to-video/package.json")).href;
+ const { withRenderSlot } = await import(/* webpackIgnore: true */ gate);
+ return (cmd, fn) => withRenderSlot(cmd, fn, { estimateMb: 2500 });
+}
+
const readJson = (file) => readFile(file, "utf8").then((t) => JSON.parse(t), () => null);
/** Run a process, its output to `log`; resolves to its exit code. */
@@ -127,10 +142,13 @@ export async function verticalCommand(args, { reportsRoot = REPORTS_ROOT, log =
const reel = p.flags["--reel"] ?? null;
let take = p.flags["--take"] ?? null;
let beats = null;
+ /** The reel's settings (its intro, outro and crossfade), when the short is a reel. */
+ let reelSettings = /** @type {Record<string, any>} */ ({});
if (reel) {
const doc = await readTrailerBeats(dir, { reel });
if (!doc.exists) throw new CliError(`no reel ${reel}: ${reelFileOf(reel)} is not there`);
beats = P.beatsOf(doc.beats);
+ reelSettings = doc.settings ?? {};
take ??= doc.settings?.take ?? null;
} else if (p.has("--beats")) {
const doc = await readJson(path.resolve(p.flags["--beats"]));
@@ -171,10 +189,20 @@ export async function verticalCommand(args, { reportsRoot = REPORTS_ROOT, log =
const c = await readJson(path.join(sourced, "segments", `${e.id}.cut.json`));
if (c) cuts.set(e.id, c);
}
+ // The brand intro (9:16) and the reel's outro card (outro.mjs), added after the short is made.
+ const introSpec = p.has("--no-intro") ? null : isObj(reelSettings.intro) ? reelSettings.intro : (p.has("--intro") || reelSettings.intro === true) ? true : null;
+ let outro = null;
+ const o = p.has("--no-outro") ? null : resolveOutro(reelSettings.outro, { reelTitle: reelSettings.title ?? null, projectTitle: projectManifest?.title ?? null });
+ if (o) {
+ if (!o.title) throw new CliError(`the reel ${reel}'s outro has no title: give it one (\`umtool trailer-beats ${r.project.id} --reel ${reel} outro '{"title":"…"}'\`)`);
+ const imageFile = o.image ? path.join(dir, o.image) : null;
+ if (imageFile && !existsSync(imageFile)) throw new CliError(`the reel ${reel}'s outro image ${o.image} is not a file of ${r.project.id}`);
+ outro = { ...o, imageFile };
+ }
const plan = P.planVerticalCut({ timeline: takeManifest.timeline ?? [], beats, items, schedule, cuts, project: projectManifest?.timeline ?? [] });
if (p.has("--dry-run")) {
- const out = { project: r.project.id, take, name, layout: tag, wouldWrite: outFile, pieces: plan.pieces, items: plan.timeline.map((e) => ({ id: e.id, type: e.type, start: e.start, end: e.end })) };
- log(json ? JSON.stringify(out, null, 2) : [`would write ${outFile}`, ...plan.pieces.map((x) => ` ${x.id}${x.to === null ? "" : ` ${x.from}–${x.to}`}`)].join("\n"));
+ const out = { project: r.project.id, take, name, layout: tag, wouldWrite: outFile, intro: introSpec ? (introSpec === true ? "the take's render.intro, else the default" : introSpec) : null, outro: outro ? { title: outro.title, text: outro.text, image: outro.image, seconds: outro.seconds } : null, pieces: plan.pieces, items: plan.timeline.map((e) => ({ id: e.id, type: e.type, start: e.start, end: e.end })) };
+ log(json ? JSON.stringify(out, null, 2) : [`would write ${outFile}`, ...(introSpec ? [" (intro, 9:16)"] : []), ...plan.pieces.map((x) => ` ${x.id}${x.to === null ? "" : ` ${x.from}–${x.to}`}`), ...(outro ? [` (outro card "${outro.title}", ${outro.seconds} s)`] : [])].join("\n"));
return 0;
}
const started = Date.now();
@@ -217,9 +245,21 @@ export async function verticalCommand(args, { reportsRoot = REPORTS_ROOT, log =
render: { ...takeManifest.render, vertical: { ...(takeManifest.render?.vertical ?? {}), ...knobs } }, log: 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) {
+ const { wrapShort } = await import("umtool-report-to-video/reel-intro");
+ const RF = await import("umtool-report-to-video/reframe");
+ const slot = await heavySlot();
+ wrapped = await slot(["umtool", "vertical", r.project.id, "--take", take, ...(reel ? ["--reel", reel] : []), "(intro/outro)"], () => wrapShort({
+ file: outFile, takeDir, render: takeManifest.render ?? {}, manifest: takeManifest, introSpec, outro,
+ xfade: typeof reelSettings.xfade === "number" ? reelSettings.xfade : 0.3, log: say,
+ }));
+ made = { ...made, seconds: await RF.probeSeconds(outFile) };
+ }
const record = {
version: 1, kind: "vertical-short", project: r.project.id, take, name, layout: tag, reframe,
- knobs, pieces: plan.pieces, seconds: made.seconds, loudness: made.loudness ?? null,
+ 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,
madeAt: new Date().toISOString(), buildSeconds: Math.round((Date.now() - started) / 1000),
};
diff --git a/umtool/report-to-video/chrome-intro.mjs b/umtool/report-to-video/chrome-intro.mjs
@@ -164,6 +164,11 @@ const W_URL = 600;
/** The swap's beat: how long the prefix takes to change, from the chime. */
export const SWAP_SECONDS = 0.35;
+/** A portrait intro's vertical centre, as a fraction of the height: the middle of the Shorts safe area (8 % top, 20 % bottom). */
+export const PORTRAIT_SAFE_CENTRE = (0.08 + (1 - 0.2)) / 2;
+/** A portrait intro's widest drawing, as a fraction of the width: inside 12 % of either side. */
+export const PORTRAIT_SAFE_WIDTH = 1 - 2 * 0.12;
+
// The contrast rule (common/lib/brand.ts): an accent reads at 4.5:1 on its ground.
const MIN_CONTRAST = 4.5;
function luminance(hex) {
@@ -738,13 +743,18 @@ export function introHtml({
const x1 = parts.width;
const y0 = Math.min(parts.top, withMark ? parts.mark.y : Infinity);
const y1 = Math.max(parts.bottom, withMark ? parts.mark.y + parts.mark.size : -Infinity);
- const k = r3((W * (withMark ? 0.7 : 0.61)) / (x1 - x0));
+ const k = H > W ? r3(Math.min(W * (withMark ? 0.7 : 0.61), W * PORTRAIT_SAFE_WIDTH) / (x1 - x0)) : r3((W * (withMark ? 0.7 : 0.61)) / (x1 - x0));
const ox = r3(W / 2 - ((x0 + x1) / 2) * k);
// The site swap: what changes on the chime. The lockup is centred exactly as
// the plain intro centres it, and the URLs hang below it, left out of the
// centring -- so on the chime it only ever moves sideways, never a vertical
// lift (operator, 2026-10-26).
- const oy = r3(H / 2 - ((y0 + y1) / 2) * k);
+ // A portrait frame (a Short, 9:16) centres the drawing in the platform's safe
+ // area -- below the top 8 %, above the bottom 20 % (the player's own text) --
+ // and keeps it inside 12 % of either side (the right 12 % carries its buttons).
+ // A landscape frame is centred exactly as it always was.
+ const portrait = H > W;
+ const oy = portrait ? r3(H * PORTRAIT_SAFE_CENTRE - ((y0 + y1) / 2) * k) : r3(H / 2 - ((y0 + y1) / 2) * k);
const plan = site ? swapPlan({ parts, site, url, urlPlace, markX: withMark ? parts.mark.x : null, suffix, projectUrl }) : null;
const accent = site ? introAccent(site.accent, ground, palette) : null;
const lift = 0;
diff --git a/umtool/report-to-video/outro.test.mjs b/umtool/report-to-video/outro.test.mjs
@@ -189,3 +189,50 @@ test("makeTrailer: a reel's own intro and the card, made inside the slot; the re
await rm(root, { recursive: true, force: true });
}
});
+
+test("the portrait intro: the drawing centred in the Shorts safe area (top 8 %, bottom 20 %, 12 % either side); landscape unchanged", async () => {
+ const { introHtml, lockupParts, PORTRAIT_SAFE_CENTRE } = await import("./chrome-intro.mjs");
+ const { brandKit } = await import("./brand.mjs");
+ const kit = brandKit("archilyzer-media");
+ const parts = lockupParts(kit);
+ for (const mark of ["none", "chime"]) {
+ const W = 1080;
+ const H = 1920;
+ const html = introHtml({ style: "boot-dark", ground: "dark", mark, seconds: 4.75, width: W, height: H, fps: 30, kit, site: { name: "Anilyzer", lead: "Ani", accent: "sakura", url: "anilyzer.pages.dev" } });
+ const m = /<g data-k="stage">\s*<g transform="translate\(([-\d.]+) ([-\d.]+)\) scale\(([-\d.]+)\)">/.exec(html);
+ assert.ok(m, "the stage's transform");
+ const [ox, oy, k] = m.slice(1).map(Number);
+ const withMark = mark !== "none";
+ const x0 = withMark ? parts.mark.x : 0;
+ const y0 = Math.min(parts.top, withMark ? parts.mark.y : Infinity);
+ const y1 = Math.max(parts.bottom, withMark ? parts.mark.y + parts.mark.size : -Infinity);
+ assert.ok(ox + x0 * k >= W * 0.12 - 1, `left ${ox + x0 * k}`);
+ assert.ok(ox + parts.width * k <= W * 0.88 + 1, `right ${ox + parts.width * k}`);
+ assert.ok(oy + y0 * k >= H * 0.08, `top ${oy + y0 * k}`);
+ assert.ok(oy + y1 * k <= H * 0.8, `bottom ${oy + y1 * k}`);
+ assert.ok(Math.abs(oy + ((y0 + y1) / 2) * k - H * PORTRAIT_SAFE_CENTRE) < 1);
+ }
+ // landscape: centred on the frame, as it always was
+ const l = introHtml({ style: "boot-dark", ground: "dark", mark: "none", seconds: 4.18, width: 1920, height: 1080, fps: 30, kit });
+ const [lx, ly, lk] = /<g data-k="stage">\s*<g transform="translate\(([-\d.]+) ([-\d.]+)\) scale\(([-\d.]+)\)">/.exec(l).slice(1).map(Number);
+ assert.ok(Math.abs(ly + ((parts.top + parts.bottom) / 2) * lk - 540) < 1);
+ assert.ok(Math.abs(lx + (parts.width / 2) * lk - 960) < 1);
+});
+
+test("wrapShortArgs: the intro crossfaded into the short, the card after it; a hard cut with xfade 0", async () => {
+ const { wrapShortArgs } = await import("./reel-intro.mjs");
+ const { filterPath } = await import("./trailer.mjs");
+ const { outroFilterParts } = await import("./outro.mjs");
+ const base = { short: "/s.mp4", shortSeconds: 40, fps: 30, encode: ["-c:v", "libx264"], out: "/o.mp4", escape: filterPath, outroParts: outroFilterParts };
+ const argv = wrapShortArgs({ ...base, intro: { file: "/i.mp4", seconds: 4.75 }, outro: { png: "/c.png", seconds: 3.5, fade: 0.5 }, xfade: 0.3 });
+ const g = argv[argv.indexOf("-filter_complex") + 1];
+ assert.match(g, /\[iv\]trim=end_frame=143/);
+ assert.match(g, /\[ivt\]\[sv\]xfade=transition=fade:duration=0\.300000:offset=4\.466667\[wv\]/);
+ // the card fades in over the last 0.5 s of intro + short − crossfade
+ assert.match(g, /xfade=transition=fade:duration=0\.500000:offset=43\.966667\[ov\]/);
+ assert.deepEqual(argv.slice(argv.indexOf("-map"), argv.indexOf("-map") + 4), ["-map", "[ov]", "-map", "[oa]"]);
+ const hard = wrapShortArgs({ ...base, intro: { file: "/i.mp4", seconds: 4.75 }, xfade: 0 });
+ assert.match(hard[hard.indexOf("-filter_complex") + 1], /concat=n=2:v=1:a=1\[wv\]\[wa\]/);
+ const onlyOutro = wrapShortArgs({ ...base, outro: { png: "/c.png", seconds: 3.5, fade: 0.5 } });
+ assert.match(onlyOutro[onlyOutro.indexOf("-filter_complex") + 1], /offset=39\.500000\[ov\]/);
+});
diff --git a/umtool/report-to-video/reel-intro.mjs b/umtool/report-to-video/reel-intro.mjs
@@ -110,3 +110,111 @@ export async function outroBrand(entry, { provenance = null, sitesDir = undefine
}
export { ReelIntroError };
+
+/**
+ * The ffmpeg argv that puts a reel's intro before a finished short and its
+ * outro card after it, in one pass (`umtool vertical`, 9:16): the intro
+ * crossfaded into the short over `xfade` (0: a hard cut), the card faded in
+ * over its last `fade` seconds and held (outro.mjs outroFilterParts). Pure.
+ *
+ * @param {{ short: string, shortSeconds: number, intro?: { file: string, seconds: number } | null,
+ * outro?: { png: string, seconds: number, fade?: number } | null, fps: number, xfade?: number,
+ * render?: Record<string, any>, encode: string[], out: string, escape: (f: string) => string,
+ * outroParts: (o: any) => { parts: string[], vOut: string, aOut: string } }} o
+ */
+export function wrapShortArgs({ short, shortSeconds, intro = null, outro = null, fps, xfade = 0.3, render = {}, encode, out, escape, outroParts }) {
+ const rate = render.audioRate ?? 48000;
+ const layout = render.audioChannels === 1 ? "mono" : "stereo";
+ const norm = (lab, file) => [
+ `movie=filename=${escape(file)}:streams=dv+da[${lab}v0][${lab}a0]`,
+ `[${lab}v0]fps=${fps},format=yuv420p,setsar=1,settb=AVTB[${lab}v]`,
+ `[${lab}a0]aresample=${rate},aformat=channel_layouts=${layout}[${lab}a]`,
+ ];
+ const parts = [...norm("s", short)];
+ let v = "[sv]";
+ let a = "[sa]";
+ let seconds = shortSeconds;
+ if (intro) {
+ const n = Math.round(intro.seconds * fps);
+ const d = (n / fps).toFixed(6);
+ parts.push(...norm("i", intro.file));
+ parts.push(`[iv]trim=end_frame=${n},setpts=PTS-STARTPTS[ivt]`, `[ia]atrim=end=${d},asetpts=PTS-STARTPTS,apad=whole_dur=${d},atrim=end=${d}[iat]`);
+ if (xfade > 0) {
+ parts.push(`[ivt][sv]xfade=transition=fade:duration=${xfade.toFixed(6)}:offset=${(n / fps - xfade).toFixed(6)}[wv]`, `[iat][sa]acrossfade=d=${xfade.toFixed(6)}:c1=tri:c2=tri[wa]`);
+ seconds = n / fps + shortSeconds - xfade;
+ } else {
+ parts.push(`[ivt][iat][sv][sa]concat=n=2:v=1:a=1[wv][wa]`);
+ seconds = n / fps + shortSeconds;
+ }
+ v = "[wv]";
+ a = "[wa]";
+ }
+ if (outro) {
+ const o = outroParts({ png: outro.png, seconds: outro.seconds, fade: outro.fade, fps, cutSeconds: seconds, vIn: v, aIn: a, audioRate: rate, audioChannels: render.audioChannels ?? 2, escape });
+ parts.push(...o.parts);
+ v = o.vOut;
+ a = o.aOut;
+ }
+ return ["-nostdin", "-v", "error", "-y", "-filter_complex", parts.join(";"), "-map", v, "-map", a, "-map_metadata", "-1", ...encode, "-movflags", "+faststart", out];
+}
+
+/**
+ * A finished short with the reel's intro before it and its outro card after
+ * it: the intro rendered at the short's size (1080x1920; its drawing centred
+ * in the safe area, chrome-intro.mjs), the card drawn at it (outro.mjs, inside
+ * the safe area), joined in one pass, written beside and renamed over `file`.
+ * Returns what was added (`{ intro, outro }`, each null when not asked).
+ *
+ * @param {{ file: string, takeDir: string, render: Record<string, any>, manifest?: any, introSpec?: unknown,
+ * outro?: { title: string, text: string, image?: string | null, imageFile?: string | null, seconds: number } | null,
+ * xfade?: number, sitesDir?: string, log?: (s: string) => void }} o
+ */
+export async function wrapShort({ file, takeDir, render, manifest = null, introSpec = null, outro = null, xfade = 0.3, sitesDir = undefined, log = () => {} }) {
+ if (!introSpec && !outro) return { intro: null, outro: null };
+ const { execFile } = await import("node:child_process");
+ const { promisify } = await import("node:util");
+ const { rename, rm } = await import("node:fs/promises");
+ const execFileP = promisify(execFile);
+ const FFMPEG = process.env.FFMPEG_BIN ?? "ffmpeg";
+ const FFPROBE = process.env.FFPROBE_BIN ?? "ffprobe";
+ const { filterPath } = await import("./trailer.mjs");
+ const { OUTRO_FADE, outroFilterParts, renderOutroCard } = await import("./outro.mjs");
+ const { stdout } = await execFileP(FFPROBE, ["-v", "error", "-select_streams", "v:0", "-show_entries", "stream=width,height,nb_frames:format=duration", "-of", "json", file]);
+ const j = JSON.parse(stdout);
+ const W = Number(j.streams?.[0]?.width) || 1080;
+ const H = Number(j.streams?.[0]?.height) || 1920;
+ const fps = render.fps ?? 30;
+ const frames = Number(j.streams?.[0]?.nb_frames);
+ const shortSeconds = Number.isFinite(frames) && frames > 0 ? frames / fps : Number(j.format?.duration);
+ const vr = { ...render, width: W, height: H };
+ // The short's intro: never the master's 16:9 frames -- the reel's own, else the take's render.intro, else the default.
+ let ri = null;
+ if (introSpec) ri = reelIntroOf({ build: { schedule: null, render: vr, manifest }, introSpec: introSpec === true ? null : introSpec, sitesDir });
+ let introFile = null;
+ if (ri) {
+ log(`vertical: intro ${ri.label.replace(/, rendered for (it|the reel).*$/, "")} at ${W}x${H} …`);
+ introFile = (await renderIntro({ entry: ri.entry, render: vr, encode: encodeArgs(vr), manifestDir: takeDir, workDir: path.join(takeDir, "out", "sourced", "chrome") })).path;
+ }
+ let card = null;
+ if (outro) {
+ const brand = await outroBrand(ri?.entry ?? null, { provenance: manifest?.provenance ?? null, sitesDir });
+ const r = await renderOutroCard({ width: W, height: H, title: outro.title, text: outro.text, imageFile: outro.imageFile ?? null, brand, dir: path.join(takeDir, "out", "sourced", "outro") });
+ card = { png: r.file, seconds: outro.seconds, fade: OUTRO_FADE };
+ log(`vertical: outro card ${r.cached ? "(drawn before)" : "drawn"} -- "${outro.title}"`);
+ }
+ const tmp = path.join(path.dirname(file), `.${path.basename(file, ".mp4")}.${process.pid}.wrap.mp4`);
+ const argv = wrapShortArgs({
+ short: file, shortSeconds, intro: introFile ? { file: introFile, seconds: ri.entry.seconds } : null, outro: card, fps, xfade, render: vr,
+ encode: encodeArgs(vr), out: tmp, escape: filterPath, outroParts: outroFilterParts,
+ });
+ try {
+ await execFileP(FFMPEG, argv, { maxBuffer: 1 << 26 });
+ await rename(tmp, file);
+ } finally {
+ await rm(tmp, { force: true });
+ }
+ return {
+ intro: ri ? { from: ri.from, style: ri.entry.style, site: ri.entry.site?.name ?? null, seconds: ri.entry.seconds, file: introFile } : null,
+ outro: card ? { title: outro.title, text: outro.text, image: outro.image ?? null, seconds: card.seconds, fade: card.fade, card: card.png } : null,
+ };
+}