// 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, fullFrameTraitProblem, layerOffOver, regionSpans } from "./full-frame.mjs"; import { defineModule, 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 clip's stamp and posts window leave over the next segment's dissolve whole when it is full frame (ownFade)", () => { assert.deepEqual(moduleOfRegion("stamp")?.fullFrame, { drawsMarks: true, ownFade: true }); assert.deepEqual(moduleOfRegion("posts")?.fullFrame, { ownFade: true }); const items = fullFrameItems(SCHEDULE); const chain = chromeOverlayChain(RENDER, [ { name: "stamp", frames: "/f/stamp", x: 0, y: 0 }, { name: "posts", frames: "/f/posts", x: 0, y: 0, offset: 395 }, { name: "diet", frames: "/f/diet", x: 0, y: 0 }, ], "[0:v]", 1, { blackouts: items }); const [stamp, posts, diet] = chain.chain.split(";").filter((p) => p.includes("overlay=")); for (const part of [stamp, posts]) { // Their exit: the teaser's dissolve in, 400.0–400.4 -- drawn; then off to the frame before its dissolve out ends. for (const t of frames(400, 400.4 - 1 / FPS)) assert.equal(enabledAt(part, t), true, `the exit at ${t}`); for (const t of frames(400.4, END)) assert.equal(enabledAt(part, t), false, `at ${t}`); } assert.equal(enabledAt(diet, 400), false); // Both traits on the stamps: drawsMarks wins over a teaser with marks (no span), ownFade shapes the others. const marked = fullFrameItems({ ...SCHEDULE, segments: SCHEDULE.segments.map((x) => (x.id === "t" ? { ...x, claim: { id: "t", verdict: "L" } } : x)) }); assert.deepEqual(regionSpans(marked, { drawsMarks: true, ownFade: true }), []); assert.deepEqual(regionSpans(items, { drawsMarks: true, ownFade: true }), [[400.4, END]]); }); test("the traits' validator: followsDeck stands alone; ownFade with drawsMarks is allowed; anything else is refused", () => { assert.equal(fullFrameTraitProblem({ followsDeck: true }), null); assert.equal(fullFrameTraitProblem({ ownFade: true, drawsMarks: true }), null); assert.match(fullFrameTraitProblem({ followsDeck: true, ownFade: true }), /followsDeck stands alone/); assert.match(fullFrameTraitProblem({ ownFade: false }), /must be true/); assert.match(fullFrameTraitProblem({ slides: true }), /is not a trait/); assert.match(fullFrameTraitProblem({}), /one or more/); const base = { id: "x-test", version: 1, z: 1, kind: "overlay-whole", slot: "footage", title: "X", region: "x-test" }; assert.throws(() => defineModule({ ...base, fullFrame: { followsDeck: true, drawsMarks: true } }), /followsDeck stands alone/); assert.equal(defineModule({ ...base, fullFrame: { ownFade: true, drawsMarks: true } }).fullFrame.ownFade, true); }); 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); // Over a video entry or an analysis item the deck's own layers are off too, as the build blacks them out there. const av = fullFrameItems({ fps: 30, transition: 0.4, total: 30, segments: [ { id: "a", type: "clip", start: 0, end: 10.4, duration: 10.4 }, { id: "an", type: "analysis", start: 10, end: 17.4, duration: 7.4, hideDeck: true }, { id: "v", type: "video", start: 17, end: 30, duration: 13, hideDeck: true, noChrome: true }, ] }); for (const x of av) assert.equal(layerOffOver(x, { followsDeck: true }, x.start + 1), true, x.kind); }); // ---- 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 }); } });