Archilyzer · Source

archilyzer

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

commit 891551e1ddffc6829a780f5cfa2feaad1f00248f
parent 5014c0dd80001687bba5dbe4d1a5432d4f9e6a58
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Fri, 13 Nov 2026 22:13:00 -0500

clip kit G: a cold open -- the payoff first, then the clip

A clip's `coldOpen` ({from, to}: 1-4 s of its cut; a note outside 1.5-3 s) is planned
as an entry of its own, <id>~co (vertical-plan.mjs coldOpenEntry), before the clip: its
own words and sound, the hook band, no code, no card, only its own zooms. Both pieces
are joined hard (`hard` pieces: assembleShort cuts them from their segments, never the
build's crossfade); the promo still ends the clip.

Played by a per-clip build of items (a short, a desktop clip, a batch): not a reel's
beats, --landscape, --reframe or the stacked deck. --no-cold-open on vertical and
shorts. Writer and set (`coldOpen`, `coldOpen.from`, `coldOpen.to`), lint, the clip
editor's Cold open from selection / Clear. Without the key the plan and its pieces are
the ones they always were.

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

Diffstat:
Meditor/CHANGELOG.md | 7+++++++
Mumtool/components/projects/review/ClipEditor.tsx | 38++++++++++++++++++++++++++++++++++++--
Mumtool/docs/cli.md | 6++++--
Mumtool/docs/knobs.md | 21+++++++++++++++++++++
Mumtool/lib/cli/verbs.mjs | 2++
Mumtool/lib/report/clipEditorTypes.ts | 2+-
Mumtool/lib/report/clipKit.test.mjs | 15+++++++++++++++
Mumtool/lib/report/knobsCli.mjs | 6+++++-
Mumtool/lib/report/shortsBatch.test.mjs | 4++--
Mumtool/lib/report/shortsCli.mjs | 9+++++----
Mumtool/lib/report/verticalCli.mjs | 19+++++++++++++------
Mumtool/report-to-video/clip-kit.mjs | 39++++++++++++++++++++++++++++++++++++---
Mumtool/report-to-video/clip-kit.test.mjs | 2+-
Aumtool/report-to-video/cold-open.test.mjs | 72++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/report-to-video/lint.mjs | 8+++++++-
Mumtool/report-to-video/reframe.mjs | 3++-
Mumtool/report-to-video/vertical-plan.mjs | 34++++++++++++++++++++++++++++++----
17 files changed, 259 insertions(+), 28 deletions(-)

diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -1,6 +1,13 @@ # Changelog ## [Unreleased] +- **umtool: a short or a desktop clip can open on its payoff.** A clip's `coldOpen` (`{from, to}`, 1–4 s of its + cut) plays first, then the short cuts hard to the clip's start. + - The cold open has its own captions and sound, the hook band, no code and no card. The channel promo still ends + the clip. + - Set it with the clip editor's **Cold open from selection** or `umtool set <p> <clip> coldOpen.from=… coldOpen.to=…`. + - Turn it off for a build with `--no-cold-open`. + - Reels, `--landscape` and the stacked deck play the clips as cut. - **umtool: a short or a desktop clip can zoom in at points.** A clip's `zooms` (`[{at, scale|box, focus, hold, ramp}]`) push its picture in at those source seconds, eased in and out. - The zoom works on the source picture before the layout. A short's crop stays put and the focus keeps its place diff --git a/umtool/components/projects/review/ClipEditor.tsx b/umtool/components/projects/review/ClipEditor.tsx @@ -890,7 +890,7 @@ export default function ClipEditor({ {view.reactionsError && <p className="m-0 text-[12px] text-reject-text">{view.reactionsError}</p>} {view.rulingsError && <p className="m-0 text-[12px] text-reject-text">{view.rulingsError}</p>} - <ShortMaker project={project} clipId={clip.id} short={view.shorts?.[clip.id] ?? null} framed={!!clip.vertical} framing={framing} onFraming={setFraming} onCentre={() => setCrop(null)} onMade={() => void reload().catch(() => {})} busy={busy} live={view.live?.status === "live"} kit={clip.kit ?? {}} onKit={(patch, done) => void write({ op: "kit", clip: clip.id, kit: patch }, done)} playhead={playhead} /> + <ShortMaker project={project} clipId={clip.id} short={view.shorts?.[clip.id] ?? null} framed={!!clip.vertical} framing={framing} onFraming={setFraming} onCentre={() => setCrop(null)} onMade={() => void reload().catch(() => {})} busy={busy} live={view.live?.status === "live"} kit={clip.kit ?? {}} onKit={(patch, done) => void write({ op: "kit", clip: clip.id, kit: patch }, done)} playhead={playhead} selection={selection} cut={cut} /> <RenderTake project={project} render={render} takes={takes} takesHref={takesHref} /> </aside> </div> @@ -1591,7 +1591,7 @@ function SpeakerLabel({ speaker, busy, onSave }: { speaker: Speaker; busy: boole } /** Make a short: the clip at 1080x1920 from its box, a job; the one there is set aside, never overwritten. */ -function ShortMaker({ project, clipId, short, framed, framing, onFraming, onCentre, onMade, busy, live = false, kit = {}, onKit, playhead = null }: { +function ShortMaker({ project, clipId, short, framed, framing, onFraming, onCentre, onMade, busy, live = false, kit = {}, onKit, playhead = null, selection = null, cut = null }: { project: string; clipId: string; short: { mtimeMs: number; size: number; stale: boolean } | null; @@ -1609,6 +1609,9 @@ function ShortMaker({ project, clipId, short, framed, framing, onFraming, onCent onKit?: (patch: Record<string, unknown>, done: string) => void; // The player's source second: the channel promo's portrait is grabbed there. playhead?: number | null; + // The strip's selection and the clip's cut: a cold open is a span of the cut (lane clip-kit, slice G). + selection?: { cutStart: number; cutEnd: number } | null; + cut?: { cutStart: number; cutEnd: number } | null; }) { const [job, setJob] = useState<{ id: string; state: string; error: string | null } | null>(null); const [err, setErr] = useState<string | null>(null); @@ -1728,6 +1731,9 @@ function ShortMaker({ project, clipId, short, framed, framing, onFraming, onCent {portrait && <span data-promo-portrait-set="">portrait: {portrait}</span>} </div> )} + {onKit && ( + <ColdOpen clipId={clipId} coldOpen={kit.coldOpen && typeof kit.coldOpen === "object" ? (kit.coldOpen as { from: number; to: number }) : null} selection={selection} cut={cut} busy={busy} onKit={onKit} /> + )} {onKit && <ZoomList clipId={clipId} zooms={Array.isArray(kit.zooms) ? (kit.zooms as Zoom[]) : []} playhead={playhead} busy={busy} onKit={onKit} />} {job && ( <p data-short-job={job.state} className="m-0 text-[12px] text-text-2"> @@ -1749,6 +1755,34 @@ function ShortMaker({ project, clipId, short, framed, framing, onFraming, onCent // source's pixels (or the cut's soft limit) by name. // --------------------------------------------------------------------------- +/** A clip's cold open (report-to-video clip-kit.mjs coldOpenErrors): a span of its cut, 1-4 s, played first. */ +function ColdOpen({ clipId, coldOpen, selection, cut, busy, onKit }: { clipId: string; coldOpen: { from: number; to: number } | null; selection: { cutStart: number; cutEnd: number } | null; cut: { cutStart: number; cutEnd: number } | null; busy: boolean; onKit: (patch: Record<string, unknown>, done: string) => void }) { + const r2 = (n: number) => Math.round(n * 100) / 100; + const len = selection ? selection.cutEnd - selection.cutStart : 0; + const fits = !!selection && !!cut && len >= 1 && len <= 4 && selection.cutStart >= cut.cutStart - 0.02 && selection.cutEnd <= cut.cutEnd + 0.02; + return ( + <div className="flex flex-wrap items-center gap-1.5 text-[12px] text-text-2" data-kit-cold-open={clipId}> + <span>Cold open</span> + <span data-cold-open-now="">{coldOpen ? `${coldOpen.from.toFixed(2)}–${coldOpen.to.toFixed(2)} s, played first` : "none"}</span> + <button + type="button" + data-cold-open-set={clipId} + disabled={busy || !fits} + onClick={() => selection && onKit({ coldOpen: { from: r2(selection.cutStart), to: r2(selection.cutEnd) } }, "The selection plays first")} + className={buttonVariants({ variant: "quiet", size: "sm" })} + title="select 1-4 s of the clip's cut on the strip: a short or a desktop clip plays it first, then cuts to the start" + > + Cold open from selection + </button> + {coldOpen && ( + <button type="button" data-cold-open-clear={clipId} disabled={busy} onClick={() => onKit({ coldOpen: null }, "No cold open")} className={buttonVariants({ variant: "quiet", size: "sm" })}> + Clear + </button> + )} + </div> + ); +} + type Zoom = { at: number; scale?: number; hold?: number; focus?: [number, number]; box?: number[]; ramp?: number }; function ZoomList({ clipId, zooms, playhead, busy, onKit }: { clipId: string; zooms: Zoom[]; playhead: number | null; busy: boolean; onKit: (patch: Record<string, unknown>, done: string) => void }) { diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md @@ -274,9 +274,9 @@ 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] [--desktop] [--dry-run] [--intro] [--no-intro] [--no-outro] [--deck stacked\|bare] [--qr on\|off] [--qr-corner tr\|tl\|br\|bl] [--promo] [--no-promo] [--promo-lead N] [--promo-fade N] [--promo-hold N]` | a vertical short (1080x1920) of a take's items | form · queued · *project* | +| `vertical <project> --take TAKE [--reel REEL] [--beats BEATS] [--items ITEMS] [--clip full\|framed\|quote] [--post card\|stack\|media] [--side split\|overlay] [--hook HOOK] [--captions l\|xl] [--lines 1\|2] [--loudness N] [--max N] [--name NAME] [--reframe] [--landscape] [--desktop] [--dry-run] [--intro] [--no-intro] [--no-outro] [--deck stacked\|bare] [--qr on\|off] [--qr-corner tr\|tl\|br\|bl] [--promo] [--no-promo] [--promo-lead N] [--promo-fade N] [--promo-hold N] [--no-cold-open]` | a vertical short (1080x1920) of a take's items | form · queued · *project* | | `promo <project> [--portrait-from PORTRAIT-FROM] [--box BOX] [--draw] [--take TAKE]` | the channel promo: its portrait from a clip at a second, its card drawn | form · *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] [--no-promo] [--promo-lead N] [--promo-fade N] [--promo-hold N] [--replace] [--dry-run]` | a batch of shorts: each clip of a take in each format, into shorts-<take>/ | 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] [--no-promo] [--promo-lead N] [--promo-fade N] [--promo-hold N] [--no-cold-open] [--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* | @@ -557,6 +557,8 @@ $U vertical emberparadox/mr-obvious --take mid-14 --reel short-die --reframe --j in silence (`--no-promo`, `--promo-lead`, `--promo-hold`; [knobs.md](knobs.md#the-channel-promo-the-card-a-clip-ends-on)). - **Zooms:** a clip's `zooms` push its picture in at points, eased (`umtool set <p> <clip> zooms='[…]'`); refused past the source's pixels unless the project allows a soft limit ([knobs.md](knobs.md#zoom-at-points-a-shorts-or-a-desktop-clips-picture-pushed-in)). +- **A cold open:** a clip's `coldOpen` (1–4 s of its cut) plays first, then a hard cut to its start (`--no-cold-open`: + not; [knobs.md](knobs.md#a-cold-open-the-payoff-first)). - **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)). diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -484,6 +484,27 @@ much softer than its source each such zoom plays. The cut record names each zoom drawn (`zooms: [{at, scale, focus, hold, ramp, enlargement}]`, `at` on the segment's clock). +## A cold open (the payoff first) + +A short or a desktop clip can open on a moment of its clip -- the payoff line -- and then cut to the clip's start +(lane clip-kit; `report-to-video/vertical-plan.mjs` `coldOpenEntry`). A clip's `coldOpen: {from, to}` (source seconds +of its cut, 1–4 s; 1.5–3 s reads best, said otherwise) is cut out as an entry of its own, `<clip>~co`, played first +with a hard cut into the clip: + +- its own words captioned and its own sound (each piece's edges faded a few hundredths of a second, as any short's); +- the hook band over it; no code (the clip's code shows from the clip on) and no card (the channel promo is the + clip's end, unaffected); its zooms only those wholly inside its span; +- counted in the short's length note. + +Only a per-clip build plays it: a reel's beats, `--landscape` (the take's look), `--reframe` and the stacked deck's +cut play the clips as cut. A whole cut's flash-forward (`umtool timeline … flash-forward`) is the cut's own copy of a +span; this is the short's. + +| | In umtool | From a terminal | +|---|---|---| +| a clip's cold open | the clip editor's **Short**: select 1–4 s of the cut on the strip, **Cold open from selection**; **Clear** | `umtool set <p> <clip> coldOpen.from=… coldOpen.to=…` (`coldOpen=` none) | +| without them | the ⌘K forms' **--no-cold-open** | `umtool vertical … --no-cold-open` · `umtool shorts … --no-cold-open` | + ## 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`), diff --git a/umtool/lib/cli/verbs.mjs b/umtool/lib/cli/verbs.mjs @@ -326,6 +326,7 @@ export const VERBS = Object.freeze([ pick("--deck", ["stacked", "bare"]), pick("--qr", ["on", "off"]), pick("--qr-corner", ["tr", "tl", "br", "bl"], { help: "br and bl: a desktop clip's" }), bool("--promo", "end on the take's channel promo (render.promo)"), bool("--no-promo", "end without it"), num("--promo-lead", { help: "s before the end the card comes up (4.5)" }), num("--promo-fade", { help: "s (0.7)" }), num("--promo-hold", { help: "s of silence on the card (1.5)" }), + bool("--no-cold-open", "play the clips as cut, without their cold opens"), ], Q), form("promo", "project", "the channel promo: its portrait from a clip at a second, its card drawn", [ project(), opt("--portrait-from", { help: "<clip>@<source second>" }), opt("--box", { help: "x,y,w,h: the circle's part of the frame" }), @@ -339,6 +340,7 @@ export const VERBS = Object.freeze([ 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("--no-promo", "no channel promo at the end"), num("--promo-lead", { help: "s (4.5)" }), num("--promo-fade", { help: "s (0.7)" }), num("--promo-hold", { help: "s (1.5)" }), + bool("--no-cold-open", "play the clips as cut, without their cold opens"), bool("--replace", "set a file there aside and make it again"), dry(), ], Q), diff --git a/umtool/lib/report/clipEditorTypes.ts b/umtool/lib/report/clipEditorTypes.ts @@ -30,7 +30,7 @@ export type EditorClip = { /** A short's framing (release 36): `crop` = [x, y, w, h], fractions of the source picture. */ vertical: { crop: number[]; aspect?: number } | null; /** The clip kit (lane clip-kit): its own code (`qr`: false or {corner?, links?}) and batch `name`, as written. */ - kit?: { qr?: false | { corner?: string; links?: string }; name?: string; promo?: false | { lead?: number; fade?: number; hold?: number }; zooms?: unknown[]; [k: string]: unknown }; + kit?: { qr?: false | { corner?: string; links?: string }; name?: string; promo?: false | { lead?: number; fade?: number; hold?: number }; zooms?: unknown[]; coldOpen?: { from: number; to: number }; [k: string]: unknown }; /** Room at its edges (release 36 lane E): the clip's own `room` as written (false: none), and the edges it gets. */ room?: false | { tail?: boolean; head?: boolean } | null; roomEdges?: { tail: boolean; head: boolean } | null; diff --git a/umtool/lib/report/clipKit.test.mjs b/umtool/lib/report/clipKit.test.mjs @@ -86,3 +86,18 @@ test("a clip's zooms written: whole, checked against its window and each other; await rm(dir, { recursive: true, force: true }); } }); + +test("a clip's cold open written: both fields in one patch, inside its cut, 1-4 s; null clears", async () => { + const dir = await mkdtemp(path.join(tmpdir(), "umtool-coldopen-")); + try { + await writeFile(path.join(dir, MANIFEST_NAME), JSON.stringify(manifest(), null, 2) + "\n"); + await updateClip(dir, "w01", { "coldOpen.from": 17, "coldOpen.to": 19.5 }); + assert.deepEqual((await read(dir)).coldOpen, { from: 17, to: 19.5 }); + await assert.rejects(updateClip(dir, "w01", { "coldOpen.to": 25 }), /w01\.coldOpen is 8 s: a cold open is 1–4 s/); + await assert.rejects(updateClip(dir, "w01", { coldOpen: { from: 19, to: 21 } }), /outside the clip's cut \(10–20\)/); + await updateClip(dir, "w01", { coldOpen: null }); + assert.equal("coldOpen" in (await read(dir)), false); + } finally { + await rm(dir, { recursive: true, force: true }); + } +}); diff --git a/umtool/lib/report/knobsCli.mjs b/umtool/lib/report/knobsCli.mjs @@ -58,7 +58,7 @@ const GAP_KEYS = ["gaps", "gap.add", "gap.remove"]; export const VERTICAL_SET_KEYS = Object.freeze(["vertical", "vertical.crop", "vertical.layout", "vertical.aspect", "vertical.crops"]); export const SIDE_SET_KEYS = Object.freeze(["side", "side.item", "side.post", "side.from", "side.to", "side.place"]); /** The clip kit (lane clip-kit; report-to-video clip-kit.mjs): a clip's code in a per-clip build, its batch file name. */ -export const KIT_SET_KEYS = Object.freeze(["qr", "qr.corner", "qr.links", "name", "promo", "promo.lead", "promo.fade", "promo.hold", "zooms"]); +export const KIT_SET_KEYS = Object.freeze(["qr", "qr.corner", "qr.links", "name", "promo", "promo.lead", "promo.fade", "promo.hold", "zooms", "coldOpen", "coldOpen.from", "coldOpen.to"]); const SET_KEYS = [ "claim", ...CLAIM_KNOBS.map((k) => `claim.${k}`), ...MARK_KEYS, ...AUDIO_KNOBS.map((k) => `audio.${k}`), ...BLUR_KNOBS.map((k) => `blur.${k}`), "layout", ...REVIEW_KEYS, ...FX_KEYS, ...GAP_KEYS, "chat", "hideModules", "shelfNote", "chapter", @@ -126,6 +126,8 @@ export const SET_USAGE = [ " promo.fade / promo.hold (seconds) its own timing over the cut's; `promo=` the cut's again.", " zooms='[{\"at\":231.4,\"scale\":1.3,\"focus\":[0.7,0.35],\"hold\":1.5}]' pushes a short's or a desktop clip's", " picture in at those source seconds (or \"box\":[x,y,w,h] to fill the frame with); `zooms=` none.", + " coldOpen.from=… coldOpen.to=… (source seconds of its cut, 1-4 s): a short or a desktop clip plays that payoff", + " first, then cuts to the clip's start; `coldOpen=` none.", " gap.add=12.3-15.1 cuts those source seconds out of the clip's middle (one segment of jump cuts; inside", " the cut, ≥ 0.2 s, 0.5 s kept between); gap.remove=<sec> the gap holding it; gaps=12.3-15.1,20-20.6 (or", " a JSON list of {from,to}) the whole list, `gaps=` none. The same as `umtool window --gap/--gap-remove/--gaps`.", @@ -370,6 +372,7 @@ export async function setCommand(args, { root = REPORTS_ROOT, out = (s) => conso if ("name" in entryPatch) results.name = result.entry.name ?? null; if (["promo", "promo.lead", "promo.fade", "promo.hold"].some((k) => k in entryPatch)) results.promo = result.entry.promo ?? null; if ("zooms" in entryPatch) results.zooms = result.entry.zooms ?? null; + if (["coldOpen", "coldOpen.from", "coldOpen.to"].some((k) => k in entryPatch)) results.coldOpen = result.entry.coldOpen ?? null; if (FX_KEYS.some((k) => k in entryPatch)) results.fx = result.entry.fx ?? null; if ("gaps" in entryPatch || "gapAdd" in entryPatch || "gapRemove" in entryPatch) { results.gaps = result.entry.gaps ?? []; @@ -408,6 +411,7 @@ export async function setCommand(args, { root = REPORTS_ROOT, out = (s) => conso if ("vertical" in results) out(`${clipId}: vertical ${results.vertical ? JSON.stringify(results.vertical) : "the cut's (the centred crop)"}`); if ("side" in results) out(`${clipId}: side ${results.side ? JSON.stringify({ ...results.side, ...(results.side.post ? { post: `@${results.side.post.handle ?? results.side.post.author}` } : {}) }) : "none"}`); if ("qr" in results) out(`${clipId}: qr ${results.qr === false ? "none on this clip" : results.qr ? JSON.stringify(results.qr) : "the cut's"}`); + if ("coldOpen" in results) out(`${clipId}: cold open ${results.coldOpen ? `${results.coldOpen.from}–${results.coldOpen.to} s, played first` : "none"}`); if ("zooms" in results) out(`${clipId}: zooms ${results.zooms ? results.zooms.map((z) => `${z.at} s ×${z.scale ?? (z.box ? "box" : 1.3)}`).join(", ") : "none"}`); if ("promo" in results) out(`${clipId}: promo ${results.promo === false ? "none (it ends without the card)" : results.promo ? JSON.stringify(results.promo) : "the cut's"}`); if ("name" in results) out(`${clipId}: name ${results.name ? JSON.stringify(results.name) : "its title's slug"}`); diff --git a/umtool/lib/report/shortsBatch.test.mjs b/umtool/lib/report/shortsBatch.test.mjs @@ -64,7 +64,7 @@ test("formats, items and the record's again", () => { test("the snapshot: the project keys a clip has, null for one it lacks; laid over the project's entries", () => { const e = { type: "clip", id: "a", vertical: { crop: [0.6, 0, 0.3164, 1] } }; - assert.deepEqual(snapshotOf(e, PROJECT_KEYS), { vertical: { crop: [0.6, 0, 0.3164, 1] }, side: null, qr: null, promo: null, zooms: null }); + assert.deepEqual(snapshotOf(e, PROJECT_KEYS), { vertical: { crop: [0.6, 0, 0.3164, 1] }, side: null, qr: null, promo: null, zooms: null, coldOpen: null }); const project = [{ type: "clip", id: "a", vertical: { crop: [0.1, 0, 0.3164, 1] }, side: { item: "p", from: 0, to: 3 } }]; const laid = withOverrides(project, { a: { vertical: { crop: [0.6, 0, 0.3164, 1] }, side: null, title: "ignored" } }); assert.deepEqual(laid[0], { type: "clip", id: "a", vertical: { crop: [0.6, 0, 0.3164, 1] } }); @@ -118,7 +118,7 @@ test("umtool shorts: each clip in each format into shorts-<take>/, named, record assert.deepEqual(files, ["batch.json", "toms-toast-w01.landscape.mp4", "toms-toast-w01.vertical.mp4", "toms-toast.landscape.mp4", "toms-toast.vertical.mp4"]); // The builder was asked one clip at a time, with the flags' knobs and each format's cap. assert.deepEqual(calls.map((c) => [c.items[0], c.landscape, c.knobs.maxSeconds, c.knobs.clip]), [["m01", false, 180, "framed"], ["m01", true, 140, "framed"], ["w01", false, 180, "framed"], ["w01", true, 140, "framed"]]); - assert.deepEqual(calls[2].overrides, { w01: { vertical: { crop: [0.6, 0, 0.3164, 1] }, side: null, qr: null, promo: null, zooms: null } }); + assert.deepEqual(calls[2].overrides, { w01: { vertical: { crop: [0.6, 0, 0.3164, 1] }, side: null, qr: null, promo: null, zooms: null, coldOpen: null } }); const rec = JSON.parse(await readFile(path.join(folder, "batch.json"), "utf8")); assert.equal(rec.kind, "shorts-batch"); assert.deepEqual(rec.last.argv, ["shorts", "proj", "--take", "kit", "--items", "m01,w01", "--formats", "vertical,landscape"]); diff --git a/umtool/lib/report/shortsCli.mjs b/umtool/lib/report/shortsCli.mjs @@ -25,7 +25,7 @@ export const SHORTS_USAGE = [ " [--hook title|section|\"<a line of the cut's own copy>\"] [--captions l|xl] [--lines 1|2]", " [--loudness -14] [--max-vertical 180] [--max-desktop 140] [--max-landscape 140]", " [--deck stacked|bare] [--qr on|off] [--qr-corner tr|tl|br|bl] [--no-promo]", - " [--promo-lead 4.5] [--promo-fade 0.7] [--promo-hold 1.5] [--replace] [--dry-run] [--json]", + " [--promo-lead 4.5] [--promo-fade 0.7] [--promo-hold 1.5] [--no-cold-open] [--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), desktop (1920x1080, minimal chrome: `umtool vertical --desktop`) and", @@ -40,7 +40,7 @@ export const SHORTS_USAGE = [ ].join("\n"); const VALUED = new Set(["--take", "--items", "--formats", "--clip", "--post", "--side", "--hook", "--captions", "--lines", "--loudness", "--max-vertical", "--max-landscape", "--max-desktop", "--deck", "--qr", "--qr-corner", "--promo-lead", "--promo-fade", "--promo-hold"]); -const BOOL = new Set(["--all", "--again", "--replace", "--dry-run", "--json", "--help", "--no-promo"]); +const BOOL = new Set(["--all", "--again", "--replace", "--dry-run", "--json", "--help", "--no-promo", "--no-cold-open"]); function parse(args) { /** @type {Record<string, string>} */ @@ -113,7 +113,7 @@ export async function shortsCommand(args, { reportsRoot = REPORTS_ROOT, log = co } // The channel promo's flags ride in the knobs a row records (`promo`: false, or its timing). const po = promoOptionsOf(p.flags); - const knobs = { ...knobsOfFlags(p.flags), ...(po.promo === false ? { promo: false } : po.promoKnobs ? { promo: po.promoKnobs } : {}) }; + const knobs = { ...knobsOfFlags(p.flags), ...(po.promo === false ? { promo: false } : po.promoKnobs ? { promo: po.promoKnobs } : {}), ...(p.has("--no-cold-open") ? { coldOpen: false } : {}) }; const takeManifest = await takeManifestOf(dir, take); let entries; try { @@ -178,12 +178,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 { promo: promoKnob, ...rest } = c.knobs ?? {}; + const { promo: promoKnob, coldOpen: coldKnob, ...rest } = c.knobs ?? {}; const fk = knobsForFormat(rest, f); const done = await build( { 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 }, ...(promoKnob === false ? { promo: false } : promoKnob && typeof promoKnob === "object" ? { promoKnobs: promoKnob } : {}), + ...(coldKnob === false ? { coldOpen: false } : {}), }, { reportsRoot, say }, ); diff --git a/umtool/lib/report/verticalCli.mjs b/umtool/lib/report/verticalCli.mjs @@ -29,7 +29,7 @@ export const VERTICAL_USAGE = [ " [--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 | --desktop] [--dry-run] [--json]", " [--intro | --no-intro] [--no-outro] [--deck stacked|bare] [--qr on|off] [--qr-corner tr|tl]", - " [--promo | --no-promo] [--promo-lead 4.5] [--promo-fade 0.7] [--promo-hold 1.5]", + " [--promo | --no-promo] [--promo-lead 4.5] [--promo-fade 0.7] [--promo-hold 1.5] [--no-cold-open]", "", "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", @@ -62,12 +62,14 @@ export const VERTICAL_USAGE = [ "The channel promo (render.promo: the streamer's portrait, name, page and its code) ends the short's last clip when", "the take sets one: the picture dissolves into the card over the clip's last --promo-lead seconds (its sound on", "under it, the captions over it), then the card holds --promo-hold seconds in silence; --no-promo ends without it.", + "A clip with a cold open (its `coldOpen`: a span of its cut, 1-4 s) plays it first, then cuts to its start;", + "--no-cold-open plays the clips as cut.", ].join("\n"); 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", "--promo-lead", "--promo-hold", "--promo-fade"]); -const BOOL = new Set(["--reframe", "--landscape", "--desktop", "--promo", "--no-promo", "--dry-run", "--json", "--help", "--intro", "--no-intro", "--no-outro"]); +const BOOL = new Set(["--reframe", "--landscape", "--desktop", "--promo", "--no-promo", "--no-cold-open", "--dry-run", "--json", "--help", "--intro", "--no-intro", "--no-outro"]); export function parse(args) { /** @type {Record<string, string>} */ @@ -197,6 +199,7 @@ export function shortOptionsOf(p) { landscape: p.has("--landscape"), desktop: p.has("--desktop"), ...promoOptionsOf(p.flags), + ...(p.has("--no-cold-open") ? { coldOpen: false } : {}), dryRun: p.has("--dry-run"), intro: p.has("--intro"), noIntro: p.has("--no-intro"), @@ -294,7 +297,11 @@ export async function buildShort(o, { reportsRoot = REPORTS_ROOT, say = () => {} outro = { ...ro, imageFile }; } const project = P.withOverrides(projectManifest?.timeline ?? [], o.overrides ?? null); - const plan = P.planVerticalCut({ timeline: takeManifest.timeline ?? [], beats, items, schedule, cuts, project }); + // A clip's cold open (vertical-plan.mjs coldOpenEntry) plays in a short or a desktop clip of the bare builder: not + // in the take's 16:9 look, a reframe or the stacked deck (each cut from a finished or crossfaded cut). + const stacked = !desktop && !landscape && !reframe && V.stackedDeckWanted({ ...(takeManifest.render ?? {}), format: "vertical", vertical: { ...(takeManifest.render?.vertical ?? {}), ...knobs } }); + const coldOpens = o.coldOpen !== false && !landscape && !reframe && !stacked; + const plan = P.planVerticalCut({ timeline: takeManifest.timeline ?? [], beats, items, schedule, cuts, project, coldOpens }); if (o.dryRun) { return { dryRun: { 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 })) } }; } @@ -331,7 +338,7 @@ export async function buildShort(o, { reportsRoot = REPORTS_ROOT, say = () => {} 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, ...promoArgs, - "--vertical-sections", JSON.stringify(Object.fromEntries(plan.timeline.map((e) => [e.id, sections.get(e.id.replace(/~\d+$/, "")) ?? null]))), + "--vertical-sections", JSON.stringify(Object.fromEntries(plan.timeline.map((e) => [e.id, sections.get(e.id.replace(/~(?:\d+|co)$/, "")) ?? 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 })); @@ -354,7 +361,7 @@ export async function buildShort(o, { reportsRoot = REPORTS_ROOT, say = () => {} process.execPath, path.join(PIPELINE_DIR, "build-video.mjs"), renderPath, "--out", outDir, "--skip-fetch", "--no-chapters", "--vertical", "--vertical-knobs", JSON.stringify(knobs), "--vertical-work", work, "--vertical-out", built, ...promoArgs, // The hook "section" names a clip's section in the WHOLE take (each planned entry under its source's id). - "--vertical-sections", JSON.stringify(Object.fromEntries(plan.timeline.map((e) => [e.id, sections.get(e.id.replace(/~\d+$/, "")) ?? null]))), + "--vertical-sections", JSON.stringify(Object.fromEntries(plan.timeline.map((e) => [e.id, sections.get(e.id.replace(/~(?:\d+|co)$/, "")) ?? null]))), ]; say(`vertical: building ${plan.timeline.length} item(s) 9:16 in the heavy slot …`); const code = await run(argv, { cwd: path.join(UMTOOL_DIR, ".."), log: say }).finally(() => rm(renderPath, { force: true })); @@ -388,7 +395,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, ...(o.promo === false ? { promo: false } : o.promoKnobs ? { promo: o.promoKnobs } : {}), pieces: plan.pieces, ...(wrapped.intro ? { intro: wrapped.intro } : {}), ...(wrapped.outro ? { outro: wrapped.outro } : {}), seconds: made.seconds, loudness: made.loudness ?? null, + knobs, ...(o.promo === false ? { promo: false } : o.promoKnobs ? { promo: o.promoKnobs } : {}), ...(o.coldOpen === false ? { coldOpen: false } : {}), 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: 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), }; diff --git a/umtool/report-to-video/clip-kit.mjs b/umtool/report-to-video/clip-kit.mjs @@ -35,7 +35,10 @@ export const QR_KEYS = Object.freeze(["scale", "quiet", "ecc", "margin", "corner export { QR_LINKS, VERTICAL_QR_CORNERS, VERTICAL_QR_KEYS, VERTICAL_QR_SIZE, verticalQrErrors }; /** The keys a clip may carry for the kit (vertical-plan.mjs reads them from the project over a take's). */ -export const CLIP_KIT_KEYS = Object.freeze(["qr", "name", "promo", "zooms"]); +export const CLIP_KIT_KEYS = Object.freeze(["qr", "name", "promo", "zooms", "coldOpen"]); + +/** A cold open's length (s): refused outside the hard bounds, noted outside the soft ones (what reads best). */ +export const COLD_OPEN = Object.freeze({ min: 1, max: 4, softMin: 1.5, softMax: 3 }); /** A clip's pinned file name in a batch (shortsBatch.mjs): at most this many characters. */ export const CLIP_NAME_MAX = 60; @@ -67,12 +70,42 @@ export function clipKitErrors(entry, where = "clip") { errors.push(...clipPromoErrors(entry.promo, `${where}.promo`)); // Its zooms (clip-zoom.mjs), against its window. errors.push(...zoomsErrors(entry.zooms, `${where}.zooms`, entry)); - if ((entry.qr !== undefined || entry.name !== undefined || entry.promo !== undefined || entry.zooms !== undefined) && entry.type !== undefined && entry.type !== "clip") { - errors.push(`${where}: qr, name, promo and zooms are a clip's`); + // Its cold open: a span of its own cut, played first. + errors.push(...coldOpenErrors(entry.coldOpen, `${where}.coldOpen`, entry)); + if ((entry.qr !== undefined || entry.name !== undefined || entry.promo !== undefined || entry.zooms !== undefined || entry.coldOpen !== undefined) && entry.type !== undefined && entry.type !== "clip") { + errors.push(`${where}: qr, name, promo, zooms and coldOpen are a clip's`); } return errors; } +/** + * Each thing wrong with a clip's `coldOpen` ([] when fine, or absent): `{from, to}`, source seconds inside the clip's + * cut (its cutStart–cutEnd, else its window), 1–4 s long -- the payoff a short or a desktop clip plays FIRST, then + * cuts to the clip's start. + */ +export function coldOpenErrors(v, where = "clip.coldOpen", entry = null) { + if (v === undefined) return []; + if (!isObj(v)) return [`${where} is {from, to}: source seconds of the clip's cut, played first`]; + const errors = []; + for (const k of Object.keys(v)) if (!["from", "to"].includes(k)) errors.push(`${where}.${k} is not a key (from, to)`); + const num = (n) => typeof n === "number" && Number.isFinite(n); + if (!num(v.from) || !num(v.to) || v.to <= v.from) return [...errors, `${where} is {from, to}, from before to (source seconds)`]; + const len = v.to - v.from; + if (len < COLD_OPEN.min - 1e-6 || len > COLD_OPEN.max + 1e-6) errors.push(`${where} is ${Math.round(len * 100) / 100} s: a cold open is ${COLD_OPEN.min}–${COLD_OPEN.max} s`); + const a = num(entry?.cutStart) ? entry.cutStart : entry?.start; + const b = num(entry?.cutEnd) ? entry.cutEnd : entry?.end; + if (num(a) && num(b) && (v.from < a - 0.02 || v.to > b + 0.02)) errors.push(`${where} (${v.from}–${v.to}) is outside the clip's cut (${a}–${b})`); + return errors; +} + +/** A NOTE for a cold open outside what reads best (1.5–3 s), or null. */ +export function coldOpenNote(entry, where) { + const v = entry?.coldOpen; + if (!isObj(v) || typeof v.from !== "number" || typeof v.to !== "number") return null; + const len = v.to - v.from; + return len < COLD_OPEN.softMin || len > COLD_OPEN.softMax ? `${where}: its cold open is ${Math.round(len * 100) / 100} s; ${COLD_OPEN.softMin}–${COLD_OPEN.softMax} s reads best` : null; +} + /** Every clip's kit errors in a manifest, and the render's QR settings' ([] when fine). */ export function validateClipKit(manifest) { // render.vertical.qr is checked with the vertical knobs (common vertical.mjs validateVerticalRender). diff --git a/umtool/report-to-video/clip-kit.test.mjs b/umtool/report-to-video/clip-kit.test.mjs @@ -68,7 +68,7 @@ test("the rules refuse what cannot be drawn, by name", () => { assert.match(clipKitErrors({ type: "clip", qr: { corner: "tl", size: 2 } }, "w01").join(), /w01\.qr\.size is not a key/); assert.match(clipKitErrors({ type: "clip", qr: "yes" }, "w01").join(), /w01\.qr is false/); assert.match(clipKitErrors({ type: "clip", name: "x".repeat(61) }, "w01").join(), /w01\.name is a file name of 1 to 60/); - assert.match(clipKitErrors({ type: "post", qr: false }, "p1").join(), /qr, name, promo and zooms are a clip's/); + assert.match(clipKitErrors({ type: "post", qr: false }, "p1").join(), /qr, name, promo, zooms and coldOpen are a clip's/); assert.match(validateClipKit({ render: { qr: { links: "channel" } }, timeline: [] }).join(), /set render\.promo\.url/); assert.deepEqual(validateClipKit({ render: { qr: { links: "channel" }, promo: { url: "https://kick.com/somechan" } }, timeline: [] }), []); // A short's code: at the top only (its captions run along the foot), a size in bounds. diff --git a/umtool/report-to-video/cold-open.test.mjs b/umtool/report-to-video/cold-open.test.mjs @@ -0,0 +1,72 @@ +// A clip's cold open (lane clip-kit, slice G): the rules, the plan (its span first, a hard cut into the clip), and the +// join -- cut from the segments, never the build's crossfade. +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { spawnSync } from "node:child_process"; +import { mkdtempSync } from "node:fs"; +import { rm } from "node:fs/promises"; +import os from "node:os"; +import path from "node:path"; + +import { coldOpenErrors, coldOpenNote } from "./clip-kit.mjs"; +import { coldOpenEntry, piecesWhole, planVerticalCut } from "./vertical-plan.mjs"; +import { assembleShort, probeSeconds } from "./reframe.mjs"; + +const clip = (o = {}) => ({ type: "clip", id: "w01", video: "v", start: 10, end: 40, cutStart: 12, cutEnd: 38, title: "T", ...o }); + +test("the rules: {from, to} inside the clip's cut, 1 to 4 s; a note outside 1.5 to 3 s", () => { + assert.deepEqual(coldOpenErrors({ from: 35, to: 37.5 }, "c", clip()), []); + const no = (v, re) => assert.match(coldOpenErrors(v, "c", clip()).join("\n"), re, JSON.stringify(v)); + no({ from: 35 }, /\{from, to\}, from before to/); + no({ from: 35, to: 35.5 }, /0\.5 s: a cold open is 1–4 s/); + no({ from: 30, to: 36 }, /6 s: a cold open is 1–4 s/); + no({ from: 38, to: 40 }, /outside the clip's cut \(12–38\)/); + no({ from: 35, to: 37, play: true }, /play is not a key/); + assert.equal(coldOpenNote(clip({ coldOpen: { from: 35, to: 37.5 } }), "w01"), null); + assert.match(coldOpenNote(clip({ coldOpen: { from: 34, to: 37.8 } }), "w01"), /3\.8 s; 1\.5–3 s reads best/); +}); + +test("the plan: the span first as <id>~co (no card, no code, its own zooms), then the clip; both joined hard", () => { + const e = clip({ coldOpen: { from: 35, to: 37.5 }, qr: { corner: "tl" }, promo: { hold: 2 }, zooms: [{ at: 20 }, { at: 35.2, hold: 0.5, ramp: 0.3 }] }); + const co = coldOpenEntry(e); + assert.equal(co.id, "w01~co"); + assert.deepEqual([co.start, co.end, co.cutStart, co.promo, co.qr, co.coldOpen], [35, 37.5, undefined, false, false, undefined]); + assert.deepEqual(co.zooms, [{ at: 35.2, hold: 0.5, ramp: 0.3 }], "only the zooms inside its span"); + const plan = planVerticalCut({ timeline: [e, clip({ id: "w02" })], items: ["w01", "w02"] }); + assert.deepEqual(plan.timeline.map((x) => x.id), ["w01~co", "w01", "w02"]); + assert.deepEqual(plan.pieces, [{ id: "w01~co", from: 0, to: null, hard: true }, { id: "w01", from: 0, to: null, hard: true }, { id: "w02", from: 0, to: null }]); + assert.equal(piecesWhole(plan.pieces), false); + // Not asked (--no-cold-open, a landscape or a reframe): the plan it always made. + const off = planVerticalCut({ timeline: [e], items: ["w01"], coldOpens: false }); + assert.deepEqual(off.pieces, [{ id: "w01", from: 0, to: null }]); + assert.equal(piecesWhole(off.pieces), true); + assert.equal(coldOpenEntry(clip()), null); +}); + +const have = ["ffmpeg", "ffprobe"].every((b) => spawnSync(b, ["-version"]).status === 0); + +test("the hard join: the pieces cut from their segments end to end -- the cold open, then the clip, no crossfade", { skip: !have && "needs ffmpeg" }, async () => { + const root = mkdtempSync(path.join(os.tmpdir(), "rtv-coldopen-")); + try { + const seg = (name, colour, d) => { + const r = spawnSync("ffmpeg", ["-v", "error", "-y", "-f", "lavfi", "-i", `color=c=${colour}:s=320x568:r=30:d=${d}`, "-f", "lavfi", "-i", `sine=frequency=440:sample_rate=48000:duration=${d}`, "-c:v", "libx264", "-preset", "ultrafast", "-c:a", "aac", "-shortest", path.join(root, name)]); + assert.equal(r.status, 0, String(r.stderr)); + }; + seg("w01~co.mp4", "white", 2); + seg("w01.mp4", "black", 3); + // The build's own joined file (a 0.4 s crossfade): never what a hard join plays. + seg("built.mp4", "gray", 4.6); + const out = path.join(root, "short.mp4"); + const r = await assembleShort({ + pieces: [{ id: "w01~co", from: 0, to: null, hard: true }, { id: "w01", from: 0, to: null, hard: true }], + segmentsDir: root, built: path.join(root, "built.mp4"), outFile: out, render: { fps: 30, vertical: { loudness: -14 } }, + }); + assert.ok(Math.abs(r.seconds - 5) < 0.1, `the two pieces end to end (${r.seconds})`); + const y = (t) => Number((/YAVG=([0-9.]+)/.exec(String(spawnSync("ffmpeg", ["-v", "error", "-ss", String(t), "-i", out, "-frames:v", "1", "-vf", "signalstats,metadata=print:file=-", "-f", "null", "-"]).stdout)) ?? [])[1]); + assert.ok(y(0.5) > 200, "the cold open first"); + assert.ok(y(3) < 40, "then the clip"); + assert.ok(Math.abs((await probeSeconds(out)) - r.seconds) < 0.01); + } finally { + await rm(root, { recursive: true, force: true }); + } +}); 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, desktopQrOf, expiringLinkNote, validateClipKit, verticalQrOf } from "./clip-kit.mjs"; +import { clipQrUrl, coldOpenNote, cornerQrOf, desktopQrOf, expiringLinkNote, validateClipKit, verticalQrOf } from "./clip-kit.mjs"; import { validatePromo } from "./promo-card.mjs"; import { validateZooms } from "./clip-zoom.mjs"; import { cardNarrationSeconds, hasNarration, narrationsOf, validateNarration } from "./narration.mjs"; @@ -508,6 +508,12 @@ export function lintManifest(manifest, { // An analysis item: a bound pace row, a number typed into words, its audio heard twice (analysis-plan.mjs). warnings.push(...analysisWarnings(manifest, { only })); + // A cold open outside what reads best (clip-kit.mjs): a note. + for (const e of manifest.timeline ?? []) { + if (only && e?.id !== only) continue; + const n = coldOpenNote(e, `timeline ${e?.id}`); + if (n) warnings.push(n); + } // The channel promo's portrait (promo-card.mjs): a picture of the project's, there. { const pf = whole?.render?.promo?.portrait?.file; diff --git a/umtool/report-to-video/reframe.mjs b/umtool/report-to-video/reframe.mjs @@ -99,7 +99,8 @@ export function builtSpans(pieces, schedule) { export async function assembleShort({ pieces, segmentsDir, built, outFile, render, schedule = null, log = () => {} }) { const target = verticalKnobs(render).loudness; - const whole = pieces.every((p) => !p.from && p.to === null); + // A hard join (a cold open into its clip: vertical-plan.mjs) is cut from the segments, never the build's crossfade. + const whole = pieces.every((p) => !p.from && p.to === null && !p.hard); let src = built; if (!whole) { src = `${outFile}.joined-${process.pid}.mp4`; diff --git a/umtool/report-to-video/vertical-plan.mjs b/umtool/report-to-video/vertical-plan.mjs @@ -17,6 +17,8 @@ // take was made, and a short is cut from the take's items as the project now // frames them. +import { zoomEnd } from "./clip-zoom.mjs"; + const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v); const num = (v) => typeof v === "number" && Number.isFinite(v); const r3 = (n) => Math.round(n * 1000) / 1000; @@ -39,7 +41,7 @@ export function beatsOf(doc) { * The keys of a clip a short reads from the PROJECT over the take's: set with `umtool set` after the take was made * (its framing, its side post, the clip kit's keys). A batch's record snapshots them (lib/report/shortsBatch.mjs). */ -export const PROJECT_KEYS = Object.freeze(["vertical", "side", "qr", "promo", "zooms"]); +export const PROJECT_KEYS = Object.freeze(["vertical", "side", "qr", "promo", "zooms", "coldOpen"]); /** The project's per-clip framing (PROJECT_KEYS) laid over a take's entry. */ export function withProjectFraming(entry, projectById) { @@ -95,7 +97,22 @@ export function cutClip(entry, a, b, id = entry.id) { * @param {{ timeline: any[], beats?: any[] | null, items?: string[] | null, schedule?: any, cuts?: Map<string, any>, * project?: any[] }} o */ -export function planVerticalCut({ timeline, beats = null, items = null, schedule = null, cuts = new Map(), project = [] }) { +/** + * A clip's COLD OPEN (lane clip-kit, slice G; clip-kit.mjs coldOpenErrors): its `coldOpen` span cut out as an entry + * of its own, `<id>~co`, played before it with a hard cut -- its own words captioned, its own sound -- and ending on + * no card, carrying no code and no zooms outside its span; null for a clip with none. + */ +export function coldOpenEntry(entry) { + const co = entry?.coldOpen; + if (entry?.type !== "clip" || !isObj(co) || !num(co.from) || !num(co.to) || co.to <= co.from) return null; + const { coldOpen: _c, promo: _p, qr: _q, zooms, ...rest } = entry; + const out = { ...cutClip(rest, co.from, co.to, `${entry.id}~co`), promo: false, qr: false }; + const inside = Array.isArray(zooms) ? zooms.filter((z) => num(z?.at) && z.at >= co.from && zoomEnd(z) <= co.to) : []; + if (inside.length) out.zooms = inside; + return out; +} + +export function planVerticalCut({ timeline, beats = null, items = null, schedule = null, cuts = new Map(), project = [], coldOpens = true }) { const projectById = new Map((project ?? []).filter((e) => typeof e?.id === "string").map((e) => [e.id, e])); const byId = new Map((timeline ?? []).filter((e) => typeof e?.id === "string").map((e) => [e.id, withProjectFraming(e, projectById)])); const out = []; @@ -114,6 +131,15 @@ export function planVerticalCut({ timeline, beats = null, items = null, schedule for (const id of items) { const e = byId.get(id); if (!e) throw new VerticalPlanError(`no item ${id} in the take`); + // Its cold open first (a hard cut into the clip: both pieces joined, not crossfaded by the build). + const co = coldOpens ? coldOpenEntry(e) : null; + if (co) { + out.push(co); + pieces.push({ id: co.id, from: 0, to: null, hard: true }); + out.push({ ...e, id: uniq(id) }); + pieces.push({ id: out[out.length - 1].id, from: 0, to: null, hard: true }); + continue; + } add({ ...e, id: uniq(id) }); } return { timeline: out, pieces }; @@ -157,8 +183,8 @@ export function planVerticalCut({ timeline, beats = null, items = null, schedule return { timeline: out, pieces }; } -/** Is every piece played whole? (Then the build's own joined file is the short.) */ -export const piecesWhole = (pieces) => pieces.every((p) => !p.from && p.to === null); +/** Is every piece played whole, none joined by a hard cut? (Then the build's own joined file is the short.) */ +export const piecesWhole = (pieces) => pieces.every((p) => !p.from && p.to === null && !p.hard); /** A short's name for its files: the reel's, else "items". */ export const shortName = ({ reel = null, name = null } = {}) => String(name ?? reel ?? "items").replace(/[^A-Za-z0-9._-]+/g, "-");