commit 79dcb5f1a101ff11a8907a4debede3cf4df00fd5 parent 36e6766e1ff06d4fb9bc849f749b2da1e5c99a37 Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st> Date: Fri, 13 Nov 2026 23:20:16 -0500 umtool: no chrome over a teaser or any other full-frame item -- one list of full-frame spans (full-frame.mjs) The diet strip and the promise clock were drawn over a teaser: the deck's choreography hides the deck, the dial, the odometer, the trail and the feed over a segment that hides it, but the measure extras, the stamps and the other regions keep no such time, and the build's overlay blackouts covered only a video entry and an analysis item. full-frame.mjs (a leaf, no imports) is now the one rule: fullFrameSpans(schedule) gives every full-frame segment's span -- a video entry with the chrome off (its rule unchanged), and every other segment that hides the deck (a teaser that does not count, the brand intro, an analysis item, a card/scroll/chart/ledger under overCards "hide") from the first frame of its dissolve in (a dipping teaser: the frame the dip has made black; 0 when first) to the end of its dissolve out (past the cut's end when last). chromeBlackouts, videoBlackouts and analysisBlackouts read it; every region's overlay -- the full cut, a preview, a --cut-window, a chunk -- takes it as its enable. A counting teaser, a card under overCards "show" and a video entry with deck "shown" keep their chrome. A cut with no full-frame item lays the graph it did (pinned, with the video and analysis spans as printed before). Play: while a full-frame item is on screen the deck's page and every layer are hidden (kept loaded and seeked), and the root says data-play-chrome="off" -- an analysis item's page had the same leak there. Tests: teaser-chrome-off.test.mjs (a test per leaking layer over the real overlay planners, a dipping teaser, a first teaser, back-to-back teasers, a window's clock, counting teaser / overCards / intro from real schedules, the pins, and a 5 s 320x180 ffmpeg render: no stand-in pixel over the teaser's frames). Docs: report-video.md "No chrome over a full-frame item", the README's teaser, the teaser and shell module docs (knobs.md regenerated), CHANGELOG. Co-Authored-By: Claude <noreply@anthropic.com> Diffstat:
16 files changed, 496 insertions(+), 60 deletions(-)
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -1,6 +1,19 @@ # Changelog ## [Unreleased] +- **umtool: no chrome is drawn over a teaser, the brand intro or a full-frame card.** The deck already slid away over + them, but the diet strip, the promise clock, the goals, the streak chain, the peak, the stamps and the other layers + stayed on screen over the teaser's card. Now every layer is off over every item that takes the whole frame, as it + already was 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). + - The 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 come back at the end of its dissolve out. A first item is clear from frame 0. + - At the default motion the deck's own slide away and back is inside those dissolves, so over them the deck is now + gone rather than sliding. A stamp that lands on a teaser that dips still counts, but is not drawn. + - Play the cut hides the deck and every layer 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, not in the + chrome's frames: cached 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/components/projects/OnscreenSection.tsx b/umtool/components/projects/OnscreenSection.tsx @@ -206,6 +206,7 @@ export function DeckFrame({ testid, children, className = "", + chromeOff = false, }: { preview: DeckPreviewDoc; t: number; @@ -214,6 +215,8 @@ export function DeckFrame({ testid?: string; children?: React.ReactNode; className?: string; + /** A full-frame item is on screen (full-frame.mjs): the deck's page is not drawn over it (kept loaded and seeked). */ + chromeOff?: boolean; }) { const box = useRef<HTMLDivElement | null>(null); const frame = useRef<HTMLIFrameElement | null>(null); @@ -301,8 +304,9 @@ export function DeckFrame({ // behind a transparent frame on a dark page. colorScheme: "normal", pointerEvents: "none", - visibility: scale > 0 ? "visible" : "hidden", + visibility: scale > 0 && !chromeOff ? "visible" : "hidden", }} + data-deck-chrome={chromeOff ? "off" : undefined} /> </div> ); 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"): nothing of the deck or its layers shows. + 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,6 +5,7 @@ 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 { fullFrameIds } from "umtool-report-to-video/full-frame"; import { DeckFrame, FeedOverlay, ModuleLayers, PostsOverlay, postsWindowAt, type DeckPreviewDoc, type Rect } from "../OnscreenSection"; import { usePlayEngine } from "./playEngine/usePlayEngine"; import { useRenderCuts } from "./playEngine/useRenderCuts"; @@ -286,6 +287,12 @@ 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): every chrome layer is off over it, as the build lays + // each region's overlay 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 fullIds = useMemo(() => fullFrameIds(schedule), [schedule]); + const chromeOff = !!item && fullIds.has(item.id); // 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 +347,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, postNow, vstage, videoNow, teaserPage, teaserNow, introNow, placeholder, sideEntry, }; } @@ -357,7 +364,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, chromeOff } = 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} /> @@ -465,7 +472,7 @@ export function PlayStage({ core, basic = false, plainClassName }: { core: PlayC </div> <div className="relative"> {doc && g && box ? ( - <DeckFrame preview={doc} t={tc} texts={{}} testid="play-deck"> + <DeckFrame preview={doc} t={tc} texts={{}} testid="play-deck" chromeOff={chromeOff}> <div className="absolute inset-0" style={{ background: bg }} /> {footageCanvas(rect ? { left: pct(rect.x, g.W), top: pct(rect.y, g.H), width: pct(rect.width, g.W), height: pct(rect.height, g.H) } : undefined, box.width, box.height)} {videoUnder} @@ -484,6 +491,10 @@ 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 none of the layers below is drawn (chromeOff): kept mounted, transparent, so each + page is ready and seeked the moment the item after it comes up. (Opacity, not visibility: a layer's own + frame sets `visibility: visible`, which would win over an inherited hidden.) */} + <div className="pointer-events-none absolute inset-0" style={chromeOff ? { opacity: 0 } : undefined} data-play-layers={chromeOff ? "off" : "on"}> {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" />} @@ -494,6 +505,7 @@ export function PlayStage({ core, basic = false, plainClassName }: { core: PlayC <FeedOverlay key={`finale:${doc.finale.src ?? "none"}`} feed={doc.finale} frame={g} t={tc} ready="finale:ready" testid="play-finale" name="finale" /> </div> )} + </div> </DeckFrame> ) : ( <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 no chrome layer is drawn 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: no chrome layer is drawn over it -- the deck, the instruments, the diet strip, the promise clock, the goals, the stamps, every region -- from its first frame (a dip's black) to the end of its dissolve out ([report-video.md](report-video.md#no-chrome-over-a-full-frame-item)); 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,9 @@ 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); Play hides every layer 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 +1843,35 @@ 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, and **no chrome layer is drawn over it**: 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 does every other layer: the build lays +every chrome region -- the deck's shell (title, subtitle, QR, rail, section title, counter), the dial, the +odometer, the trail, the measure extras (the diet strip, the promise clock's days-since, the goals, the streak +chain, the peak), the shelf, the feed and 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 -- with an `enable` +that leaves each such item's span out. One list, `full-frame.mjs fullFrameSpans` (build-video.mjs +`chromeBlackouts`), 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 end of its dissolve out (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 | + +So the chrome goes at the first frame the item's picture is in and is back at the first frame it is not: two +full-frame items back to back are one span. At the default motion (`transition` 0.5, `motion.in` 0.45) the +deck's own slide away and back falls inside the dissolve, so over a full-frame item's dissolves the deck is +gone, not sliding. **What keeps its chrome**: a teaser that counts (marks and no dip, deck.mjs `teaserCounts`: +the deck stays up so the count is seen to step, and every layer with it), a card under `overCards: "show"`, a +video entry with `deck: "shown"`. A stamp that lands on a teaser that dips still counts (the tally steps under +the hidden deck) and is not drawn, as one that lands in the finale. 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): the deck's page and every layer +are hidden, still loaded and seeked (`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 +3709,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/report-to-video/README.md b/umtool/report-to-video/README.md @@ -1370,6 +1370,14 @@ 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, and **no chrome +layer** — the instruments, the measure extras (the diet strip, the promise +clock, the goals, the streak), the stamps, every region — is drawn over it, +from its first frame (for one that dips, the frame the dip has made black) to +the end of its dissolve out (`full-frame.mjs`; umtool's report-video.md, "No +chrome over a full-frame item"). 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 @@ -69,11 +69,12 @@ 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(chromeBlackouts(withTeaser), [[732.6, 740.6]]); + 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]]); 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 { fullFrameSpans } 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,11 @@ 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 rule is every full-frame item's + * (full-frame.mjs fullFrameSpans, which the build lays every chrome region's `enable` from); this is its analysis + * items' share. [] 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) => fullFrameSpans(schedule, { only: (s) => s.type === "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 { fullFrameSpans } 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 @@ -3929,7 +3930,7 @@ 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. + // The full-frame items' spans (chromeBlackouts, full-frame.mjs), cut seconds; "" with none. const off = blackoutEnable(blackouts, shift); const inputs = []; const parts = []; @@ -6157,23 +6158,20 @@ 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: []. + * The cut seconds every chrome region leaves out (its overlay's `enable`): every FULL-FRAME item's span + * (full-frame.mjs fullFrameSpans) -- a video entry's (video-entry.mjs videoBlackouts' rule), an analysis item's, a + * teaser's that hides the deck, the brand intro's, a card's under `overCards: "hide"` -- no layer at all over it. 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) => fullFrameSpans(schedule); /** * A cached concat is a base for the overlay only when it is as long as the diff --git a/umtool/report-to-video/full-frame.mjs b/umtool/report-to-video/full-frame.mjs @@ -0,0 +1,93 @@ +// full-frame.mjs — THE FULL-FRAME SPANS: the cut seconds no chrome is drawn over. +// +// 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 so must every other layer the build lays over the +// cut. The deck, the instruments and the feed follow the deck's choreography; the measure extras (the diet strip, +// the promise clock, the goals, the streak, the peak), the stamps, the side panels, the chapters, the finale's pages +// keep no such time. So the build lays EVERY chrome region with an `enable` that leaves these spans out +// (build-video.mjs chromeBlackouts -> chromeOverlayChain, video-entry.mjs blackoutEnable), and Play hides every +// layer while such an item is the one on screen (playCore.tsx, `fullFrameIds`). One list, one rule per kind: +// +// 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 segment that hides the deck: 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 previous segment's last: the dip fades the +// whole frame, overlays with it, so nothing pops before then) -- to the last frame its picture is in: the end of +// its dissolve out, or past the cut's end when it is last. A first segment is off from 0. +// +// A segment that keeps the deck up keeps every layer: 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 segment: [] -- 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; + +/** + * Is this schedule segment full frame, every chrome layer off over it? 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; +} + +/** + * A video entry's span (video-entry.mjs videoBlackouts' rule, unchanged). + * @param {any} s @param {number} i @param {any[]} segs @param {any} schedule @param {number} D @param {number} fps + */ +function videoSpan(s, i, segs, schedule, D, fps) { + 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; + return [Math.max(0, r4(entered)), r4(b)]; +} + +/** + * Any other full-frame segment's span: its picture's first frame to its last (the analysis item's rule, with a + * teaser's dip starting at its black). + * @param {any} s @param {number} i @param {any[]} segs @param {any} schedule @param {number} D @param {number} fps + */ +function pageSpan(s, i, segs, schedule, D, fps) { + const start = Number(s.start); + const end = fin(Number(s.end)) ? Number(s.end) : start + Number(s.duration); + const from = i === 0 ? 0 : s.dip ? start + D - 1 / fps : start; + const to = i === segs.length - 1 ? Number(schedule.total ?? end) + 1 : end; + return [Math.max(0, r4(from)), r4(to)]; +} + +/** + * The cut seconds every chrome region leaves out, `[from, to]` pairs in cut seconds, by start: one per full-frame + * segment of the schedule (`fullFrameSegment`). Overlapping pairs (two full-frame items back to back) are kept as + * they are: an `enable` of `not(between(…)+between(…))` is off over their union. [] without one. + * + * `only` narrows it to the segments it accepts (video-entry.mjs videoBlackouts: the video entries' alone). + * + * @param {{ segments?: any[], total?: number, fps?: number, transition?: number } | null | undefined} schedule + * @param {{ only?: (seg: any) => boolean }} [opts] + * @returns {Array<[number, number]>} + */ +export function fullFrameSpans(schedule, { only = () => true } = {}) { + const segs = schedule?.segments ?? []; + const D = Number(schedule?.transition ?? 0) || 0; + const fps = Number(schedule?.fps ?? 30) || 30; + /** @type {Array<[number, number]>} */ + const out = []; + segs.forEach((s, i) => { + if (!fullFrameSegment(s) || !only(s) || !fin(Number(s?.start))) return; + out.push(/** @type {[number, number]} */ (s.type === "video" ? videoSpan(s, i, segs, schedule, D, fps) : pageSpan(s, i, segs, schedule, D, fps))); + }); + return out.sort((x, y) => x[0] - y[0]); +} + +/** The ids of the schedule's full-frame segments: what Play hides every layer over while it is on screen. */ +export function fullFrameIds(schedule) { + return new Set((schedule?.segments ?? []).filter(fullFrameSegment).map((s) => s.id)); +} diff --git a/umtool/report-to-video/modules/shell.mjs b/umtool/report-to-video/modules/shell.mjs @@ -48,7 +48,7 @@ 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 no chrome layer is drawn 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}'`"], ], 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: no chrome layer is drawn over it -- the deck, the instruments, the diet strip, the promise clock, the goals, the stamps, every region -- from its first frame (a dip's black) to the end of its dissolve out ([report-video.md](report-video.md#no-chrome-over-a-full-frame-item)); 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/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,291 @@ +// 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 the build lays (modules deckOverlays, their real `regions` planners) gets an `enable` that leaves each +// full-frame segment's span out (full-frame.mjs fullFrameSpans -> build-video.mjs chromeBlackouts -> +// 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. 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 { deckSchedule, estimateSchedule, scheduleFrom } from "./deck.mjs"; +import { fullFrameIds, fullFrameSegment, fullFrameSpans } from "./full-frame.mjs"; +import { deckOverlays } from "./modules/index.mjs"; +import { 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; +}; + +// THE LEAKING LAYERS, one test each: the measure extras (the diet strip, the promise clock, the goals, the streak, +// the peak), and every other region the cut lays -- the deck's shell and the instruments with it. +{ + const { ids } = overlayParts(SCHEDULE); + for (const id of ["diet", "promise", "goals", "streak", "peak", "shell", "dial", "odometer", "trail"]) { + 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, blackouts } = overlayParts(SCHEDULE); + assert.deepEqual(blackouts, [[400, 406.4]]); + 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). + for (const t of frames(400, 406.4)) assert.equal(enabledAt(part, t), false, `${id} at ${t}`); + assert.equal(enabledAt(part, 400 - 1 / FPS), true, `${id} the frame before`); + assert.equal(enabledAt(part, 406.4 + 1 / FPS), true, `${id} the frame after`); + assert.equal(enabledAt(part, 100), true); + } + }); + } +} + +test("a teaser that dips: off from the frame the dip has made black (the clip's last) to the end of its dissolve out", () => { + const sch = { ...SCHEDULE, segments: SCHEDULE.segments.map((s) => (s.id === "t" ? { ...s, dip: { fade: 1, black: 0.5 } } : s)) }; + const [[a, b]] = chromeBlackouts(sch); + assert.equal(a, Math.round((400 + D - 1 / FPS) * 1e4) / 1e4); + assert.equal(b, 406.4); + // The dip fades the whole frame, overlays with it, until then: the chrome is there to fade. + const { parts } = overlayParts(sch); + for (const { part } of parts) { + assert.equal(enabledAt(part, 400.3), true); + for (const t of frames(400.4, 406.4)) assert.equal(enabledAt(part, t), false); + } +}); + +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(chromeBlackouts(sch), [[0, 6.4]]); +}); + +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: 406.4, hideDeck: true }, + { id: "t2", type: "teaser", start: 406, duration: 6.4, end: 412.4, hideDeck: true }, + ], + }; + assert.deepEqual(chromeBlackouts(sch), [[400, 406.4], [406, 413.4]]); + const { parts } = overlayParts(sch); + for (const { part } of parts) { + for (const t of frames(400, 412.4)) assert.equal(enabledAt(part, t), false, `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", () => { + 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.5), true); +}); + +// ---- 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 }, + ], +}); + +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(chromeBlackouts(plain), [[seg.start, 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(chromeBlackouts(hide), [[hide.segments[1].start, 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 end of its dissolve into the first entry", () => { + 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(chromeBlackouts(doc), [[0, doc.segments[0].end]]); +}); + +test("a video entry's span and an analysis item's are the ones they were (pinned from the build before this lane)", () => { + 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: "c", type: "clip", start: 47, end: 60, duration: 13 }, + ], + }; + // Literals printed by the build at main bf1b4f461 (chromeBlackouts = videoBlackouts + analysisBlackouts). + assert.deepEqual(chromeBlackouts(sch), [[10.3667, 20.2], [30.2, 40.2], [40, 47.4]]); + assert.deepEqual(chromeBlackouts({ ...sch, total: 47.4, segments: sch.segments.slice(0, 5) }), [[10.3667, 20.2], [30.2, 40.2], [40, 48.4]]); + assert.deepEqual(chromeBlackouts({ ...sch, total: 40.4, segments: sch.segments.slice(0, 4) }), [[10.3667, 20.2], [30.2, 41.4]]); + assert.deepEqual(videoBlackouts(sch), [[10.3667, 20.2], [30.2, 40.2]]); + assert.deepEqual(analysisBlackouts(sch), [[40, 47.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]]); + assert.deepEqual(fullFrameSpans(sch), chromeBlackouts(sch)); +}); + +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 instrument pixel is drawn; over the clips either side the stand-ins are", + { 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(blackouts, [[1.5, 3.5]]); + // 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 at = [[160, 165], [40, 30]]; // inside the deck's band, inside the diet strip + for (let f = 0; f < n; f += 1) { + const t = f / 30; + const off = t >= 1.5 && t <= 3.5; + for (const [x, y] of at) { + if (off) assert.equal(luma(laid[f], x, y), luma(bare[f], x, y), `frame ${f} (${t.toFixed(3)} s) at ${x},${y}: the teaser's own pixel`); + else assert.ok(luma(laid[f], x, y) > 230, `frame ${f} (${t.toFixed(3)} s) at ${x},${y}: the stand-in is drawn (${luma(laid[f], x, y)})`); + } + } + } 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 { fullFrameSpans } 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 every full-frame item's spans (full-frame.mjs + * fullFrameSpans, 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) => fullFrameSpans(schedule, { only: (s) => s.type === "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) {