commit 66b96f1bbf2de94b9a547977465599b4db59e089 parent 36e6766e1ff06d4fb9bc849f749b2da1e5c99a37 Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st> Date: Sat, 14 Nov 2026 00:29:44 -0500 Merge lane/teaser-chrome: no instrument is drawn over an item that owns the frame -- over a teaser, the brand intro or a card the deck hides for, the diet strip, the promise clock, the goals, the streak, the peak, the shelf, the side panels and the finale pages are off from the start of its dissolve in to the frame before its dissolve out ends; the deck, dial, odometer, trail and feed keep their own slide exactly as before; a teaser that carries marks keeps its stamps, a finale page finishes its fade, and a chapter bumper after such an item plays its whole entrance; Play draws the same; a cut with no such item is unchanged Co-Authored-By: Claude <noreply@anthropic.com> Diffstat:
28 files changed, 753 insertions(+), 72 deletions(-)
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -1,6 +1,22 @@ # Changelog ## [Unreleased] +- **umtool: the diet strip, the promise clock and the other layers are no longer drawn over a teaser, the brand + intro or a full-frame card.** The deck already slid away over them, but the measure extras, the side panels, the + chapters and the finale's pages stayed on screen over the teaser's card. Now they are left out over every item that + takes the whole frame, as they already were over a video entry and an analysis item. + - Full frame: a teaser (unless it counts: marks and no dip), the brand intro, an analysis item, a video entry + (unless `deck: "shown"`), and a card, scroll, chart or ledger under `deck.overCards: "hide"` (the default). + - Those layers go at the first frame of the item's dissolve in, or, for a teaser that dips, at the frame the dip has + made black. They are back on the last frame of its dissolve out, which shows only the next clip. + - The deck, the dial, the odometer, the trail and the feed are laid as before: they keep their own slide away and + back. + - The finale's pages finish their fade out through the dissolve into the item. A teaser that carries marks keeps + its stamps. + - A chapter bumper on the clip after such an item starts once the item has gone, so its entrance plays whole. + - Play the cut hides the same layers while such an item is on screen. + - A cut with none of these items is laid exactly as before. The change is in how the overlays are laid (and, after + such an item, in a chapter's window): other cached chrome frames are reused. - **Clip windows can be asked for taller than 720, and the 720 window stays.** A `maxHeight` above 720 on fetch-windows, fetch-window or `fetch_clip` asks for a taller window, up to the new setting `clips.windowMaxHeight` (default 1080; a taller ask is held to it and the answer says so). With no `maxHeight` a diff --git a/umtool/app/api/report/chrome/preview/route.ts b/umtool/app/api/report/chrome/preview/route.ts @@ -23,6 +23,7 @@ import { counterOrder } from "umtool-report-to-video/counter"; import { cachedTakeManifest, takePlayDir, writePlayManifest } from "@/lib/report/takeManifest.mjs"; import { isTakeId } from "@/lib/report/takes.mjs"; import { stackedOn } from "umtool-report-to-video/vertical-deck"; +import { MODULES } from "umtool-report-to-video/modules"; export const dynamic = "force-dynamic"; @@ -301,6 +302,13 @@ export async function POST(request: Request) { ...(stampDoc ? { stamp: stampDoc } : {}), ...(finale ? { finale } : {}), layers, + // Each region's traits over a full-frame item (its module's `fullFrame`, full-frame.mjs): Play hides the feed, + // the stamps and the finale by them, as the build lays them. + fullFrame: Object.fromEntries( + (MODULES as readonly { region?: string; fullFrame?: Record<string, boolean> }[]) + .filter((m) => m.fullFrame && m.region) + .map((m) => [m.region, m.fullFrame]), + ), // The lead-in breath before a clip's cut (render.leadIn): the play // window's start, which the live preview maps the source through. leadIn: typeof render.leadIn === "number" ? render.leadIn : 0.4, diff --git a/umtool/components/projects/OnscreenSection.tsx b/umtool/components/projects/OnscreenSection.tsx @@ -113,6 +113,8 @@ export type DeckPreviewDoc = { verdictLabels?: Record<string, string>; /** The play layers: every module that declares `play` (the module contract) and that the cut draws, by z. */ layers?: PlayLayer[]; + /** Each region's `fullFrame` traits (its module's), for the regions that carry any: the feed's, the stamps', the finale's. */ + fullFrame?: Record<string, FullFrameTraits>; }; /** * One module's live layer (the module contract's `play`, onscreen.mjs @@ -133,7 +135,11 @@ export type PlayLayer = { src?: string; error?: string; windows?: { segment: string | null; from: number; to: number; src?: string; error?: string }[]; + /** How it is laid over a full-frame item (its module's `fullFrame`, full-frame.mjs); absent, it is off over every one. */ + fullFrame?: FullFrameTraits; }; +/** A module's `fullFrame` traits (full-frame.mjs regionSpans, layerOffOver). */ +export type FullFrameTraits = { followsDeck?: boolean; ownFade?: boolean; drawsMarks?: boolean }; /** An unsaved change to a post, as PUT /api/report/posts takes it. */ export type PostPatch = { attachTo?: string | null; hide?: boolean; thread?: boolean }; /** What each segment's panel should say right now, by entry id. */ @@ -2356,11 +2362,14 @@ export function ModuleLayers({ frame: g, t, testid = "module-layer", + off, }: { layers: PlayLayer[] | undefined; frame: DeckGeometry; t: number; testid?: string; + /** A layer not drawn now (a full-frame item on screen, full-frame.mjs layerOffOver): kept mounted, transparent. */ + off?: (layer: PlayLayer) => boolean; }) { if (!layers?.length) return null; type Row = { key: string; layer: PlayLayer; segment: string | null; src?: string; error?: string; up: boolean }; @@ -2383,7 +2392,8 @@ export function ModuleLayers({ data-play-layer={r.layer.id} data-play-layer-segment={r.segment ?? undefined} data-play-layer-up={r.up ? "1" : "0"} - style={{ opacity: r.up ? 1 : 0 }} + data-play-layer-off={off?.(r.layer) ? "1" : undefined} + style={{ opacity: r.up && !off?.(r.layer) ? 1 : 0 }} > <FeedOverlay feed={{ geometry: r.layer.geometry!, src: r.src, error: r.error }} diff --git a/umtool/components/projects/review/PlayCut.tsx b/umtool/components/projects/review/PlayCut.tsx @@ -818,8 +818,9 @@ export default function PlayCut({ data-play-state={ui.ended ? "ended" : ui.playing ? (ui.waiting ? "waiting" : "playing") : "paused"} data-play-t={String(Math.round(t * 100) / 100)} data-play-item={item?.id ?? ""} - // A video entry with the chrome off over it is on screen (video-entry.mjs): nothing of the deck shows. - data-play-chrome={videoNow?.video.noChrome ? "off" : undefined} + // A full-frame item is on screen (full-frame.mjs: a video entry with the chrome off, a teaser the deck hides + // over, the intro, an analysis item, a card under overCards "hide"): the deck is away and its layers are off. + data-play-chrome={videoNow?.video.noChrome || core.chromeOff ? "off" : undefined} data-play-compose={composeState} data-play-basic={view.basic ? "" : undefined} data-play-edges={edges.state} diff --git a/umtool/components/projects/review/playCore.tsx b/umtool/components/projects/review/playCore.tsx @@ -5,7 +5,8 @@ import { footageAt } from "@/lib/report/footage-move.mjs"; import { finaleUp, stampAt, tallyAt } from "@/lib/report/liveClock.mjs"; import { chromeTime, playPlan, skipEntries } from "@/lib/report/playCut.mjs"; import { tallyCellsFrom, VERDICTS } from "umtool-report-to-video/factcheck"; -import { DeckFrame, FeedOverlay, ModuleLayers, PostsOverlay, postsWindowAt, type DeckPreviewDoc, type Rect } from "../OnscreenSection"; +import { fullFrameItems, layerOffOver } from "umtool-report-to-video/full-frame"; +import { DeckFrame, FeedOverlay, ModuleLayers, PostsOverlay, postsWindowAt, type DeckPreviewDoc, type FullFrameTraits, type Rect } from "../OnscreenSection"; import { usePlayEngine } from "./playEngine/usePlayEngine"; import { useRenderCuts } from "./playEngine/useRenderCuts"; import type { ItemGate, MediaRef } from "./playEngine/engine"; @@ -286,6 +287,16 @@ export function usePlayCore(view: PlayViewData, { showRejected = false }: { show // it did not compose -- a placeholder that says so. const introNow = item && entry?.type === "intro" && introPage && "src" in introPage ? { item, page: introPage } : null; const placeholder = item && !postNow && !videoNow && !teaserNow && !introNow && (!item.clip || missing || broken) ? { kind: !item.clip ? "card" : "missing", item, entry } : null; + // A FULL-FRAME item on screen (full-frame.mjs: a teaser the deck hides over, the intro, an analysis item, a card + // under overCards "hide", a video entry with the chrome off): the layers that keep no time of their own are off over + // it, as the build lays their overlays with an `enable` that leaves its span out. Play cuts at mid-dissolve, so + // "over it" is while it is the item on screen. + const fullItems = useMemo(() => fullFrameItems(schedule), [schedule]); + const fullNow = item ? (fullItems.find((x) => x.id === item.id) ?? null) : null; + const chromeOff = !!fullNow; + // Each layer by its module's traits: the deck's page, the feed and the instruments keep their own slide; the + // stamps stay over a teaser with marks; the finale's pages finish their fade out. + const layerOff = useCallback((region: string, traits?: FullFrameTraits | null) => layerOffOver(fullNow, traits ?? doc?.fullFrame?.[region] ?? null, tc), [fullNow, doc?.fullFrame, tc]); // The clips' sound fades with the picture into a video entry and is off over it (its element plays its own). const duck = vstage ? vstage.duck : 1; useEffect(() => { @@ -340,7 +351,7 @@ export function usePlayCore(view: PlayViewData, { showRejected = false }: { show teaserPages, introPage, engine, onPostReady, bg, asPublished, setAsPublished, uncensored, setUncensored, // what is on screen - t, tc, item, entry, g, box, move, rect, tally, stamp, finaleNow, postsWin, missing, broken, + t, tc, item, entry, g, box, move, rect, tally, stamp, finaleNow, postsWin, missing, broken, chromeOff, layerOff, postNow, vstage, videoNow, teaserPage, teaserNow, introNow, placeholder, sideEntry, }; } @@ -357,7 +368,7 @@ const pct = (n: number, of: number) => `${(n / of) * 100}%`; * `basic`: a basic cut -- the bare footage, as the basic render cuts it. */ export function PlayStage({ core, basic = false, plainClassName }: { core: PlayCore; basic?: boolean; plainClassName?: string }) { - const { project, take, doc, g, box, rect, move, tc, t, bg, engine, postNow, entryOf, plan, videoNow, vstage, teaserNow, introNow, placeholder, teaserPage, introPage, sideEntry, item, postsWin, finaleNow, asPublished, uncensored, onPostReady } = core; + const { project, take, doc, g, box, rect, move, tc, t, bg, engine, postNow, entryOf, plan, videoNow, vstage, teaserNow, introNow, placeholder, teaserPage, introPage, sideEntry, item, postsWin, finaleNow, asPublished, uncensored, onPostReady, layerOff } = core; const { ui, rate, failed } = engine; const footageCanvas = (style: React.CSSProperties | undefined, w: number, h: number) => ( <canvas ref={engine.canvasRef} data-play-footage="" data-play-move={move ? move.segment : ""} width={w} height={h} className="absolute" style={style} /> @@ -484,13 +495,24 @@ export function PlayStage({ core, basic = false, plainClassName }: { core: PlayC {introCard} {placeholderCard} {sideNow && rect && <div className="pointer-events-none absolute" style={{ left: pct(rect.x, g.W), top: pct(rect.y, g.H), width: pct(rect.width, g.W), height: pct(rect.height, g.H) }}>{sideNow}</div>} + {/* Over a full-frame item (full-frame.mjs) a layer that keeps no time of its own is not drawn (layerOff): + kept mounted, transparent, so its page is ready and seeked when the item after it comes up. The feed + follows the deck (followsDeck), as the deck's own page does. */} {doc.feed && <FeedOverlay key={doc.feed.src ?? "none"} feed={doc.feed} frame={g} t={tc} testid="play-feed" />} - {postsWin && doc.posts && <PostsOverlay key={`${postsWin.segment}:${postsWin.src ?? "none"}`} win={postsWin} geometry={doc.posts.geometry} frame={g} t={tc} />} - {doc.stamp && <FeedOverlay key={`stamp:${doc.stamp.src ?? "none"}`} feed={doc.stamp} frame={g} t={tc} ready="stamp:ready" testid="play-stamp" name="fact-check stamps" />} + {postsWin && doc.posts && ( + <div className="pointer-events-none absolute inset-0" style={layerOff("posts") ? { opacity: 0 } : undefined} data-play-off={layerOff("posts") ? "posts" : undefined}> + <PostsOverlay key={`${postsWin.segment}:${postsWin.src ?? "none"}`} win={postsWin} geometry={doc.posts.geometry} frame={g} t={tc} /> + </div> + )} + {doc.stamp && ( + <div className="pointer-events-none absolute inset-0" style={layerOff("stamp") ? { opacity: 0 } : undefined} data-play-off={layerOff("stamp") ? "stamp" : undefined}> + <FeedOverlay key={`stamp:${doc.stamp.src ?? "none"}`} feed={doc.stamp} frame={g} t={tc} ready="stamp:ready" testid="play-stamp" name="fact-check stamps" /> + </div> + )} {/* Every module that declares `play` (chapters, then and now, the status ledger …), by z. */} - <ModuleLayers layers={doc.layers} frame={g} t={tc} testid="play-layer" /> + <ModuleLayers layers={doc.layers} frame={g} t={tc} testid="play-layer" off={(l) => layerOff(l.region, l.fullFrame ?? {})} /> {doc.finale && finaleNow && ( - <div className="pointer-events-none absolute inset-0" style={{ zIndex: 2 }} data-play-finale=""> + <div className="pointer-events-none absolute inset-0" style={{ zIndex: 2, ...(layerOff("finale") ? { opacity: 0 } : {}) }} data-play-finale=""> <FeedOverlay key={`finale:${doc.finale.src ?? "none"}`} feed={doc.finale} frame={g} t={tc} ready="finale:ready" testid="play-finale" name="finale" /> </div> )} diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -2482,7 +2482,7 @@ The panel at the foot of the frame and each clip's title (`render.chrome.deck`); | `deck.height` | 120–400 px · default 190 | `umtool look <p> deck.height=210` | | `deck.footageScale` | 0.5–1 (the footage must fit above the deck) · default 0.82 | `umtool look <p> deck.footageScale=0.8` | | `deck.background` | `panel` · `flush` · default `panel` | `umtool look <p> deck.background=flush` | -| `deck.overCards` | `hide` (the deck slides away over a card) · `show` · default `hide` | `umtool look <p> deck.overCards=show` | +| `deck.overCards` | `hide` (the deck slides away over a card, and the layers that keep no time of their own are left out over it: a full-frame item, [report-video.md](report-video.md#no-chrome-over-a-full-frame-item)) · `show` (the deck and every layer stay over it) · default `hide` | `umtool look <p> deck.overCards=show` | | `deck.title` | `{size 24–96, maxChars 10–120}` · default 54, 48 | `umtool look <p> deck.title='{"size":60}'` | | `deck.motion` | `{out 0–2, in 0–2, pip 0–3}` s · default 0.3, 0.45, 0.7 | `umtool look <p> deck.motion='{"in":0.6}'` | @@ -2566,7 +2566,7 @@ A timeline entry `{ type: "analysis", … }` (analysis-plan.mjs; [report-video.m ### Teaser -A timeline entry `{ type: "teaser", lines, … }`: a full-frame card whose lines pop in on the beat, cut in as its own segment (deck.mjs `validateTeaser`; [report-video.md](report-video.md)). +A timeline entry `{ type: "teaser", lines, … }`: a full-frame card whose lines pop in on the beat, cut in as its own segment (deck.mjs `validateTeaser`; [report-video.md](report-video.md)). Full frame: the deck, the instruments and the feed slide away over it, and every layer that keeps no time of its own -- the diet strip, the promise clock, the goals, the streak, the side panels, the chapters, the finale's pages -- is left out from its first frame (a dip's black) to the frame before its dissolve out ends ([report-video.md](report-video.md#no-chrome-over-a-full-frame-item)); its stamps stay when it carries marks; a teaser that counts (marks, no dip) keeps the deck and every layer up. | Knob | Range · default | From a terminal | |---|---|---| diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md @@ -424,9 +424,10 @@ window framed into the deck's box, a video entry is drawn over by **nothing**: n no header or date line, no QR, no rail, markers or section titles, no counters, captions, clock, thread map, watermark or any overlay layer. The build lays every chrome region (the deck's shell, the feed, the posts windows, stamps, stats, effects, the finale) with an `enable` that leaves the -entry's span out (`video-entry.mjs videoBlackouts`: from the frame the entrance's dip has made black -to its end -- mid-dissolve into the next entry, or the cut's end), and the deck hides over it as over -a teaser. Play draws it the same way. `deck: "shown"` keeps the chrome. +entry's span out (`video-entry.mjs videoBlackouts`, its share of every full-frame item's spans -- +[No chrome over a full-frame item](#no-chrome-over-a-full-frame-item): from the frame the entrance's dip +has made black to its end -- mid-dissolve into the next entry, or the cut's end), and the deck hides over +it as over a teaser. Play draws it the same way. `deck: "shown"` keeps the chrome. **The entrance** (`enter`, default `{out: 0.5, in: 0.5}`): the item before -- its picture and every overlay, and its sound -- fades to black over its last `out` seconds (the teaser's dip, with no held @@ -547,8 +548,10 @@ source file, its offset, its gain) and the encode, so an unchanged item is not e `--chrome-only` rebuilds it from the cache; a `--cut-window` preview lays it as any segment. Its page is the whole frame: **no chrome layer is laid over it** -- the deck, the instruments, the diet strip and the goal notes, the promise clock, the stamps, the effects, the chapter bands, every region -- each region's overlay leaves its -span out (`chromeBlackouts`, as a video entry's), from the first frame of its dissolve in to the end of its -dissolve out (to the cut's end when it is last). It draws in the deck's faces: a cut without `render.fontRegular` and `render.fontBold` +span out (`chromeBlackouts`, as a video entry's and a teaser's: [No chrome over a full-frame +item](#no-chrome-over-a-full-frame-item)), from the first frame of its dissolve in to the end of its +dissolve out (to the cut's end when it is last) -- a frame sooner for the layers that keep no time of their own, +the finale's pages once the dissolve in is over; Play hides those layers while it is on screen. It draws in the deck's faces: a cut without `render.fontRegular` and `render.fontBold` is refused early. No vertical form: a 9:16 cut, or `--vertical` on a landscape one, refuses it before anything is spent. Its date axis is by days alone (`trailLayout`'s `dayShare: 1`), whatever share the by-date trail gives its weights: a span's width says its days. `umtool ledger rm` refuses @@ -1841,6 +1844,44 @@ stays one line. The schedule carries each segment's `subtitleLines` beside `subt (only in two lines), the page's items carry the markup, so a frame key changes with the lines. Absent or `1`: the deck, its page and its keys are what they were. +### No chrome over a full-frame item + +An item that is the whole frame is its own picture: a **teaser** (unless it counts), the **brand intro**, an +**analysis item**, a **video entry** (unless `deck: "shown"`), and a **card** -- `card`, `scroll`, `chart`, +`ledger` -- under `deck.overCards: "hide"` (the default). The deck slides away over each (deck.mjs `hidesDeck`, the +segment's `hideDeck`), and so do the layers that follow its choreography. **Every layer that keeps no time of its +own is left out over it**: the measure extras (the diet strip, the promise clock's days-since, the goals, the +streak chain, the peak), the shelf, the posts windows, the stamps, the stats, the effects, the thread map, the +flips, the status ledger, the pair strip, the chat, the chapter bands, the finale's pages. The build lays each of +those regions with an `enable` that leaves the item's span out -- one list, `full-frame.mjs fullFrameItems`, each +region taking its share by its module's `fullFrame` traits (`regionSpans`; build-video.mjs `chromeOverlayChain`), +for the full cut, a preview, a `--cut-window` and every chunk of a chunked encode: + +| Item | Off from | Off to | +|---|---|---| +| a teaser, the intro, an analysis item, a card | the first frame of its dissolve in (0 when it is first); for a teaser that **dips**, the frame the dip has made black -- the clip before, overlays and all, fades to black first | the frame BEFORE the end of its dissolve out (that frame is the next segment's alone), or past the cut's end when it is last | +| a video entry | the frame the entrance's dip has made black (mid-dissolve for `enter: "cut"`) | mid-dissolve into the next entry, or past the cut's end | + +What a region's module says (`fullFrame` in the module contract): + +- **`followsDeck`** -- the deck's shell (title, subtitle, QR, rail, section title, counter; the stacked deck's page + too), the dial, the odometer, the trail, the feed. They hide themselves over the item and slide back after it + (deckChoreography), so they keep exactly the blackouts they had: a video entry's span and an analysis item's + (to the end of its dissolve out), nothing over a teaser, the intro or a card. +- **`ownFade`** -- the finale, the dial's finale, the diet runs. Their page fades out through the dissolve after the + run, so over an item that follows the finale they are left out only once the dissolve into it is over. +- **`drawsMarks`** -- the stamps. A teaser that carries marks keeps its stamps over it, a teaser that dips too: the + stamp is that card's own content, and its tally steps as it lands. + +**A chapter bumper** on the clip right after a full-frame item starts on the first frame after the item's span +(its entrance plays whole, never cut by the span), for its `seconds`, never past the clip. **What keeps every +layer**: a teaser that counts (marks and no dip, deck.mjs `teaserCounts`: the deck stays up so the count is seen to +step), a card under `overCards: "show"`, a video entry with `deck: "shown"`. A cut with none of these items lays +every overlay exactly as before. **Play the cut** does the same while such an item is on screen (it cuts at +mid-dissolve): each layer by the same traits (the preview's `fullFrame` map; a play layer's own `fullFrame`), kept +loaded and seeked; the deck's page, the feed and the instruments draw their own slide; `data-play-chrome="off"` on +its root. Present draws no chrome at all. + ### The video's knobs (the pipeline's side) Every knob below is a manifest key the build reads; absent, the render is @@ -3678,7 +3719,8 @@ lockup's own glyph paths (brands/archilyzer-media.json), not a font. "intro", id: "brand-intro"}`, so the build, the deck's schedule, the chapters and umtool's Play view and export all see the same first segment: the cut grows by the intro's seconds less the join, and every entry starts that much -later. The deck hides over it (it is full frame, like a teaser). It is not a +later. The deck hides over it, and no chrome layer is drawn over it (it is full frame, like a teaser: +[No chrome over a full-frame item](#no-chrome-over-a-full-frame-item)). It is not a chapter of its own: the first entry's chapter starts at 0 and takes it in (YouTube keeps no chapter under 10 s). A timeline entry of your own named `brand-intro` is refused. diff --git a/umtool/lib/report/onscreen.mjs b/umtool/lib/report/onscreen.mjs @@ -1016,7 +1016,11 @@ export async function composePlayLayers(project, variant, schedule, render, { sr const rows = await composeLayerPreviews(project, variant, schedule, mods.map((m) => m.id), render, { compose }); return rows.map((l, i) => { const m = mods[i]; - const base = { id: l.id, region: l.region, kind: l.kind ?? m.kind, z: m.z, clock: m.play.clock, ready: m.play.ready, geometry: l.geometry ?? null }; + const base = { + id: l.id, region: l.region, kind: l.kind ?? m.kind, z: m.z, clock: m.play.clock, ready: m.play.ready, geometry: l.geometry ?? null, + // How it is laid over a full-frame item (full-frame.mjs): Play hides it by the same traits the build lays it by. + ...(m.fullFrame ? { fullFrame: m.fullFrame } : {}), + }; if (Array.isArray(l.windows)) { return { ...base, diff --git a/umtool/report-to-video/README.md b/umtool/report-to-video/README.md @@ -1370,6 +1370,15 @@ trailer hit under each pop. Put it after the last clip; the ordinary crossfade joins them, and `render.endFade` — which fades the cut's last segment — now falls on the teaser. +Under the deck it is full frame: the deck slides away over it, the instruments and +the feed with it, and the layers that keep no time of their own — the measure +extras (the diet strip, the promise clock, the goals, the streak), the side +panels, the chapters, the finale's pages — are left out over it, from its first +frame (for one that dips, the frame the dip has made black) to the frame before +its dissolve out ends (`full-frame.mjs`; umtool's report-video.md, "No chrome +over a full-frame item"). Its stamps stay when it carries marks. A teaser that +counts (marks, no dip) keeps the deck up, and every layer with it. + ```jsonc { "type": "teaser", "id": "fin", "seconds": 7, "lines": ["Pirate Software", diff --git a/umtool/report-to-video/analysis-chrome-off.test.mjs b/umtool/report-to-video/analysis-chrome-off.test.mjs @@ -11,6 +11,7 @@ import { fileURLToPath } from "node:url"; import { chromeBlackouts, chromeOverlayChain } from "./build-video.mjs"; import { analysisBlackouts } from "./analysis-plan.mjs"; +import { fullFrameSpans, regionSpans } from "./full-frame.mjs"; import { deckOverlays } from "./modules/index.mjs"; import { videoBlackouts } from "./video-entry.mjs"; @@ -47,7 +48,8 @@ test("every overlay module's region is off over the analysis segment, from its f const regions = on.flatMap((m) => m.regions(SCHEDULE, { render: RENDER, outDir: "/out", frames: `/out/chrome/${m.region}-frames`, shift: 0 })); assert.ok(regions.length >= ids.length); const blackouts = chromeBlackouts(SCHEDULE); - assert.deepEqual(blackouts, [[732.6, 740.6]]); + assert.deepEqual(fullFrameSpans(SCHEDULE), [[732.6, 740.6]]); + assert.deepEqual(regionSpans(blackouts, { followsDeck: true }), [[732.6, 740.6]]); const chain = chromeOverlayChain(RENDER, regions, "[0:v]", 1, { blackouts }); const overlays = chain.chain.split(";").filter((p) => p.includes("overlay=")); assert.equal(overlays.length, regions.length); @@ -69,12 +71,17 @@ test("in a window of the cut (--cut-window, a preview) the span is shifted to th assert.equal(enabledAt(part, 2.5), true); }); -test("a cut without an analysis item: the blackouts it always had (a teaser's span is not one -- reported, unchanged)", () => { +test("a cut without an analysis item: no analysis span (a teaser that hides the deck is full frame by the same rule: teaser-chrome-off.test.mjs)", () => { const withTeaser = { ...SCHEDULE, segments: [SCHEDULE.segments[0], { ...SCHEDULE.segments[1], id: "t", type: "teaser" }] }; - assert.deepEqual(chromeBlackouts(withTeaser), videoBlackouts(withTeaser)); - assert.deepEqual(chromeBlackouts(withTeaser), []); + assert.deepEqual(videoBlackouts(withTeaser), []); assert.deepEqual(analysisBlackouts(withTeaser), []); + assert.deepEqual(fullFrameSpans(withTeaser), [[732.6, 740.6]]); + assert.deepEqual(regionSpans(chromeBlackouts(withTeaser), { followsDeck: true }), []); + assert.deepEqual(chromeBlackouts({ ...SCHEDULE, segments: [SCHEDULE.segments[0]] }), []); // An analysis item mid-cut: off from its dissolve in to the end of its dissolve out. const mid = { ...SCHEDULE, total: 760, segments: [...SCHEDULE.segments, { id: "b", type: "clip", start: 739.2, duration: 20.8, end: 760 }] }; - assert.deepEqual(chromeBlackouts(mid), [[732.6, 739.6]]); + // The deck's own regions to the end of its dissolve out, as before; every other to the frame before (that frame + // is the next clip's alone). + assert.deepEqual(regionSpans(chromeBlackouts(mid), { followsDeck: true }), [[732.6, 739.6]]); + assert.deepEqual(fullFrameSpans(mid), [[732.6, 739.5667]]); }); diff --git a/umtool/report-to-video/analysis-plan.mjs b/umtool/report-to-video/analysis-plan.mjs @@ -36,6 +36,7 @@ import { playEdges } from "./mute.mjs"; import { gapsOf } from "./gaps.mjs"; import { trailLayout, trailLine } from "./trail-plan.mjs"; import { endFadeOf, transitionOf } from "./deck.mjs"; +import { itemSpans } from "./full-frame.mjs"; /** The item's length: the silent default and ceiling (no dead air), the floor any item has, the longest audio. */ export const ANALYSIS_SECONDS = Object.freeze({ silent: 7, silentMax: 8, min: 4, audioMax: 30 }); @@ -234,20 +235,10 @@ export function analysisSeconds(entry) { /** * THE CUT SECONDS NO CHROME DRAWS OVER, for an analysis item (its page is the whole frame): each analysis segment * of the schedule as `[from, to]` cut seconds -- from the first frame of its dissolve in (its segment's start) to the - * last of its dissolve out (its end), the cut's end + 1 when it is last. The build lays every chrome region with an - * `enable` that leaves these out, as it does a video entry's (video-entry.mjs videoBlackouts). [] without one. + * last of its dissolve out (its end), the cut's end + 1 when it is last: the span the deck's own regions leave out + * (full-frame.mjs regionSpans `followsDeck`; every other region's ends a frame sooner). [] without one. */ -export function analysisBlackouts(schedule) { - const segs = schedule?.segments ?? []; - const out = []; - segs.forEach((s, i) => { - if (s?.type !== "analysis" || !Number.isFinite(Number(s.start))) return; - const end = Number.isFinite(Number(s.end)) ? Number(s.end) : Number(s.start) + Number(s.duration); - const to = i === segs.length - 1 ? Number(schedule.total ?? end) + 1 : end; - out.push([Math.round(Number(s.start) * 1e4) / 1e4, Math.round(to * 1e4) / 1e4]); - }); - return out; -} +export const analysisBlackouts = (schedule) => itemSpans(schedule, "analysis"); /** The ledger a cut's analysis reads: the variant's whole measure record (selectVariant keeps it), else the ledger. */ export const analysisLedger = (manifest) => (Array.isArray(manifest?.measureLedger) ? manifest.measureLedger : manifest?.ledger ?? []); diff --git a/umtool/report-to-video/build-video.mjs b/umtool/report-to-video/build-video.mjs @@ -155,8 +155,9 @@ import { } from "./sources.mjs"; // A clip whose media is a file beside the manifest (`src`, `cues`). import { clipLabel, createLocalMedia, hasLocalMedia, resolveManifestPath, validateLocalMedia } from "./local-media.mjs"; -import { analysisBlackouts, analysisSeconds, validateAnalysisEntries } from "./analysis-plan.mjs"; -import { blackoutEnable, validateVideoEntries, videoBlackouts, videoFit, videoLoudnessTarget, videoLead, videoMeasureFilter, videoSeconds, videoSegmentGraph, videoSegmentKey, videoSpan } from "./video-entry.mjs"; +import { analysisSeconds, validateAnalysisEntries } from "./analysis-plan.mjs"; +import { fullFrameItems, regionSpans } from "./full-frame.mjs"; +import { blackoutEnable, validateVideoEntries, videoFit, videoLoudnessTarget, videoLead, videoMeasureFilter, videoSeconds, videoSegmentGraph, videoSegmentKey, videoSpan } from "./video-entry.mjs"; import { createPostChannelResolver, resolvePostLinks } from "./post-links.mjs"; import { ensureWriteDir } from "../lib/report/storage.mjs"; // The deck (`render.chrome`): its geometry, validation and schedule are pure @@ -185,7 +186,7 @@ import { SYNC_FILE, writeSyncReport } from "./sync-report.mjs"; import { validateThreadEntries } from "./threads.mjs"; import { validateFlipEntries } from "./flips.mjs"; import { validateStatsEntries } from "./stats.mjs"; -import { deckOverlays, moduleById, placementOf } from "./modules/index.mjs"; +import { deckOverlays, moduleById, moduleOfRegion, placementOf } from "./modules/index.mjs"; import { CHAT_CUES_FILE, chatWanted } from "./chat.mjs"; import { counterOrder } from "./counter.mjs"; // The upload's text (release 28 M6): composed by code, written beside the cut. @@ -3929,8 +3930,9 @@ export function railFilterChain(rail, assets, times, render, inLabel, firstInput */ export function chromeOverlayChain(render, regions, inLabel, firstInputIdx, opts = {}) { const { outLabel = "[hfout]", final = true, blackouts = null, shift = 0 } = opts; - // The video entries' spans (video-entry.mjs videoBlackouts), cut seconds; "" with none. - const off = blackoutEnable(blackouts, shift); + // The full-frame items (chromeBlackouts, full-frame.mjs): each region's share of them, by its module's traits, + // cut seconds; "" with none. (`[a, b]` pairs: the same pairs for every region.) + const offOf = (name) => blackoutEnable(regionBlackouts(blackouts, name), shift); const inputs = []; const parts = []; let lab = inLabel; @@ -3985,7 +3987,7 @@ export function chromeOverlayChain(render, regions, inLabel, firstInputIdx, opts parts.push(`${src}format=rgba[hfa${i}]`); src = `[hfa${i}]`; } - parts.push(`${lab}${src}overlay=x=${r.x}:y=${r.y}:format=yuv444:${posts ? "eof_action=pass" : "shortest=1"}${off}${out}`); + parts.push(`${lab}${src}overlay=x=${r.x}:y=${r.y}:format=yuv444:${posts ? "eof_action=pass" : "shortest=1"}${offOf(r.name)}${out}`); lab = out; }); if (final) parts.push(`${lab}format=yuv420p[vout]`); @@ -6157,22 +6159,26 @@ async function renderDeck({ manifestPath, render, outDir, variant, schedule, fro await logRebuild(outDir, { phase: "chrome", seconds: Number(((Date.now() - tAll) / 1000).toFixed(1)), workers: pool.budget, renders: CHROME_LAYERS, layers }); } - // Over a video entry the chrome is OFF (video-entry.mjs): each region's overlay leaves its span out. + // Over a full-frame item -- a video entry, an analysis item, a teaser, the intro, a card the deck hides over -- + // the chrome is OFF (full-frame.mjs): each region's overlay leaves its span out. // Only when the cut has one, so every other cut's graph is the one it was. const blackouts = chromeBlackouts(schedule); return { regions, outLabel: "[hfout]", ...(blackouts.length ? { blackouts } : {}) }; } /** - * The cut seconds every chrome region leaves out (its overlay's `enable`): a video entry's span (video-entry.mjs - * videoBlackouts) and an analysis item's, whose page is the whole frame (analysis-plan.mjs analysisBlackouts) -- - * no layer at all over it. A cut with neither: []. + * What every chrome region's overlay `enable` leaves out: the cut's FULL-FRAME items (full-frame.mjs fullFrameItems) + * -- a video entry, an analysis item, a teaser that hides the deck, the brand intro, a card under `overCards: + * "hide"` -- each region taking its share by its module's `fullFrame` traits (chromeOverlayChain, regionSpans). A + * cut with none: []. */ -export function chromeBlackouts(schedule) { - const blackouts = videoBlackouts(schedule); - const analysisOff = analysisBlackouts(schedule); - if (analysisOff.length) blackouts.push(...analysisOff), blackouts.sort((x, y) => x[0] - y[0]); - return blackouts; +export const chromeBlackouts = (schedule) => fullFrameItems(schedule); + +/** The spans region `name` leaves out of `blackouts`: `[a, b]` pairs as given, or full-frame items by its traits. */ +export function regionBlackouts(blackouts, name) { + if (!blackouts?.length) return null; + if (Array.isArray(blackouts[0])) return blackouts; + return regionSpans(blackouts, moduleOfRegion(name)?.fullFrame ?? null); } /** diff --git a/umtool/report-to-video/chrome-story.mjs b/umtool/report-to-video/chrome-story.mjs @@ -19,6 +19,7 @@ import { deckGeometry, feedGeometry, overlayBox, pictureK } from "./deck.mjs"; import { rgba } from "./chrome-deck.mjs"; import { compileCues, cuePageHtml, dateText, esc, joinSpans, r4, segmentSpans, spanEvents, INSTANT } from "./chrome-cues.mjs"; import { CHAPTER_DEFAULTS, PAIR_DEFAULTS, STATUS_DEFAULTS } from "./modules/story-settings.mjs"; +import { fullFrameItems, regionSpans } from "./full-frame.mjs"; const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v); @@ -192,13 +193,23 @@ export function resolveChapter(render) { export function chapterWindows(schedule, render) { const C = resolveChapter(render); const at = segmentSpans(schedule); + // A clip whose start is inside a full-frame item's span (the dissolve out of a teaser, the intro, a card: no + // chrome is drawn there, full-frame.mjs): its bumper starts on the first frame after that span, so its entrance + // plays whole. None: it starts with its clip, as ever. + const fps = Number(schedule?.fps) || 30; + const off = regionSpans(fullFrameItems(schedule)); + const after = (t) => { + for (const [a, b] of off) if (t >= a && t <= b) return r4(b + 1 / fps); + return t; + }; const out = []; C.list.forEach((c, n) => { const sp = at.get(c?.at); if (!sp) return; - const to = Math.min(sp.out, sp.in + C.seconds); - if (!(to - sp.in > 0.2)) return; - const w = { segment: c.at, from: sp.in, to, n, title: c.title, subtitle: c.subtitle ?? "", date: c.date ?? null }; + const from = after(sp.in); + const to = Math.min(sp.out, from + C.seconds); + if (!(to - from > 0.2)) return; + const w = { segment: c.at, from, to, n, title: c.title, subtitle: c.subtitle ?? "", date: c.date ?? null }; // Where it stands (chapterPlacement): a lower band that would cover a post card moves into the card's free side // margin -- or, where neither margin can hold it, the cut has no bumper over that card. const place = chapterPlacement(schedule, render, w); diff --git a/umtool/report-to-video/full-frame.mjs b/umtool/report-to-video/full-frame.mjs @@ -0,0 +1,162 @@ +// full-frame.mjs — THE FULL-FRAME ITEMS: the cut seconds a chrome layer that keeps no time of its own is not drawn. +// +// An item that takes the whole frame -- a teaser, the brand intro, an analysis item, a video entry, a card +// (`card`, `scroll`, `chart`, `ledger`) under `deck.overCards: "hide"` -- is its own picture. The deck slides away +// over it (deck.mjs hidesDeck, the segment's `hideDeck`), and the layers that follow the deck's choreography go with +// it: the shell, the dial, the odometer, the trail, the feed (their module's `fullFrame.followsDeck`). The others -- +// the measure extras (the diet strip, the promise clock, the goals, the streak, the peak), the shelf, the stamps, +// the side panels, the chapters, the posts windows, the finale's pages -- keep no such time, so the build lays each +// with an `enable` that leaves these items' spans out (build-video.mjs chromeOverlayChain, by `regionSpans`), and +// Play hides them while such an item is on screen (playCore.tsx, `layerOffOver`). One list (`fullFrameItems`), and +// what each region takes of it (`regionSpans`, by its module's `fullFrame` traits): +// +// every region but those below: every item's span -- +// a video entry that hides the chrome (`noChrome`; `deck: "shown"` keeps it): from the frame the dip into it has +// made black (its start + the dissolve − a frame; mid-dissolve for `enter: "cut"`) to mid-dissolve out of it, +// or past the cut's end when it is last -- as it always was; +// every other item: from the first frame its picture is in -- its dissolve's first frame, or, for a teaser that +// dips, the frame the dip has made black (the dip fades the whole frame, overlays with it) -- to the frame +// BEFORE the end of its dissolve out (that frame is the next segment's alone), or past the cut's end when it is +// last. A first item is off from 0. +// `followsDeck` (shell, dial, odometer, trail, feed): only a video entry's and an analysis item's spans, as the +// build laid them before (an analysis item's to the end of its dissolve out) -- over a teaser, the intro or a +// card their own slide away and back is kept. +// `ownFade` (the finale, the dial's finale, the diet runs): an item's span starts once its dissolve in is over, so +// the page's own fade out through that dissolve plays whole (a video entry's as above). +// `drawsMarks` (the stamps): not over a teaser that carries marks -- the stamp is that card's own content. +// +// A segment that keeps the deck up is not full frame: a teaser that COUNTS (deck.mjs teaserCounts: marks, no dip), +// a card under `overCards: "show"`, a video entry with `deck: "shown"`. A cut with no full-frame item: [] -- and +// every graph is the one it was. +// +// A LEAF with no imports: the build, umtool's server and its client (Play) read the same rule. + +const fin = (v) => typeof v === "number" && Number.isFinite(v); +const r4 = (v) => Math.round(v * 1e4) / 1e4; + +/** A module's `fullFrame` traits (contract.mjs): how its region is laid over a full-frame item. */ +export const FULL_FRAME_TRAITS = Object.freeze(["followsDeck", "ownFade", "drawsMarks"]); + +/** + * Is this schedule segment full frame? A video entry by its `noChrome`, an analysis item always, anything else by + * its `hideDeck`. + * + * @param {{ type?: string, hideDeck?: boolean, noChrome?: boolean } | null | undefined} seg + */ +export function fullFrameSegment(seg) { + if (!seg) return false; + if (seg.type === "video") return !!seg.noChrome; + if (seg.type === "analysis") return true; + return !!seg.hideDeck; +} + +/** + * @typedef {{ id: string, type: string, kind: "video" | "analysis" | "page", index: number, start: number, + * end: number, last: boolean, marks: boolean, fps: number, D: number, span: [number, number] }} FullFrameItem + * `span` is the item's span as the build laid it before the measure extras were left out (a video entry's + * rule; any other's from its first frame to the END of its dissolve out, inclusive). + */ + +/** + * The schedule's full-frame items, in order, each with its span and what a region's traits read of it. + * + * @param {{ segments?: any[], total?: number, fps?: number, transition?: number } | null | undefined} schedule + * @returns {FullFrameItem[]} + */ +export function fullFrameItems(schedule) { + const segs = schedule?.segments ?? []; + const D = Number(schedule?.transition ?? 0) || 0; + const fps = Number(schedule?.fps ?? 30) || 30; + /** @type {FullFrameItem[]} */ + const out = []; + segs.forEach((s, i) => { + if (!fullFrameSegment(s) || !fin(Number(s?.start))) return; + const start = Number(s.start); + const end = fin(Number(s.end)) ? Number(s.end) : start + Number(s.duration); + const last = i === segs.length - 1; + const kind = s.type === "video" ? "video" : s.type === "analysis" ? "analysis" : "page"; + let a; + let b; + if (kind === "video") { + a = i > 0 && s.enter ? start + D - 1 / fps : i > 0 ? start + D / 2 : 0; + b = last ? Number(schedule.total ?? end) + 1 : end - D / 2; + } else { + a = i === 0 ? 0 : s.dip ? start + D - 1 / fps : start; + b = last ? Number(schedule.total ?? end) + 1 : end; + } + out.push({ + id: s.id, type: s.type, kind, index: i, start, end, last, + marks: !!(s.claim || (Array.isArray(s.claims) && s.claims.length)), + fps, D, span: [Math.max(0, r4(a)), r4(b)], + }); + }); + return out; +} + +/** + * The spans one region leaves out, `[from, to]` cut seconds by start, for its module's `fullFrame` traits (none: + * every region but the deck's own and the finale's). Overlapping pairs (two full-frame items back to back) are kept as + * they are: `not(between(…)+between(…))` is off over their union. [] without one. + * + * @param {FullFrameItem[]} items + * @param {{ followsDeck?: boolean, ownFade?: boolean, drawsMarks?: boolean } | null | undefined} [traits] + * @returns {Array<[number, number]>} + */ +export function regionSpans(items, traits = {}) { + const t = traits ?? {}; + /** @type {Array<[number, number]>} */ + const out = []; + for (const it of items ?? []) { + if (t.followsDeck) { + if (it.kind !== "page") out.push([it.span[0], it.span[1]]); + continue; + } + if (t.drawsMarks && it.type === "teaser" && it.marks) continue; + let [a, b] = it.span; + // The frame at the end of its dissolve out is the next segment's alone: the layer is drawn on it. + if (it.kind !== "video" && !it.last) b = r4(b - 1 / it.fps); + // Its own fade out through the dissolve in plays whole. + if (t.ownFade && it.kind !== "video" && it.index > 0) a = Math.max(a, r4(it.start + it.D)); + if (b >= a) out.push([a, b]); + } + return out.sort((x, y) => x[0] - y[0]); +} + +/** + * The spans a region with no traits leaves out (the measure extras, the stamps, every side panel): `regionSpans` + * with none. `only` narrows the items (video-entry.mjs videoBlackouts: the video entries' alone). + * + * @param {{ segments?: any[], total?: number, fps?: number, transition?: number } | null | undefined} schedule + * @param {{ only?: (item: FullFrameItem) => boolean }} [opts] + */ +export function fullFrameSpans(schedule, { only = () => true } = {}) { + return regionSpans(fullFrameItems(schedule).filter(only)); +} + +/** The items' spans as the build laid them before (`span`), of one kind: a video entry's, an analysis item's. */ +export function itemSpans(schedule, kind) { + return fullFrameItems(schedule).filter((it) => it.kind === kind).map((it) => /** @type {[number, number]} */ ([it.span[0], it.span[1]])); +} + +/** + * PLAY: is a layer with these traits hidden while `item` (a full-frame item, or null) is the one on screen, at cut + * second `tc`? Play cuts at mid-dissolve, so "over it" is while it is on screen. A `followsDeck` layer hides itself; + * the stamps stay over a teaser with marks; an `ownFade` page goes once the dissolve into the item is over. + * + * @param {FullFrameItem | null | undefined} item + * @param {{ followsDeck?: boolean, ownFade?: boolean, drawsMarks?: boolean } | null | undefined} traits + * @param {number} tc + */ +export function layerOffOver(item, traits, tc) { + if (!item) return false; + const t = traits ?? {}; + if (t.followsDeck) return false; + if (t.drawsMarks && item.type === "teaser" && item.marks) return false; + if (t.ownFade && item.kind !== "video" && item.index > 0) return tc >= item.start + item.D; + return true; +} + +/** The ids of the schedule's full-frame segments. */ +export function fullFrameIds(schedule) { + return new Set((schedule?.segments ?? []).filter(fullFrameSegment).map((s) => s.id)); +} diff --git a/umtool/report-to-video/modules/contract.mjs b/umtool/report-to-video/modules/contract.mjs @@ -32,6 +32,8 @@ // imported by the build, the composer and umtool alike. /** What a module is: how its pixels reach the cut. */ +import { FULL_FRAME_TRAITS } from "../full-frame.mjs"; + export const MODULE_KINDS = Object.freeze([ // A page over the whole cut (or a window of it), laid by its region at frame 1. "overlay-whole", @@ -117,6 +119,7 @@ const SPEC = Object.freeze({ names: "a function ({ preview, window, entry, suffix }) => { project, stem }", entry: "a function (manifest, segment) => the timeline entry a segment module draws", seconds: "a function (entry, transition, fps) => how long a segment module's page is", + fullFrame: "how its region is laid over a full-frame item (full-frame.mjs): { followsDeck?, ownFade?, drawsMarks? } -- each true; absent, it is off over every one", }); /** @@ -185,6 +188,13 @@ export function defineModule(def) { if (def.docs !== undefined && !(isObj(def.docs) && typeof def.docs.heading === "string")) throw new Error(`${where}: docs must be ${SPEC.docs}`); if (def.vertical !== undefined && !(isObj(def.vertical) && VERTICAL_SLOTS.includes(def.vertical.slot))) throw new Error(`${where}: vertical must be ${SPEC.vertical}`); if (def.workers !== undefined && !["wide", "narrow"].includes(def.workers)) throw new Error(`${where}: workers must be ${SPEC.workers}`); + if (def.fullFrame !== undefined) { + const f = def.fullFrame; + if (!isObj(f) || !Object.keys(f).length || Object.entries(f).some(([k, v]) => !FULL_FRAME_TRAITS.includes(k) || v !== true)) { + throw new Error(`${where}: fullFrame must be ${SPEC.fullFrame}`); + } + if (!(def.kind === "overlay-whole" || def.kind === "overlay-window")) throw new Error(`${where}: only an overlay is laid over a full-frame item`); + } return Object.freeze({ ...def }); } diff --git a/umtool/report-to-video/modules/dial-finale.mjs b/umtool/report-to-video/modules/dial-finale.mjs @@ -35,6 +35,8 @@ export default defineModule({ ], }, region: "dial-finale", + // Out through the finale's dissolve, as the finale: full-frame.mjs `ownFade`. + fullFrame: { ownFade: true }, workers: "narrow", noun: "the dial finale's", on: (schedule, render) => !!schedule?.finale && hasMeasure(schedule) && wanted(render), diff --git a/umtool/report-to-video/modules/dial.mjs b/umtool/report-to-video/modules/dial.mjs @@ -70,6 +70,8 @@ export default defineModule({ ], }, region: "dial", + // It comes and goes with the deck (chrome-instruments.mjs): full-frame.mjs `followsDeck`. + fullFrame: { followsDeck: true }, workers: "narrow", noun: "the dial's", on: (schedule, render) => hasMeasure(schedule) && !!resolveDial(render), diff --git a/umtool/report-to-video/modules/feed.mjs b/umtool/report-to-video/modules/feed.mjs @@ -42,6 +42,8 @@ export default defineModule({ ], }, region: "feed", + // The column slides with the deck's visibility (chrome-feed.mjs): full-frame.mjs `followsDeck`. + fullFrame: { followsDeck: true }, workers: "wide", noun: "the feed's", on: (schedule) => schedule?.layout === "feed", diff --git a/umtool/report-to-video/modules/finale.mjs b/umtool/report-to-video/modules/finale.mjs @@ -47,6 +47,9 @@ export default defineModule({ ], }, region: "finale", + // Its page fades out through the dissolve after the run: over a full-frame item it is left out only once that + // dissolve is over (full-frame.mjs `ownFade`). + fullFrame: { ownFade: true }, workers: "narrow", noun: "the finale's", on: (schedule) => !!schedule?.finale, diff --git a/umtool/report-to-video/modules/odometer.mjs b/umtool/report-to-video/modules/odometer.mjs @@ -44,6 +44,8 @@ export default defineModule({ ], }, region: "odometer", + // It comes and goes with the deck (chrome-instruments.mjs): full-frame.mjs `followsDeck`. + fullFrame: { followsDeck: true }, workers: "narrow", noun: "the odometer's", on: (schedule, render) => hasMeasure(schedule) && !!resolveOdometer(render), diff --git a/umtool/report-to-video/modules/runs-finale.mjs b/umtool/report-to-video/modules/runs-finale.mjs @@ -32,6 +32,8 @@ export default defineModule({ ], }, region: "runs-finale", + // In the finale's page, out with it: full-frame.mjs `ownFade`. + fullFrame: { ownFade: true }, workers: "narrow", noun: "the finale's diet runs'", on: drawn, diff --git a/umtool/report-to-video/modules/shell.mjs b/umtool/report-to-video/modules/shell.mjs @@ -48,12 +48,15 @@ export default defineModule({ ["`deck.height`", "120–400 px · default 190", "`umtool look <p> deck.height=210`"], ["`deck.footageScale`", "0.5–1 (the footage must fit above the deck) · default 0.82", "`umtool look <p> deck.footageScale=0.8`"], ["`deck.background`", "`panel` · `flush` · default `panel`", "`umtool look <p> deck.background=flush`"], - ["`deck.overCards`", "`hide` (the deck slides away over a card) · `show` · default `hide`", "`umtool look <p> deck.overCards=show`"], + ["`deck.overCards`", "`hide` (the deck slides away over a card, and the layers that keep no time of their own are left out over it: a full-frame item, [report-video.md](report-video.md#no-chrome-over-a-full-frame-item)) · `show` (the deck and every layer stay over it) · default `hide`", "`umtool look <p> deck.overCards=show`"], ["`deck.title`", "`{size 24–96, maxChars 10–120}` · default 54, 48", "`umtool look <p> deck.title='{\"size\":60}'`"], ["`deck.motion`", "`{out 0–2, in 0–2, pip 0–3}` s · default 0.3, 0.45, 0.7", "`umtool look <p> deck.motion='{\"in\":0.6}'`"], ], }, region: "deck", + // It slides away over a full-frame item and back on its own (deckChoreography): only a video entry's and an + // analysis item's spans are left out of it (full-frame.mjs). + fullFrame: { followsDeck: true }, workers: "wide", noun: "the deck's", on: () => true, diff --git a/umtool/report-to-video/modules/stamp.mjs b/umtool/report-to-video/modules/stamp.mjs @@ -43,6 +43,8 @@ export default defineModule({ ], }, region: "stamp", + // A teaser that carries marks keeps its stamps (they are the card's own content): full-frame.mjs `drawsMarks`. + fullFrame: { drawsMarks: true }, workers: "narrow", noun: "the stamps'", on: (schedule, render) => stampsDrawn(schedule, render), diff --git a/umtool/report-to-video/modules/teaser.mjs b/umtool/report-to-video/modules/teaser.mjs @@ -19,7 +19,7 @@ export default defineModule({ validate: (_value, { manifest }) => validateTeasers(manifest), docs: { heading: "Teaser", - intro: "A timeline entry `{ type: \"teaser\", lines, … }`: a full-frame card whose lines pop in on the beat, cut in as its own segment (deck.mjs `validateTeaser`; [report-video.md](report-video.md)).", + intro: "A timeline entry `{ type: \"teaser\", lines, … }`: a full-frame card whose lines pop in on the beat, cut in as its own segment (deck.mjs `validateTeaser`; [report-video.md](report-video.md)). Full frame: the deck, the instruments and the feed slide away over it, and every layer that keeps no time of its own -- the diet strip, the promise clock, the goals, the streak, the side panels, the chapters, the finale's pages -- is left out from its first frame (a dip's black) to the frame before its dissolve out ends ([report-video.md](report-video.md#no-chrome-over-a-full-frame-item)); its stamps stay when it carries marks; a teaser that counts (marks, no dip) keeps the deck and every layer up.", rows: [ ["a `teaser` entry", "`lines` (each `{text, role?, hold?, …}`), `tail?`, `dip?`", "`umtool timeline <p> insert …`"], ], diff --git a/umtool/report-to-video/modules/trail.mjs b/umtool/report-to-video/modules/trail.mjs @@ -50,6 +50,8 @@ export default defineModule({ ], }, region: "trail", + // It comes and goes with the deck (chrome-instruments.mjs): full-frame.mjs `followsDeck`. + fullFrame: { followsDeck: true }, workers: "narrow", noun: "the trail's", on: (schedule, render) => hasMeasure(schedule) && !!resolveTrail(render), diff --git a/umtool/report-to-video/package.json b/umtool/report-to-video/package.json @@ -19,6 +19,7 @@ "exports": { "./attribution": "./attribution.mjs", "./video-entry": "./video-entry.mjs", + "./full-frame": "./full-frame.mjs", "./analysis-plan": "./analysis-plan.mjs", "./site-links": "./site-links.mjs", "./brand": "./brand.mjs", diff --git a/umtool/report-to-video/teaser-chrome-off.test.mjs b/umtool/report-to-video/teaser-chrome-off.test.mjs @@ -0,0 +1,371 @@ +// NO CHROME OVER A TEASER, OR ANY OTHER FULL-FRAME ITEM (lane teaser-chrome, 13 Nov: the diet strip and the promise +// clock were drawn over a teaser -- the leak the analysis item had, analysis-chrome-off.test.mjs). Every overlay +// module that keeps no time of its own (the measure extras, the stamps, the side panels, the chapters, the finale's +// pages) gets an `enable` that leaves each full-frame item's span out (full-frame.mjs fullFrameItems / regionSpans, +// build-video.mjs chromeOverlayChain): a teaser that hides the deck, the brand intro, a card under `overCards: +// "hide"`, as the video entry and the analysis item already were. The regions that follow the deck's choreography +// (`followsDeck`: the shell, the dial, the odometer, the trail, the feed) keep exactly the blackouts they had -- +// their own slide away and back over a teaser is kept. A teaser that counts, a card under `overCards: "show"` and a +// video entry with `deck: "shown"` keep their chrome; a cut with none of them lays exactly the graph it did. +import assert from "node:assert/strict"; +import { spawnSync } from "node:child_process"; +import { mkdirSync, mkdtempSync, readFileSync, rmSync } from "node:fs"; +import { tmpdir } from "node:os"; +import path from "node:path"; +import test from "node:test"; +import { fileURLToPath } from "node:url"; + +import { chromeBlackouts, chromeOverlayChain, xfadeConcatArgs } from "./build-video.mjs"; +import { analysisBlackouts } from "./analysis-plan.mjs"; +import { chapterWindows } from "./chrome-story.mjs"; +import { deckSchedule, estimateSchedule, scheduleFrom } from "./deck.mjs"; +import { fullFrameIds, fullFrameItems, fullFrameSegment, fullFrameSpans, layerOffOver, regionSpans } from "./full-frame.mjs"; +import { deckOverlays, moduleOfRegion } from "./modules/index.mjs"; +import { blackoutEnable, videoBlackouts } from "./video-entry.mjs"; + +const HERE = path.dirname(fileURLToPath(import.meta.url)); +const MEASURE = JSON.parse(readFileSync(path.join(HERE, "fixtures/measure-extras/measure.json"), "utf8")); +const RENDER = { + width: 1920, height: 1080, fps: 30, + palette: { bg: "#0F1312", fg: "#EDF0EC", muted: "#98A29B", accent: "#22AB83", amber: "#E8A33F" }, + chrome: { engine: "hyperframes", layout: "deck", deck: { dial: true, odometer: true, trail: true, diet: {}, goals: {}, promise: {}, peak: true, streak: {} } }, +}; +const D = 0.4; +const FPS = 30; +// A clip to 400.4 s, a teaser 400.0–406.4 (dissolved in and out), the clips after it to 739.6. +const SCHEDULE = { + kind: "deck", fps: FPS, total: 739.6, transition: D, + segments: [ + { id: "a", type: "clip", start: 0, duration: 400.4, end: 400.4, hideDeck: false }, + { id: "t", type: "teaser", start: 400, duration: 6.4, end: 406.4, hideDeck: true }, + { id: "b", type: "clip", start: 406, duration: 333.6, end: 739.6, hideDeck: false }, + ], + measure: MEASURE, +}; + +/** Each overlay's enable, as a predicate of cut second t (blackoutEnable's `not(between(...)+...)`). */ +function enabledAt(part, t) { + const m = /enable='not\((.*)\)'/.exec(part); + if (!m) return true; + const spans = [...m[1].matchAll(/between\(t,(-?[\d.]+),(-?[\d.]+)\)/g)].map((x) => [Number(x[1]), Number(x[2])]); + return !spans.some(([a, b]) => t >= a && t <= b); +} + +/** Every overlay part of the full cut's chain for `schedule`, one per region, with the module that laid it. */ +function overlayParts(schedule) { + const on = deckOverlays().filter((m) => m.on(schedule, RENDER)); + const regions = on.flatMap((m) => m.regions(schedule, { render: RENDER, outDir: "/out", frames: `/out/chrome/${m.region}-frames`, shift: 0 }).map((r) => ({ ...r, mod: m.id }))); + const blackouts = chromeBlackouts(schedule); + const chain = chromeOverlayChain(RENDER, regions, "[0:v]", 1, { blackouts }); + const parts = chain.chain.split(";").filter((p) => p.includes("overlay=")); + assert.equal(parts.length, regions.length); + return { ids: on.map((m) => m.id), parts: parts.map((p, i) => ({ part: p, mod: regions[i].mod })), blackouts }; +} + +/** Every frame from `a` to `b` cut seconds (inclusive), as seconds. */ +const frames = (a, b) => { + const out = []; + for (let f = Math.round(a * FPS); f <= Math.round(b * FPS); f += 1) out.push(f / FPS); + return out; +}; + +const END = Math.round((406.4 - 1 / FPS) * 1e4) / 1e4; // the frame before the end of its dissolve out + +// THE LEAKING LAYERS, one test each: the measure extras (the diet strip, the promise clock, the goals, the streak, +// the peak) -- off from the teaser's first frame to the frame before its dissolve out ends. +{ + const { ids } = overlayParts(SCHEDULE); + for (const id of ["diet", "promise", "goals", "streak", "peak"]) { + test(`over a teaser: ${id}'s region is off from the teaser's first frame to its last, and only there`, () => { + assert.ok(ids.includes(id), `${id} is laid (${ids.join(", ")})`); + const { parts } = overlayParts(SCHEDULE); + assert.deepEqual(fullFrameSpans(SCHEDULE), [[400, END]]); + const mine = parts.filter((p) => p.mod === id); + assert.ok(mine.length >= 1); + for (const { part } of mine) { + // Its dissolve in (400.0–400.4), its page, its dissolve out (406.0–406.4) but its last frame. + for (const t of frames(400, END)) assert.equal(enabledAt(part, t), false, `${id} at ${t}`); + assert.equal(enabledAt(part, 400 - 1 / FPS), true, `${id} the frame before`); + // The frame at 406.4 is the next clip's alone: the layer is on it. + assert.equal(enabledAt(part, 406.4), true, `${id} the end frame`); + assert.equal(enabledAt(part, 100), true); + } + }); + } + // THE DECK'S OWN REGIONS keep their slide: the enable main laid (none over a teaser), byte for byte. + for (const id of ["shell", "dial", "odometer", "trail"]) { + test(`over a teaser: ${id} follows the deck -- no enable of its own, as before`, () => { + assert.ok(ids.includes(id)); + for (const { part } of overlayParts(SCHEDULE).parts.filter((p) => p.mod === id)) assert.doesNotMatch(part, /enable=/); + }); + } +} + +test("a teaser that dips: off from the frame the dip has made black (the clip's last) to the frame before its dissolve out ends", () => { + const sch = { ...SCHEDULE, segments: SCHEDULE.segments.map((s) => (s.id === "t" ? { ...s, dip: { fade: 1, black: 0.5 } } : s)) }; + const [[a, b]] = fullFrameSpans(sch); + assert.equal(a, Math.round((400 + D - 1 / FPS) * 1e4) / 1e4); + assert.equal(b, END); + // The dip fades the whole frame, overlays with it, until then: the chrome is there to fade. + const { parts } = overlayParts(sch); + for (const { part, mod } of parts) { + if (["shell", "dial", "odometer", "trail"].includes(mod)) continue; + assert.equal(enabledAt(part, 400.3), true, mod); + for (const t of frames(400.4, END)) assert.equal(enabledAt(part, t), false, `${mod} at ${t}`); + } +}); + +test("a teaser at the very start (before the deck is up): off from 0", () => { + const sch = { + ...SCHEDULE, total: 339.6, + segments: [{ id: "t", type: "teaser", start: 0, duration: 6.4, end: 6.4, hideDeck: true }, { id: "b", type: "clip", start: 6, duration: 333.6, end: 339.6 }], + }; + assert.deepEqual(fullFrameSpans(sch), [[0, Math.round((6.4 - 1 / FPS) * 1e4) / 1e4]]); +}); + +test("back-to-back teasers: off over both and the dissolve between them; a last one to past the cut's end", () => { + const sch = { + ...SCHEDULE, total: 412.4, + segments: [ + SCHEDULE.segments[0], + { id: "t1", type: "teaser", start: 400, duration: 6.4, end: 6.4 + 400, hideDeck: true }, + { id: "t2", type: "teaser", start: 406, duration: 6.4, end: 412.4, hideDeck: true }, + ], + }; + assert.deepEqual(fullFrameSpans(sch), [[400, END], [406, 413.4]]); + const { parts } = overlayParts(sch); + for (const { part, mod } of parts) { + if (["shell", "dial", "odometer", "trail"].includes(mod)) continue; + for (const t of frames(400, 412.4)) assert.equal(enabledAt(part, t), false, `${mod} at ${t}`); + assert.equal(enabledAt(part, 400 - 1 / FPS), true); + } +}); + +test("in a window of the cut (--cut-window, a preview, a chunk) the span is shifted to the window's clock; a span before it is negative", () => { + const regions = deckOverlays().filter((m) => m.id === "diet").flatMap((m) => m.regions(SCHEDULE, { render: RENDER, outDir: "/out", frames: "/f" })); + const chain = chromeOverlayChain(RENDER, regions, "[0:v]", 1, { blackouts: chromeBlackouts(SCHEDULE), shift: 398 }); + const part = chain.chain.split(";").find((p) => p.includes("overlay=")); + assert.equal(enabledAt(part, 2), false); + assert.equal(enabledAt(part, 1.9), true); + assert.equal(enabledAt(part, 8.4), true); + // A window that starts after the teaser: its span is in the window's past. + const later = chromeOverlayChain(RENDER, regions, "[0:v]", 1, { blackouts: chromeBlackouts(SCHEDULE), shift: 410 }); + const lp = later.chain.split(";").find((p) => p.includes("overlay=")); + assert.match(lp, /between\(t,-10,-3\.6333\)/); + assert.equal(enabledAt(lp, 0), true); +}); + +// ---- the traits: the finale's fade out, the stamps over a card with marks ---------------------------------------- + +test("ownFade (the finale's pages): over a teaser it is left out only once the dissolve into it is over", () => { + const items = fullFrameItems(SCHEDULE); + assert.deepEqual(regionSpans(items, { ownFade: true }), [[400.4, END]]); + for (const name of ["finale", "dial-finale", "runs-finale"]) assert.equal(moduleOfRegion(name)?.fullFrame?.ownFade, true, name); + const chain = chromeOverlayChain(RENDER, [{ name: "finale", frames: "/f/finale", x: 0, y: 0, offset: 390 }], "[0:v]", 1, { blackouts: items }); + const part = chain.chain.split(";").find((p) => p.includes("overlay=")); + for (const t of frames(400, 400.4 - 1 / FPS)) assert.equal(enabledAt(part, t), true, `the fade out at ${t}`); + assert.equal(enabledAt(part, 400.4), false); +}); + +test("drawsMarks (the stamps): a teaser that dips and carries marks keeps its stamps; the other layers go", () => { + const sch = { ...SCHEDULE, segments: SCHEDULE.segments.map((s) => (s.id === "t" ? { ...s, dip: { fade: 1, black: 0.5 }, claim: { id: "t", verdict: "L" } } : s)) }; + const items = fullFrameItems(sch); + assert.equal(items[0].marks, true); + assert.deepEqual(regionSpans(items, { drawsMarks: true }), []); + const chain = chromeOverlayChain(RENDER, [{ name: "stamp", frames: "/f/stamp", x: 0, y: 0 }, { name: "diet", frames: "/f/diet", x: 0, y: 0 }], "[0:v]", 1, { blackouts: items }); + const [stamp, diet] = chain.chain.split(";").filter((p) => p.includes("overlay=")); + assert.doesNotMatch(stamp, /enable=/); + assert.equal(enabledAt(diet, 403), false); + // A teaser without marks: the stamps' region is off over it as any other. + assert.deepEqual(regionSpans(fullFrameItems(SCHEDULE), { drawsMarks: true }), [[400, END]]); +}); + +test("a chapter bumper on the clip after a full-frame item starts when the item's span ends, its entrance whole", () => { + const r = { ...RENDER, chrome: { ...RENDER.chrome, chapter: { list: [{ at: "b", title: "Part two" }] } } }; + const [w] = chapterWindows(SCHEDULE, r); + assert.equal(w.segment, "b"); + assert.equal(w.from, 406.4); + assert.equal(w.to, 409.4); + // After a clip: with its clip, as ever. + const clips = { ...SCHEDULE, segments: SCHEDULE.segments.map((s) => (s.id === "t" ? { ...s, type: "clip", hideDeck: false } : s)) }; + assert.equal(chapterWindows(clips, r)[0].from, 406); +}); + +test("Play: a layer is off while a full-frame item is on screen, by the same traits", () => { + const [it] = fullFrameItems(SCHEDULE); + assert.equal(layerOffOver(it, null, 403), true); + assert.equal(layerOffOver(it, { followsDeck: true }, 403), false); + assert.equal(layerOffOver(it, { ownFade: true }, 400.3), false); + assert.equal(layerOffOver(it, { ownFade: true }, 400.4), true); + assert.equal(layerOffOver(it, { drawsMarks: true }, 403), true); + assert.equal(layerOffOver({ ...it, marks: true }, { drawsMarks: true }, 403), false); + assert.equal(layerOffOver(null, null, 403), false); +}); + +// ---- which segments are full frame: the deck's own rule (deck.mjs hidesDeck), from real schedules --------------- + +const card = (extra = {}) => ({ type: "teaser", id: "tz", seconds: 5, lines: [{ text: "A line", role: "kicker" }], ...extra }); +const manifestWith = (mid, render = {}) => ({ + provenance: {}, posts: [], + render: { width: 1920, height: 1080, fps: 30, transition: 0.5, chrome: { engine: "hyperframes", layout: "deck", deck: { counter: { series: [{ id: "L", label: "L", color: "#5b9bd5" }] } } }, ...render }, + timeline: [ + { type: "clip", id: "c1", video: "v1", start: 0, end: 10 }, + mid, + { type: "clip", id: "c2", video: "v2", start: 0, end: 10 }, + ], +}); +const less = (v) => Math.round((v - 1 / 30) * 1e4) / 1e4; + +test("a teaser that hides the deck is full frame; a teaser that COUNTS keeps the deck, and every layer with it", () => { + const plain = estimateSchedule(manifestWith(card())); + const seg = plain.segments[1]; + assert.equal(seg.hideDeck, true); + assert.equal(fullFrameSegment(seg), true); + assert.deepEqual(fullFrameSpans(plain), [[seg.start, less(seg.end)]]); + assert.deepEqual([...fullFrameIds(plain)], ["tz"]); + const counts = estimateSchedule(manifestWith(card({ claim: { id: "tz", verdict: "L", at: 1 } }))); + assert.equal(counts.segments[1].hideDeck, false); + assert.deepEqual(chromeBlackouts(counts), []); + assert.equal(fullFrameIds(counts).size, 0); +}); + +test("a card under overCards: hide (the default) is full frame; under overCards: show it keeps its chrome", () => { + const k = { type: "card", id: "k1", seconds: 3, heading: "Part two" }; + const hide = estimateSchedule(manifestWith(k)); + assert.equal(hide.segments[1].hideDeck, true); + assert.deepEqual(fullFrameSpans(hide), [[hide.segments[1].start, less(hide.segments[1].end)]]); + const m = manifestWith(k); + m.render.chrome.deck.overCards = "show"; + assert.deepEqual(chromeBlackouts(estimateSchedule(m)), []); +}); + +test("the brand intro (the first segment, full frame): off from 0 to the frame before its dissolve into the first entry ends", () => { + const render = { width: 1920, height: 1080, fps: 30, chrome: { engine: "hyperframes", layout: "deck", deck: {} } }; + const entries = [{ type: "intro", id: "brand-intro" }, { type: "clip", id: "c1", video: "v1", start: 0, end: 10 }]; + const doc = deckSchedule({ entries, durs: [4.18, 10], D: 0.5, render }); + assert.equal(doc.segments[0].hideDeck, true); + assert.deepEqual(fullFrameSpans(doc), [[0, less(doc.segments[0].end)]]); + assert.deepEqual(regionSpans(chromeBlackouts(doc), { followsDeck: true }), []); +}); + +test("the deck's own regions are laid as main laid them: a video entry's and an analysis item's spans alone (pinned)", () => { + const sch = { + fps: 30, transition: 0.4, total: 60, segments: [ + { id: "a", type: "clip", start: 0, end: 10.4, duration: 10.4 }, + { id: "v", type: "video", start: 10, end: 20.4, duration: 10.4, hideDeck: true, noChrome: true, enter: { out: 0.5, in: 0.5 } }, + { id: "b", type: "clip", start: 20, end: 30.4, duration: 10.4 }, + { id: "vc", type: "video", start: 30, end: 40.4, duration: 10.4, hideDeck: true, noChrome: true }, + { id: "an", type: "analysis", start: 40, end: 47.4, duration: 7.4, hideDeck: true }, + { id: "tz", type: "teaser", start: 47, end: 53.4, duration: 6.4, hideDeck: true }, + { id: "c", type: "clip", start: 53, end: 60, duration: 7 }, + ], + }; + // Literals printed by the build at main bf1b4f461 (chromeBlackouts = videoBlackouts + analysisBlackouts; the + // teaser was not one). + const main = [[10.3667, 20.2], [30.2, 40.2], [40, 47.4]]; + const items = chromeBlackouts(sch); + assert.deepEqual(regionSpans(items, { followsDeck: true }), main); + assert.deepEqual(videoBlackouts(sch), main.slice(0, 2)); + assert.deepEqual(analysisBlackouts(sch), [[40, 47.4]]); + for (const name of ["deck", "dial", "odometer", "trail", "feed"]) { + assert.equal(moduleOfRegion(name)?.fullFrame?.followsDeck, true, name); + const chain = chromeOverlayChain(RENDER, [{ name, frames: `/f/${name}`, x: 0, y: 0 }], "[0:v]", 1, { blackouts: items }); + assert.ok(chain.chain.includes(`shortest=1${blackoutEnable(main)}[`), `${name}: ${chain.chain}`); + } + // Every other region: the video spans as they were, the analysis and the teaser to the frame before their ends. + assert.deepEqual(fullFrameSpans(sch), [[10.3667, 20.2], [30.2, 40.2], [40, less(47.4)], [47, less(53.4)]]); + assert.deepEqual(regionSpans(chromeBlackouts({ ...sch, total: 47.4, segments: sch.segments.slice(0, 5) }), { followsDeck: true }), [[10.3667, 20.2], [30.2, 40.2], [40, 48.4]]); + assert.deepEqual(regionSpans(chromeBlackouts({ ...sch, total: 40.4, segments: sch.segments.slice(0, 4) }), { followsDeck: true }), [[10.3667, 20.2], [30.2, 41.4]]); + // A video entry with deck: "shown" keeps the chrome. + const shown = { ...sch, segments: sch.segments.map((s) => (s.id === "v" ? { ...s, hideDeck: false, noChrome: undefined } : s)) }; + assert.deepEqual(videoBlackouts(shown), [[30.2, 40.2]]); +}); + +test("a cut with no full-frame item: no blackouts, and the overlay chain is byte for byte the one it was", () => { + const clips = { ...SCHEDULE, segments: [SCHEDULE.segments[0], { ...SCHEDULE.segments[2], start: 400, duration: 339.6 }] }; + assert.deepEqual(chromeBlackouts(clips), []); + assert.equal(fullFrameIds(clips).size, 0); + const on = deckOverlays().filter((m) => m.on(clips, RENDER)); + const regions = on.flatMap((m) => m.regions(clips, { render: RENDER, outDir: "/out", frames: `/out/chrome/${m.region}-frames`, shift: 0 })); + const plain = chromeOverlayChain(RENDER, regions, "[0:v]", 1, {}); + // renderDeck passes `blackouts` only when there is one (`...(blackouts.length ? { blackouts } : {})`). + const bo = chromeBlackouts(clips); + const laid = chromeOverlayChain(RENDER, regions, "[0:v]", 1, bo.length ? { blackouts: bo } : {}); + assert.equal(laid.chain, plain.chain); + assert.deepEqual(laid.inputs, plain.inputs); + assert.doesNotMatch(laid.chain, /enable=/); +}); + +// ---- real ffmpeg: a few seconds at 320x180 ----------------------------------------------------------------------- + +const have = spawnSync("ffmpeg", ["-version"]).status === 0; +const ff = (args) => { + const r = spawnSync("ffmpeg", ["-nostdin", "-v", "error", "-y", ...args], { maxBuffer: 1 << 28 }); + assert.equal(r.status, 0, String(r.stderr)); + return r.stdout; +}; + +test("ffmpeg: over a teaser's frames no diet-strip pixel is drawn, on the clips either side it is; the deck's band is laid as before", + { skip: !have && "no ffmpeg" }, () => { + const dir = mkdtempSync(path.join(tmpdir(), "teaser-chrome-")); + try { + const W = 320, H = 180, Dx = 0.5; + // Three lossless segments: two dark clips, a mid-grey teaser between them. + const seg = (name, seconds, color) => { + const f = path.join(dir, `${name}.mov`); + ff(["-f", "lavfi", "-i", `color=c=${color}:s=${W}x${H}:r=30:d=${seconds}`, "-f", "lavfi", "-i", `anullsrc=r=48000:cl=stereo`, + "-t", String(seconds), "-map", "0:v", "-map", "1:a", "-c:v", "ffv1", "-pix_fmt", "yuv420p", "-c:a", "pcm_s16le", f]); + return f; + }; + const durs = [2, 2, 2]; + const segs = [seg("a", 2, "0x202020"), seg("t", 2, "0x808080"), seg("b", 2, "0x202020")]; + const { starts, total } = scheduleFrom(durs, Dx); + const schedule = { + fps: 30, transition: Dx, total, + segments: ["a", "t", "b"].map((id, i) => ({ id, type: id === "t" ? "teaser" : "clip", start: starts[i], duration: durs[i], end: starts[i] + durs[i], hideDeck: id === "t" })), + }; + const blackouts = chromeBlackouts(schedule); + assert.deepEqual(fullFrameSpans(schedule), [[1.5, 3.4667]]); + // White, opaque stand-ins for the deck's band and the diet strip, as long as the cut. + const n = Math.round(total * 30); + const seq = (name, w, h) => { + const d = path.join(dir, `${name}-frames`); + mkdirSync(d); + ff(["-f", "lavfi", "-i", `color=c=white:s=${w}x${h}:r=30`, "-frames:v", String(n), "-start_number", "1", path.join(d, "frame_%06d.png")]); + return d; + }; + const regions = [ + { name: "deck", frames: seq("deck", W, 30), x: 0, y: 150, width: W, height: 30 }, + { name: "diet", frames: seq("diet", 60, 40), x: 10, y: 10, width: 60, height: 40 }, + ]; + const R = { width: W, height: H, fps: 30, transition: Dx, audioRate: 48000, audioChannels: 2 }; + const picture = (chrome) => { + const args = xfadeConcatArgs({ segments: segs, durs, render: R, outPath: "-", chrome }); + const inputs = args.slice(4, args.indexOf("-filter_complex")); + const fc = args[args.indexOf("-filter_complex") + 1]; + const [v, a] = args.filter((_, i) => args[i - 1] === "-map"); + // The sound to a null muxer (an unmapped graph output is refused; an in-graph nullsink aborts ffmpeg 7.1). + const pic = ff([...inputs, "-filter_complex", fc, "-map", v, "-f", "rawvideo", "-pix_fmt", "yuv420p", "-", "-map", a, "-f", "null", "-"]); + const size = W * H * 1.5; + const out = []; + for (let o = 0; o + size <= pic.length; o += size) out.push(pic.subarray(o, o + size)); + return out; + }; + const bare = picture(null); + const laid = picture({ regions, outLabel: "[hfout]", blackouts }); + assert.equal(laid.length, n); + const luma = (frame, x, y) => frame[y * W + x]; + const [dx, dy] = [40, 30]; // inside the diet strip + const [kx, ky] = [160, 165]; // inside the deck's band: it follows the deck (its own page hides it), never cut + for (let f = 0; f < n; f += 1) { + const t = f / 30; + // Frames 45 (1.5 s, the dissolve's first) to 104; frame 105 (3.5 s) is the next clip's alone. + const off = f >= 45 && f <= 104; + if (off) assert.equal(luma(laid[f], dx, dy), luma(bare[f], dx, dy), `frame ${f} (${t.toFixed(3)} s): the teaser's own pixel`); + else assert.ok(luma(laid[f], dx, dy) > 230, `frame ${f} (${t.toFixed(3)} s): the diet stand-in is drawn (${luma(laid[f], dx, dy)})`); + assert.ok(luma(laid[f], kx, ky) > 230, `frame ${f}: the deck stand-in is laid as before`); + } + } finally { + rmSync(dir, { recursive: true, force: true }); + } + }); diff --git a/umtool/report-to-video/video-entry.mjs b/umtool/report-to-video/video-entry.mjs @@ -34,6 +34,7 @@ import { NARRATION_DEFAULTS } from "./narration.mjs"; import { POST_NARRATION_DEFAULTS } from "./post-narration.mjs"; +import { itemSpans } from "./full-frame.mjs"; const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v); const fin = (v) => typeof v === "number" && Number.isFinite(v); @@ -261,24 +262,13 @@ export function videoSegmentKey({ entry, file, render, lead, target = null }) { * segments: each video entry that hides it, from the frame the dip into it * has made black (the segment's start + the dissolve − a frame; mid-dissolve * for `enter: "cut"`) to its end (mid-dissolve into the next, or the cut's - * end). Empty for a cut without one -- and then nothing changes. + * end). Empty for a cut without one -- and then nothing changes. The video + * entries' share of the full-frame items (full-frame.mjs fullFrameItems, + * which the build lays every chrome region's `enable` from). * * @param {{ segments: Array<{ type: string, start: number, end: number, noChrome?: boolean, dip?: object }>, total: number, fps?: number, transition?: number }} schedule */ -export function videoBlackouts(schedule) { - const segs = schedule?.segments ?? []; - const D = Number(schedule?.transition ?? 0) || 0; - const fps = Number(schedule?.fps ?? 30) || 30; - const out = []; - segs.forEach((s, i) => { - if (s.type !== "video" || !s.noChrome) return; - const entered = i > 0 && s.enter ? s.start + D - 1 / fps : i > 0 ? s.start + D / 2 : 0; - const last = i === segs.length - 1; - const b = last ? Number(schedule.total ?? s.end) + 1 : s.end - D / 2; - out.push([Math.max(0, Math.round(entered * 1e4) / 1e4), Math.round(b * 1e4) / 1e4]); - }); - return out; -} +export const videoBlackouts = (schedule) => itemSpans(schedule, "video"); /** An overlay's `enable` for blackouts in a stream whose clock starts `shift` s into the cut; "" with none. */ export function blackoutEnable(blackouts, shift = 0) {