// NO CHROME OVER AN ANALYSIS ITEM (rev9-a10 R1, 13 Nov: the diet strip, the goal notes and the promise clock were // laid over the analysis page -- the deck's own choreography hides the deck, the dial, the odometer and the trail // over it, but the measure extras keep no such time). Every overlay module the build lays (modules deckOverlays, // their real `regions` planners) gets an `enable` that leaves the analysis segment's span out -- from the first frame // of its dissolve in to the cut's end -- as a video entry's (build-video.mjs chromeBlackouts, chromeOverlayChain). import assert from "node:assert/strict"; import { readFileSync } from "node:fs"; import path from "node:path"; import test from "node:test"; 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"; 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; // Clips to 732.6 s, then the analysis item 732.6–739.6, the cut's last. const SCHEDULE = { kind: "deck", fps: 30, total: 739.6, transition: D, segments: [ { id: "a", type: "clip", start: 0, duration: 733, end: 733 }, { id: "analysis", type: "analysis", start: 732.6, duration: 7, end: 739.6, hideDeck: true }, ], 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); } test("every overlay module's region is off over the analysis segment, from its first frame to the cut's end", () => { const on = deckOverlays().filter((m) => m.on(SCHEDULE, RENDER)); const ids = on.map((m) => m.id); for (const id of ["shell", "diet", "goals", "promise", "dial", "odometer", "trail"]) assert.ok(ids.includes(id), `${id} is laid (${ids.join(", ")})`); 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(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); const fps = SCHEDULE.fps; for (const part of overlays) { // Every frame of the item: its dissolve in (732.6–733.0), the page, its last frames to the cut's end. for (let f = Math.round(732.6 * fps); f <= Math.round(739.6 * fps); f += 1) assert.equal(enabledAt(part, f / fps), false, `${part.slice(0, 60)} at ${f / fps}`); // ...and only there: the frame before the dissolve keeps the chrome. assert.equal(enabledAt(part, 732.6 - 1 / fps), true); assert.equal(enabledAt(part, 100), true); } }); test("in a window of the cut (--cut-window, a preview) the span is shifted to the window's clock", () => { const regions = deckOverlays().filter((m) => m.id === "promise").flatMap((m) => m.regions(SCHEDULE, { render: RENDER, outDir: "/out", frames: "/f" })); const chain = chromeOverlayChain(RENDER, regions, "[0:v]", 1, { blackouts: chromeBlackouts(SCHEDULE), shift: 730 }); const part = chain.chain.split(";").find((p) => p.includes("overlay=")); assert.equal(enabledAt(part, 2.6), false); assert.equal(enabledAt(part, 2.5), true); }); 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(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 }] }; // 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]]); });