commit 5b4aaf5e7a4b6cca38003ab66b02fc78bb3ad762
parent 50acf3e1b3bdc17487b720df504123931febfc19
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Fri, 20 Nov 2026 20:02:33 -0500
Merge lane/gap-cue-module: the gap mark is a HyperFrames module wherever a deck runs
Under a deck the mark is one short overlay page per join (over the footage corner, or in the deck band beside the source line), drawn from the cut records, so turning it on, moving it or giving it a reason re-renders chrome only and an old take needs no re-cut. The drawtext path stays for builds with no chrome over the picture; never both on one frame.
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
31 files changed, 2256 insertions(+), 406 deletions(-)
diff --git a/common/lib/report/gapCue.d.mts b/common/lib/report/gapCue.d.mts
@@ -4,13 +4,15 @@ type Render = Record<string, unknown> | null | undefined;
type Entry = Record<string, unknown> | null | undefined;
export type GapCueCorner = "auto" | "tl" | "tr" | "bl" | "br";
-export type GapCue = { mark: boolean; min: number; corner: GapCueCorner; label: string };
+export type GapCuePlace = "footage" | "deck";
+export type GapCue = { mark: boolean; min: number; corner: GapCueCorner; label: string; place: GapCuePlace };
export type GapCueMark = { at: number; until: number; seconds: number; count: number; why?: string; corner?: string };
export type GapJoin = { at: number; seconds: number; mark: boolean; play?: number; why?: string; corner?: string | null };
export type GapWhy = "dead-air" | "idle" | "other";
export const GAP_CUE_DEFAULTS: Readonly<GapCue>;
-export const GAP_CUE_KEYS: readonly ("mark" | "min" | "corner" | "label")[];
+export const GAP_CUE_KEYS: readonly ("mark" | "min" | "corner" | "label" | "place")[];
+export const GAP_CUE_PLACES: readonly GapCuePlace[];
export const GAP_CUE_CORNERS: readonly GapCueCorner[];
export const GAP_CUE_MIN: Readonly<{ min: number; max: number }>;
export const GAP_CUE_LABEL_MAX: number;
@@ -26,6 +28,12 @@ export const GAP_CUE_LOOK: Readonly<{
}>;
export const GAP_CUE_MOTION: Readonly<{ in: number; hold: number; out: number; peak: number }>;
export const GAP_CUE_LIFE: number;
+export type GapCueBoxStyle = {
+ fontSize: string; lineHeight: string; padding: string; color: string; border: string; background: string;
+ backgroundClip: "padding-box"; whiteSpace: "nowrap";
+};
+export function gapCueBoxStyle(o: { font: number | string; stroke: number | string; lineHeight?: number; look?: Partial<typeof GAP_CUE_LOOK> }): GapCueBoxStyle;
+export function gapCueCss(selector: string, o: { font: number | string; stroke: number | string; lineHeight?: number; look?: Partial<typeof GAP_CUE_LOOK>; family?: string }): string;
export function gapCueErrors(v: unknown, where?: string): string[];
export function validateGapCue(manifest: unknown): string[];
diff --git a/common/lib/report/gapCue.mjs b/common/lib/report/gapCue.mjs
@@ -10,9 +10,9 @@
//
// THE SETTINGS, most specific wins:
//
-// render.gapCue { mark?, min?, corner?, label? } the project's (a look key: a preset, a style or
-// a take patch carries it like any other)
-// clip.gapCue { mark?, min?, corner?, label? } one clip's, over the project's
+// render.gapCue { mark?, min?, corner?, label?, place? } the project's (a look key: a preset, a
+// style or a take patch carries it)
+// clip.gapCue { mark?, min?, corner?, label?, place? } one clip's, over the project's
// a gap's `mark` true | false one gap's, over both
//
// mark draw the mark at a join (default false: OFF, so a cut that says nothing renders as it always did)
@@ -20,6 +20,8 @@
// corner auto | tl | tr | bl | br (default auto: the layout's own free corner)
// label the text: `{s}` the length skipped, `{why}` the gap's reason, and a part in [ ] drawn only when
// the gap has one (default "» {s}[ · {why}]": "» 27 s", or "» 26 s · dead air"; from a minute "» 1:12")
+// place footage | deck (default footage: over the footage at its corner; deck: in the deck's band, at the
+// end of the source line, left of the QR -- only where a deck is drawn: elsewhere footage)
//
// A gap may also carry `why` ("dead-air" | "idle" | "other"): what it was cut
// for, and `reason`, a few words of its own (at most GAP_REASON_MAX). The mark
@@ -30,8 +32,13 @@
// `corner` stands its mark in that corner, over its clip's (a stream's layout
// can change inside one clip).
//
-// THE LOOK (GAP_CUE_LOOK) is here too, so the build's drawtext (gap-mark.mjs)
-// and the pages' element (GapMarkChip) draw one mark.
+// THE LOOK (GAP_CUE_LOOK) is here too, so the build's drawtext (gap-mark.mjs),
+// the gap-cue module's page (chrome-gap-cue.mjs, gapCueCss) and umtool's
+// element over a raw picture (GapMarkChip, gapCueBoxStyle) draw one mark.
+//
+// WHO DRAWS IT (lane gap-cue, slice 1d): wherever a deck is drawn, the gap-cue
+// MODULE (a HyperFrames page per mark, at its own seconds); the drawtext into
+// the clip's segment only where no chrome is laid over the picture.
//
// THE TIMING, on the segment's clock (seconds from its first frame): the mark
// comes up over GAP_CUE_MOTION.in at the join, holds, and goes over
@@ -46,9 +53,11 @@ const fin = (v) => typeof v === "number" && Number.isFinite(v);
const EPS = 1e-6;
/** The settings a cut that says nothing has: the mark off. */
-export const GAP_CUE_DEFAULTS = Object.freeze({ mark: false, min: 2, corner: "auto", label: "» {s}[ · {why}]" });
+export const GAP_CUE_DEFAULTS = Object.freeze({ mark: false, min: 2, corner: "auto", label: "» {s}[ · {why}]", place: "footage" });
/** The keys `render.gapCue` and a clip's `gapCue` take. */
-export const GAP_CUE_KEYS = Object.freeze(["mark", "min", "corner", "label"]);
+export const GAP_CUE_KEYS = Object.freeze(["mark", "min", "corner", "label", "place"]);
+/** Where the mark is drawn: over the footage (at its corner), or in the deck's band (the end of the source line). */
+export const GAP_CUE_PLACES = Object.freeze(["footage", "deck"]);
/** Where the mark may stand: the layout's choice, or a corner of its box. */
export const GAP_CUE_CORNERS = Object.freeze(["auto", "tl", "tr", "bl", "br"]);
/** `min`'s range, in seconds. */
@@ -90,6 +99,52 @@ export const GAP_CUE_MOTION = Object.freeze({ in: 0.15, hold: 0.6, out: 0.35, pe
/** How long one mark is up: in, hold and out. */
export const GAP_CUE_LIFE = GAP_CUE_MOTION.in + GAP_CUE_MOTION.hold + GAP_CUE_MOTION.out;
+/** `#rrggbb` at `a`, for CSS. */
+const rgbaOf = (hex, a) => {
+ const n = Number.parseInt(String(hex).replace(/^#/, ""), 16);
+ return `rgba(${(n >> 16) & 255}, ${(n >> 8) & 255}, ${n & 255}, ${a})`;
+};
+
+/**
+ * The mark's box as CSS values, from THE LOOK (`look` over GAP_CUE_LOOK): its font size `font` (px, or any CSS
+ * length), the box round the text (`pad` em), the border (`stroke`: px, or a CSS length), the text's colour, and
+ * the background -- the box over the border's colour inside the border, as the drawtext lays its two boxes
+ * (gap-mark.mjs gapMarkFilters), so the inside reads the same. `lineHeight` the text's line box. What the module's
+ * page (gapCueCss) and umtool's element over a raw picture (GapMarkChip) both draw: one look.
+ *
+ * @param {{ font: number | string, stroke: number | string, lineHeight?: number, look?: Partial<typeof GAP_CUE_LOOK> }} o
+ */
+export function gapCueBoxStyle({ font, stroke, lineHeight = 1.2, look = GAP_CUE_LOOK }) {
+ const L = { ...GAP_CUE_LOOK, ...look };
+ const len = (v) => (typeof v === "number" ? `${v}px` : String(v));
+ const inner = rgbaOf(L.box, L.boxAlpha);
+ const edge = rgbaOf(L.strokeColor, L.strokeAlpha);
+ return {
+ fontSize: len(font),
+ lineHeight: String(lineHeight),
+ padding: `${L.pad}em`,
+ color: L.fg,
+ border: `${len(stroke)} solid ${edge}`,
+ background: `linear-gradient(${inner}, ${inner}), ${edge}`,
+ backgroundClip: "padding-box",
+ whiteSpace: "nowrap",
+ };
+}
+
+/**
+ * gapCueBoxStyle as a CSS declaration block (`selector { … }`), for a page: the module's (chrome-gap-cue.mjs).
+ * `family` the face (the deck's own: DeckSansBold).
+ *
+ * @param {string} selector
+ * @param {Parameters<typeof gapCueBoxStyle>[0] & { family?: string }} o
+ */
+export function gapCueCss(selector, { family = "'DeckSansBold', sans-serif", ...o }) {
+ const s = gapCueBoxStyle(o);
+ const kebab = (k) => k.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
+ const decls = Object.entries(s).map(([k, v]) => `${kebab(k)}: ${v};`).join(" ");
+ return `${selector} { position: absolute; box-sizing: border-box; font-family: ${family}; ${decls} overflow: hidden; text-overflow: ellipsis; }`;
+}
+
const q = (v) => JSON.stringify(v);
/**
@@ -101,7 +156,7 @@ const q = (v) => JSON.stringify(v);
*/
export function gapCueErrors(v, where = "render.gapCue") {
if (v === undefined || v === null) return [];
- if (!isObj(v)) return [`${where} must be { mark?, min?, corner?, label? }`];
+ if (!isObj(v)) return [`${where} must be { mark?, min?, corner?, label?, place? }`];
const errors = [];
for (const k of Object.keys(v)) if (!GAP_CUE_KEYS.includes(k)) errors.push(`${where}.${k} is not a key (${GAP_CUE_KEYS.join(", ")})`);
if (v.mark !== undefined && typeof v.mark !== "boolean") errors.push(`${where}.mark is true (draw the mark at a join) or false, not ${q(v.mark)}`);
@@ -109,6 +164,9 @@ export function gapCueErrors(v, where = "render.gapCue") {
errors.push(`${where}.min is seconds from ${GAP_CUE_MIN.min} to ${GAP_CUE_MIN.max} (a shorter gap draws nothing), not ${q(v.min)}`);
}
if (v.corner !== undefined && !GAP_CUE_CORNERS.includes(/** @type {string} */ (v.corner))) errors.push(`${where}.corner is one of ${GAP_CUE_CORNERS.join(", ")}, not ${q(v.corner)}`);
+ if (v.place !== undefined && !GAP_CUE_PLACES.includes(/** @type {string} */ (v.place))) {
+ errors.push(`${where}.place is footage (over the footage, at its corner) or deck (in the deck's band, at the end of the source line), not ${q(v.place)}`);
+ }
if (v.label !== undefined) {
if (typeof v.label !== "string" || !v.label.includes("{s}")) errors.push(`${where}.label is text holding {s} (the seconds skipped), e.g. "» {s}" or "{s} later"`);
else if (!labelLineOk(v.label)) errors.push(`${where}.label is one line of at most ${GAP_CUE_LABEL_MAX} characters (no tab or other control character)`);
@@ -159,6 +217,7 @@ function own(v) {
if (typeof v.mark === "boolean") out.mark = v.mark;
if (fin(v.min) && v.min >= GAP_CUE_MIN.min && v.min <= GAP_CUE_MIN.max) out.min = v.min;
if (GAP_CUE_CORNERS.includes(v.corner)) out.corner = v.corner;
+ if (GAP_CUE_PLACES.includes(v.place)) out.place = v.place;
if (typeof v.label === "string" && v.label.includes("{s}") && labelLineOk(v.label) && labelPartsOk(v.label)) out.label = v.label;
return out;
}
@@ -167,7 +226,7 @@ function own(v) {
* The project's settings, the defaults filled in.
*
* @param {Record<string, any> | null | undefined} render
- * @returns {{ mark: boolean, min: number, corner: string, label: string }}
+ * @returns {{ mark: boolean, min: number, corner: string, label: string, place: string }}
*/
export const gapCueOf = (render) => ({ ...GAP_CUE_DEFAULTS, ...own(render?.gapCue) });
diff --git a/common/lib/report/gapCue.test.ts b/common/lib/report/gapCue.test.ts
@@ -6,6 +6,7 @@ import assert from "node:assert/strict";
import {
GAP_CUE_DEFAULTS,
GAP_CUE_LIFE,
+ GAP_CUE_LOOK,
clipGapCueOf,
gapCueAlpha,
gapCueLength,
@@ -17,11 +18,13 @@ import {
gapReasonOk,
gapWhyWord,
validateGapCue,
+ gapCueBoxStyle,
+ gapCueCss,
} from "./gapCue.mjs";
import { applyLookPatch, lookErrors } from "./look.mjs";
test("the defaults: the mark OFF, 2 s, the layout's corner, '» {s}[ · {why}]'", () => {
- assert.deepEqual(gapCueOf(undefined), { mark: false, min: 2, corner: "auto", label: "» {s}[ · {why}]" });
+ assert.deepEqual(gapCueOf(undefined), { mark: false, min: 2, corner: "auto", label: "» {s}[ · {why}]", place: "footage" });
assert.deepEqual(gapCueOf({}), GAP_CUE_DEFAULTS);
assert.equal(gapCueWanted({}, { type: "clip", gaps: [{ from: 1, to: 9 }] }), false, "a cut that says nothing marks nothing");
});
@@ -30,7 +33,7 @@ test("precedence: a gap's mark over its clip's over the project's", () => {
const render = { gapCue: { mark: true, min: 3 } };
const clip = { type: "clip", gapCue: { mark: false, corner: "tr" }, gaps: [{ from: 1, to: 9 }, { from: 12, to: 20, mark: true }] };
const cue = clipGapCueOf(render, clip);
- assert.deepEqual(cue, { mark: false, min: 3, corner: "tr", label: "» {s}[ · {why}]" });
+ assert.deepEqual(cue, { mark: false, min: 3, corner: "tr", label: "» {s}[ · {why}]", place: "footage" });
assert.equal(gapMarkOn(cue, clip.gaps[0]), false, "the clip's off");
assert.equal(gapMarkOn(cue, clip.gaps[1]), true, "the gap's own on");
assert.equal(gapCueWanted(render, clip), true);
@@ -118,6 +121,29 @@ test("the opacity: up over 0.15 s, 0.9 at full, down over 0.35 s", () => {
assert.equal(gapCueAlpha(c.until, c), 0);
});
+test("place (slice 1d): footage or deck, the clip's over the project's; anything else refused", () => {
+ assert.equal(clipGapCueOf({ gapCue: { place: "deck" } }, { gapCue: {} }).place, "deck");
+ assert.equal(clipGapCueOf({ gapCue: { place: "deck" } }, { gapCue: { place: "footage" } }).place, "footage");
+ assert.deepEqual(validateGapCue({ render: { gapCue: { place: "deck" } } }), []);
+ assert.match(validateGapCue({ render: { gapCue: { place: "band" } } }).join("\n"), /render\.gapCue\.place is footage .* or deck/);
+ assert.equal(gapCueOf({ gapCue: { place: "band" } }).place, "footage", "an unreadable place is the default");
+});
+
+test("the look as CSS (slice 1d): one box for the module's page and umtool's element -- a real border, the box inside it", () => {
+ const st = gapCueBoxStyle({ font: 32, stroke: 2 });
+ assert.equal(st.fontSize, "32px");
+ assert.equal(st.padding, `${GAP_CUE_LOOK.pad}em`);
+ assert.equal(st.border, "2px solid rgba(255, 255, 255, 0.9)");
+ assert.equal(st.background, "linear-gradient(rgba(16, 16, 16, 0.86), rgba(16, 16, 16, 0.86)), rgba(255, 255, 255, 0.9)");
+ assert.equal(gapCueBoxStyle({ font: "3cqmin", stroke: "max(1.5px, 0.19cqmin)" }).fontSize, "3cqmin");
+ const css = gapCueCss(".gm", { font: 32, stroke: 2 });
+ assert.match(css, /^\.gm \{ position: absolute;/);
+ assert.match(css, /font-family: 'DeckSansBold', sans-serif;/);
+ assert.match(css, /border: 2px solid rgba\(255, 255, 255, 0\.9\);/);
+ assert.match(css, /background-clip: padding-box;/);
+ assert.match(css, /white-space: nowrap;/);
+});
+
test("validation: the project's block and each clip's, in the build's words", () => {
assert.deepEqual(validateGapCue({ render: {}, timeline: [] }), []);
assert.deepEqual(validateGapCue({ render: { gapCue: { mark: true, min: 4, corner: "bl", label: "{s} later" } } }), []);
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md
@@ -7,6 +7,28 @@
read a missing field as wrong. It now reads a missing field as empty.
- `umtool source-status <p> refresh` no longer writes empty fields, so the project's stamp and the take's agree. A
stamp written with them still works, and a refresh does not rewrite it only to remove them.
+- **umtool: under a deck, the gap mark is a HyperFrames module, so changing it re-renders chrome only.**
+ - Wherever a deck is drawn, the mark is the `gap-cue` module: one short page per mark, at its own seconds, like
+ the stamps and popup posts. Its page is its live preview in Play the cut.
+ - Turning the mark on, or changing its corner, label, reason or place, re-renders those pages and the chunks over
+ them. No clip segment is re-encoded.
+ - An old take gets marks from a `--chrome-only` re-render, with no re-cut. The joins come from the cut records the
+ schedule already reads.
+ - New `place` setting: `footage` (the default) or `deck`, which puts the mark at the end of the source line, left
+ of the QR. Where the line and the mark do not both fit, the mark goes over the footage. CLI:
+ `gapCue.place=deck`. It is also in the bench's **where** control and the Modules panel.
+ - With no chrome over the picture (the plain cut, `--no-chrome`, a bare vertical cut, `--desktop`, `--short`) the
+ mark is still drawn into the clip's segment. The two are never drawn on one frame.
+ - A take whose segments already drew marks under a deck changes those segments' keys once. A `--chrome-only` pass
+ over such a segment says so, worded by whether the mark is still wanted.
+ - The deck place never covers the source line. The line is measured in the face the deck sets it in (the brand's
+ IBM Plex Mono included), and the mark's page measures it again in its own faces before it shows the mark; if
+ they would touch, the mark goes over the footage.
+ - The deck's lazy capture stays on with gap marks in the cut: a retrofit draws the deck only for the chunks the
+ marks are in.
+ - A segment cut before its clip had gaps gets no mark at a join its picture does not have, and the pass says so.
+ - Over the footage the mark also keeps off the stats panel and the effects' screenshots. A mark ends before the
+ dissolve into the next clip. Clip ids with `.` or `:` work.
- **umtool: the gap mark is set on the clip bench and shows while playing.**
- A click on a gap's band now picks the gap. A row under the waveform shows its seconds, how it shows (skip;
fast-forward is not built yet), its own mark (as the clip's, on or off), what it was cut for, its own words, its
diff --git a/umtool/components/projects/ClipBench.tsx b/umtool/components/projects/ClipBench.tsx
@@ -1480,6 +1480,8 @@ export default function ClipBench({
const benchMark = benchMarks.length ? gapMarkAt(benchMarks, clipPlayClock({ gaps: clip.gaps ?? [], from: gapsSpan.from, to: gapsSpan.to }, playhead)) : null;
// A gap's own corner over the clip's (a stream's layout can change inside one clip).
const benchMarkCorner = gapMarkCorner(benchMark?.corner ?? clipCue.corner, { deck: data.deckOn });
+ // In the deck's band (gapCue.place deck, under a deck): not over the source picture.
+ const benchMarkInDeck = data.deckOn && clipCue.place === "deck";
const writeGapCue = useCallback(
async (patch: Record<string, unknown>) => {
const ok = await save({ gapCue: patch });
@@ -3014,7 +3016,13 @@ export default function ClipBench({
/>
{hasHidden && <CensorOverlay regions={data.hidden ?? []} at={benchAt} aspect={benchAspect} mode="edit" testId="bench-censor" />}
{/* The mark at a gap's join, as the render draws it (lane gap-cue): up while what plays crosses a marked join. */}
- {benchMarks.length > 0 && <GapMarkChip mark={benchMark} corner={benchMarkCorner} aspect={benchAspect} testId="bench-gap-mark" />}
+ {benchMarks.length > 0 && !benchMarkInDeck && <GapMarkChip mark={benchMark} corner={benchMarkCorner} aspect={benchAspect} testId="bench-gap-mark" />}
+ {/* Placed in the deck (gapCue.place deck): the band is not over this picture -- said beside it, not drawn on it. */}
+ {benchMarkInDeck && benchMark && (
+ <div data-bench-gap-mark-deck={benchMark.text} className="pointer-events-none absolute bottom-1 left-1 z-[4] rounded bg-black/70 px-1.5 py-0.5 font-mono text-[11px] text-white">
+ {benchMark.text} · in the deck
+ </div>
+ )}
</div>
) : (
<div data-walk-pin-empty="" className={cn("flex aspect-video w-full items-center justify-center rounded border border-dashed border-[var(--color-line)] text-[12px] text-[var(--color-dim)] lg:aspect-auto lg:min-h-[200px] lg:flex-[3_1_0%]", inspector && "aspect-auto py-3 lg:aspect-auto lg:min-h-0")}>
diff --git a/umtool/components/projects/bench/GapCueTools.tsx b/umtool/components/projects/bench/GapCueTools.tsx
@@ -2,7 +2,7 @@
import { useEffect, useState } from "react";
import { buttonVariants } from "@/components/ui/button";
-import { GAP_CUE_CORNERS, GAP_CUE_MIN, GAP_OWN_CORNERS, GAP_REASON_MAX, gapCueText, gapMarkOn, gapWhyWord, type GapCue } from "yt-dlp-transcript-common/lib/report/gapCue.mjs";
+import { GAP_CUE_CORNERS, GAP_CUE_MIN, GAP_CUE_PLACES, GAP_OWN_CORNERS, GAP_REASON_MAX, gapCueText, gapMarkOn, gapWhyWord, type GapCue } from "yt-dlp-transcript-common/lib/report/gapCue.mjs";
import type { GapEditor } from "./useGapEditor";
// ---------------------------------------------------------------------------
@@ -28,6 +28,7 @@ const sel =
"rounded border border-[var(--color-line)] bg-[var(--color-panel-2)] px-1 py-0.5 text-[11px] text-[var(--color-text)] disabled:opacity-60";
const onOff = (v: boolean) => (v ? "on" : "off");
const CORNER_WORDS: Record<string, string> = { auto: "the layout's", tl: "top left", tr: "top right", bl: "bottom left", br: "bottom right" };
+const PLACE_WORDS: Record<string, string> = { footage: "over the footage", deck: "in the deck" };
export default function GapCueTools({
gap,
@@ -227,6 +228,24 @@ export default function GapCueTools({
</select>
</label>
<label className="flex items-center gap-1">
+ <span className="micro">where</span>
+ <select
+ data-gap-cue-place=""
+ className={sel}
+ disabled={busy}
+ value={own?.place ?? ""}
+ title="over the footage at its corner, or in the deck's band at the end of the source line (umtool set <p> <clip> gapCue.place=footage|deck)"
+ onChange={(e) => void writeCue({ place: e.target.value === "" ? null : e.target.value })}
+ >
+ <option value="">as the project’s ({PLACE_WORDS[project.place] ?? project.place})</option>
+ {GAP_CUE_PLACES.map((p) => (
+ <option key={p} value={p}>
+ {PLACE_WORDS[p] ?? p}
+ </option>
+ ))}
+ </select>
+ </label>
+ <label className="flex items-center gap-1">
<span className="micro">label</span>
<input
data-gap-cue-label=""
diff --git a/umtool/components/projects/review/GapMarkChip.tsx b/umtool/components/projects/review/GapMarkChip.tsx
@@ -1,14 +1,14 @@
"use client";
import { useEffect, useRef, useState } from "react";
-import { GAP_CUE_LOOK } from "yt-dlp-transcript-common/lib/report/gapCue.mjs";
+import { GAP_CUE_LOOK, gapCueBoxStyle } from "yt-dlp-transcript-common/lib/report/gapCue.mjs";
-// THE GAP MARK OVER A PLAYER (lane gap-cue, slice 1b): "» 27 s" at a clip gap's join, drawn where the render
-// draws it -- Play the cut over its footage, the clip bench over its picture -- at the second
-// lib/report/gapCueView.mjs says (common gapCue.mjs's timing, the build's own). The look is common GAP_CUE_LOOK,
-// the numbers the build's drawtext reads (gap-mark.mjs), in the frame's proportions (cqmin: the frame's short
-// side): Plex Mono Bold, the box round it in ems, its border, the inset; the box over the border's colour inside
-// the border, as the build lays its two boxes; the text, its box and its border faded together. Nothing to press.
+// THE GAP MARK OVER A RAW PICTURE (lane gap-cue, slice 1b; 1d): "» 27 s" at a clip gap's join, drawn where the
+// drawtext path draws it -- Play the cut of a cut with no deck, the clip bench over its source picture. Under a
+// deck, Play shows the gap-cue module's own page instead (its live preview: ModuleLayers). At the second
+// lib/report/gapCueView.mjs says (common gapCue.mjs's timing, the build's own). The look is common gapCueBoxStyle --
+// the box the module's page draws too (gapCueCss) -- in the frame's proportions (cqmin: the frame's short side),
+// in Plex Mono Bold as the drawtext draws it; the text, its box and its border faded together. Nothing to press.
//
// box where the mark stands inside the frame (Play's deck: the footage's rect, in % of the frame); the whole
// frame when absent
@@ -17,12 +17,6 @@ import { GAP_CUE_LOOK } from "yt-dlp-transcript-common/lib/report/gapCue.mjs";
export type GapMarkCorner = "tl" | "tr" | "bl" | "br";
-/** `#rrggbb` at `a`, for CSS. */
-const rgba = (hex: string, a: number) => {
- const n = Number.parseInt(hex.replace(/^#/, ""), 16);
- return `rgba(${(n >> 16) & 255}, ${(n >> 8) & 255}, ${n & 255}, ${a})`;
-};
-
export default function GapMarkChip({
mark,
corner,
@@ -66,16 +60,10 @@ export default function GapMarkChip({
<span
data-gap-mark-chip={mark.text}
data-gap-mark-alpha={mark.alpha.toFixed(2)}
- className="absolute whitespace-nowrap font-mono font-bold leading-[1.2]"
+ className="absolute font-mono font-bold"
style={{
...at,
- fontSize: `max(9px, ${L.font * 100}cqmin)`,
- padding: `${L.pad}em`,
- color: L.fg,
- border: `max(1.5px, ${L.stroke * 100}cqmin) solid ${rgba(L.strokeColor, L.strokeAlpha)}`,
- // The build's two boxes: its box over the border's colour (gap-mark.mjs gapMarkFilters).
- background: `linear-gradient(${rgba(L.box, L.boxAlpha)}, ${rgba(L.box, L.boxAlpha)}), ${rgba(L.strokeColor, L.strokeAlpha)}`,
- backgroundClip: "padding-box",
+ ...gapCueBoxStyle({ font: `max(9px, ${L.font * 100}cqmin)`, stroke: `max(1.5px, ${L.stroke * 100}cqmin)` }),
opacity: mark.alpha,
// Never off its box: a long label and reason end "…" (the build shrinks the face first: gap-mark.mjs gapMarkFit).
maxWidth: `calc(100% - ${2 * L.inset * 100}cqmin)`,
diff --git a/umtool/components/projects/review/playCore.tsx b/umtool/components/projects/review/playCore.tsx
@@ -385,7 +385,11 @@ export function PlayStage({ core, basic = false, plainClassName }: { core: PlayC
[item, cueEntry],
);
const gapMark = gapMarks.length ? gapMarkAt(gapMarks, t) : null;
- const gapCorner = gapMarkCorner(gapMark?.corner ?? cueEntry?.gapCue?.corner, { deck: !!doc });
+ // Under a deck the gap-cue module's page draws it (ModuleLayers) -- except for a clip whose segment drew its marks
+ // INTO its picture (the schedule's gapCue.inSegment: built with no chrome drawing them): the render shows those,
+ // and Play's footage is the source, so the chip stands in for them at the deck's corner.
+ const gapInSegment = !!item && !!doc && ((doc.schedule as { gapCue?: { inSegment?: string[] } }).gapCue?.inSegment ?? []).includes(item.id);
+ const gapCorner = gapMarkCorner(gapMark?.corner ?? cueEntry?.gapCue?.corner, { deck: gapInSegment });
const sideNow = item && sideEntry ? <SidePostOverlay project={project} take={take} clipId={item.id} side={sideEntry} s={Math.max(0, t - item.start)} published={asPublished} /> : null;
const postPlayer = (box2: { width: number; height: number }) =>
postNow ? (
@@ -508,7 +512,9 @@ 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>}
- {gapMarks.length > 0 && rect && (
+ {/* The gap mark under a deck is the gap-cue module's own page (a play layer, below): its live preview -- but
+ a clip whose segment drew its own (gapInSegment) has none there, so the chip shows what the render does. */}
+ {gapInSegment && gapMarks.length > 0 && rect && (
<GapMarkChip mark={gapMark} corner={gapCorner} box={{ left: pct(rect.x, g.W), top: pct(rect.y, g.H), width: pct(rect.width, g.W), height: pct(rect.height, g.H) }} testId="play-gap-mark" />
)}
{/* Over a full-frame item (full-frame.mjs) a layer that keeps no time of its own is not drawn (layerOff):
diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md
@@ -41,7 +41,7 @@ that generates it ([notes.md](notes.md)).
| `fx.zoom` — `{shot, focus, at?, hold?}`: a screenshot (a file in the project; a bare name under its `shots/` is written as `shots/<name>`) that comes up over the footage and pushes in on `focus` (`[left, top, right, bottom]`, fractions of the shot) — drawn once `render.chrome.fx.zoom` is on ([Effects](#effects)). **How long it stays**: up 0.2 s into the clip's clean span (rising in over 0.38 s), its focus box drawn 0.55 s later, the push at `at` (seconds into the clip; default as soon as the box has drawn) over 1 s, then a slow drift on the detail; it leaves with a 0.3 s fade 0.3 s before the clip's clean span ends — or, with `hold` (0.5–10 s), that long after the push lands (never past the clip's own leave) | — | `umtool set <p> <clip> fx.zoom='{"shot":"shots/x.png","focus":[0.1,0.2,0.9,0.4],"at":5.9,"hold":4}'` (`fx.zoom=` clears it) | `PUT /api/report/window {project, clip, "fx.zoom": {…} \| null}` |
| `fx.receipts`, `fx.punch`, `fx.quote`, `fx.punchIn`, `fx.speakers` — the clip's other effect fields (`[{shot, mark?, at?, hold?, label?}]` 1–4, `at` the source second a receipt flies in at (default: as the clip comes up), `hold` 0.5–10 s it stays once landed (on every one: they leave then, not with the clip), `label` a line of at most 80 characters in a band under the screenshot (when it was taken, what it is); the words to punch; `false`: no line; 1–8 source seconds inside the clip; `[{at, who: 0\|1}]`), each inert until its effect is on; `fx` is all of them at once. Checked by the build's own `validateFxEntries` | — | `fx.punch="the words"` `fx.punchIn='[231.4]'` · `fx='{…}'` sets them all, `fx=` clears every one | `PUT /api/report/window {project, clip, fx}` (or one `"fx.<field>"`) |
| `gaps` — `[{from, to}]`, SOURCE seconds cut out of the clip's middle: it renders as ONE segment of jump cuts (one pip, one card), not two clips with a crossfade ([below](#gaps-inside-a-clip)) | clip bench (Edit this clip), the waveform: **Select a gap** (`g`) or Alt + drag a span, **Cut gap** (`g`), **Hear it**; a click on a gap's band picks it: its settings and **Remove** under the waveform (`G`: put back the one at the playhead); **Undo** | `umtool window <p> <clip> --gap 12.3-15.1` (repeatable) · `--gap-remove 12.3` · `--gaps '12.3-15.1,20-20.6'` (`--gaps ''` clears) · `umtool set <p> <clip> gap.add=12.3-15.1 gap.remove=12.3 gaps=` · a gap's own: `gap.mark=12.3:off` `gap.why=12.3:dead-air` `gap.reason=12.3:walks off` `gap.corner=12.3:tr` (`…:default`, `gap.reason=12.3:` drop one) | `PUT /api/report/window {project, clip, token, gapAdd \| gapRemove \| gaps \| gapEdit}` |
-| `gapCue` — `{mark?, min?, corner?, label?}`: the mark at this clip's gaps' joins, over the project's `render.gapCue` ([below](#gaps-inside-a-clip)) | clip bench, under the waveform: **mark at joins**, **from** (s), **corner**, **label** | `umtool set <p> <clip> gapCue.mark=true gapCue.corner=tr` (`gapCue=` clears it) | `PUT /api/report/window {project, clip, token, gapCue}` |
+| `gapCue` — `{mark?, min?, corner?, label?, place?}`: the mark at this clip's gaps' joins, over the project's `render.gapCue` ([below](#gaps-inside-a-clip)) | clip bench, under the waveform: **mark at joins**, **from** (s), **corner**, **where**, **label** | `umtool set <p> <clip> gapCue.mark=true gapCue.corner=tr gapCue.place=deck` (`gapCue=` clears it) | `PUT /api/report/window {project, clip, token, gapCue}` |
`key=` (nothing after the `=`) clears a knob; in umtool, **Clear** beside a field (Audio: **Clear all**). A
claim's knobs are read from the clip that **stamps** it — the last clip carrying the claim id; the box on any other
@@ -284,23 +284,30 @@ seconds (`report-to-video/gaps.mjs` is the rule and both clocks).
others (**Cut gap** on a span touching one, `gap.add=`, `--gap`) keeps what they said of themselves: `why` and
`reason` when they all gave the same, the first `corner`, and its `mark` on when any was (off only when all were);
the bench's note says what it kept.
-- **The mark at the join** (`render.gapCue`, off by default; common `lib/report/gapCue.mjs` is the rule,
- `report-to-video/gap-mark.mjs` draws it): with `mark` on, each join a gap of `min` seconds or more (default 2) leaves
+- **The mark at the join** (`render.gapCue`, off by default; common `lib/report/gapCue.mjs` is the rule; under a deck
+ the **gap-cue module's pages** draw it, `report-to-video/gap-cue-slice.mjs` and `chrome-gap-cue.mjs`, elsewhere
+ `report-to-video/gap-mark.mjs`'s drawtext -- see **Where it is drawn** below): with `mark` on, each join a gap of `min` seconds or more (default 2) leaves
shows a small `» 27 s` near a corner of the footage for 1.1 s -- up over 0.15 s, held, down over 0.35 s; no sound.
It says the gap's reason when it has one: `» 26 s · dead air` (`label` is `» {s}[ · {why}]` by default: `{s}` the
time skipped, from a minute `1:12`; `{why}` the reason; a part in `[ ]` drawn only with one). The reason is the
gap's own words (`reason`, 1-24 characters) or its `why`'s word: `dead-air` "dead air", `idle` "idle", `other`
- nothing. THE LOOK is one set of numbers, common `GAP_CUE_LOOK`, which the build's drawtext and umtool's pages both
- read: IBM Plex Mono Bold at 3 % of the frame's short side (32 px at 1080), light text on a #101010 box at 86 % inside
- a 2 px white border at 90 %, the box 0.38 em round the text, inset 2.6 %; the text, box and border fade together.
+ nothing. THE LOOK is one set of numbers, common `GAP_CUE_LOOK`, which the module's page (as CSS: `gapCueCss`), the
+ drawtext and umtool's element over a raw picture (`gapCueBoxStyle`) all read: 3 % of the frame's short side (32 px
+ at 1080), light text on a #101010 box at 86 % inside a real 2 px white border at 90 %, the box 0.38 em round the
+ text, inset 2.6 %; the text, box and border fade together. The face: the deck's own bold (DeckSansBold) in the
+ module's page, IBM Plex Mono Bold in the drawtext (a cut with no deck has no deck face). The variant is one edit of
+ `GAP_CUE_LOOK` (stills of A white border, B accent border, C heavy: the operator picks; A is drawn).
Joins less than 1.1 s apart are ONE mark saying their seconds together (and their reason only when they all give
- the same). It is drawn into the clip's segment after its hidden regions and its blur (chrome over the footage,
- never blurred), at the layout's free corner (`corner: auto`): the deck's footage bottom left (its stamp stands top
- left, its posts top right), the plain cut's picture top left (never the corner code's corner), a vertical clip's
+ the same). It is chrome over the footage, never blurred, at the layout's free corner (`corner: auto`): the deck's
+ footage box bottom left (its stamp stands top left, its posts top right), the plain cut's picture top left (never
+ the corner code's corner), a vertical clip's
picture top left (framed, quote), its picture's top right (split: its captions are at the picture's foot) or the
safe area's top right (full bleed, desktop), and a twocrop clip's crop one top right -- every vertical mark inside
the safe area, whatever corner is asked; a hidden region up while the mark is, or a code, under that corner moves
- it to the next free one. A mark too wide for its box (a long label with a long reason on a 1080-wide frame) is
+ it to the next free one -- and under a deck so do the other modules over the footage while each is up: a stamp,
+ the popup posts' column, the chat column, a chapter's cover, the stats panel, and the effects' screenshots (the
+ receipts' fan, a column on their side; a zoom's card, centred -- each reckoned at its largest, since the page sizes
+ it to its shot). A mark too wide for its box (a long label with a long reason on a 1080-wide frame) is
drawn smaller, down to 75 % of its size, then cut to fit, ending `…`: never off its box. Its text is drawn as
written (`expansion=none`): a `%` or a `\` in a label or a reason is words; a tab or any other control character
is refused there. A clip cut from its pieces marks the join between two pieces too (the recording's seconds left
@@ -310,23 +317,88 @@ seconds (`report-to-video/gaps.mjs` is the rule and both clocks).
(`gap.corner=<s>:tr`; a stream's layout can change inside one clip), which wins over the clip's. Precedence: a gap's
own `mark` and `corner` over its clip's `gapCue` over `render.gapCue` (a look key: a preset, a style or a take patch
carries it -- `umtool look <p> gapCue='{"mark":true}'`, `umtool take <p> --id marks --set render.gapCue.mark=true`;
- the Media tab's Modules panel, **Gap mark**). Turning it on re-renders only the segments of clips with a
- marked gap of `min` or more, and the chunks over them; off, unset or under `min`, every segment is byte for byte
- what it was (its key is the same). Not drawn: a montage (it applies no gaps), `render.mode: basic` and **Export
- one clip** (the footage alone); a trailer beat cut across a marked join plays the master's mark. **Play the cut and
- the bench draw it too**, at the same seconds with the same text and look (`lib/report/gapCueView.mjs` lays out the
- joins and asks gapCue.mjs, the build's own timing): Play over the deck's footage or the plain picture, the bench over
- its picture. Where the pages differ from the render: they do not move it off a hidden region or a code as the build
- does; a vertical cut's page uses the deck's or the plain cut's corner; **Play stands it in the corner of the deck's
- footage box**, where the render stands it in the corner of the picture as fitted in that box (a 4:3 source in a 16:9
- box: the render's mark is that much further in); and **the bench sizes it from the source picture** (3 % of its
- short side as shown), where the render sizes it from the output frame's. A long text the pages cut with `…` at the
- box's width, without first drawing it smaller. The record says where each was drawn (`gapMarks` in
- `segments/<id>.cut.json`: its text as drawn, its corner and rect, the corner it asked for).
-- **`--chrome-only` rebuilds no clip segment**, and the mark is in the segment: a mark changed since the segment was
- built (turned on or off, its label, a gap's reason or corner) is laid as it was built, and the build says so, one
- note per clip (`<id>: its gap mark changed since its segment was built (…) — --chrome-only rebuilds no clip
- segment: build without it (or --only <id>) to draw it`).
+ the Media tab's Modules panel, **Gap mark**). Off, unset or under `min`, every segment, schedule and page is byte
+ for byte what it was (no module page, the schedule's `gapCue` key absent, every segment key the same). Not drawn: a montage (it applies no gaps), `render.mode: basic` and **Export
+ one clip** (the footage alone); a trailer beat cut across a marked join plays the master's mark.
+- **Where it is drawn** (lane gap-cue, slice 1d -- the first slice's decision REVERSED). Slice 1 drew the mark into
+ the clip's segment everywhere, because the plain, vertical and short paths run no chrome. But most cuts run the
+ deck, and there a segment mark cost a clip re-encode for every change (on, corner, label, reason), could not be
+ retrofitted with `--chrome-only`, and was a second preview beside the module contract's own (every other overlay
+ on the picture -- Stamps, Effects, Popup posts, Chapters -- is a HyperFrames page that is its own live preview). So:
+ - **wherever a deck is drawn over the picture** (`render.chrome`, the HyperFrames deck: landscape, the feed, the
+ stacked vertical deck and its twocrop clips; `--clip-preview` too, which lays the deck over its clip): the
+ **gap-cue module** (`modules/gap-cue.mjs`, `overlay-window`, z 35: over the popup posts, under the stamps) --
+ one short transparent page per mark over the frame, laid at its own seconds (`chrome/gap-cue-<clip>.g<k>-frames`,
+ about 33 frames each at 30 fps). Its position over the footage is the footage BOX's corner (as the stamps'), not
+ the picture as fitted in it (the drawtext's: a 4:3 source in a 16:9 box puts that mark further in). The clip's
+ segment draws none: its argv and record are the plain ones.
+ - **where no chrome is laid over the picture** -- no `render.chrome` (the plain letterbox cut), `--no-chrome`, a bare
+ vertical cut, `--desktop`, `--short` -- the drawtext into the segment, as slice 1 built it.
+ - Never both on one frame: a segment whose record carries `gapMarks` (it drew them) is left out of the chrome's
+ marks (the schedule's `gapCue.inSegment`). The build says which draws, once: `gap mark: drawn by the gap-cue page
+ (chrome)` or `gap mark: drawn into the clip segments (no chrome for the picture: <why>)`.
+ - **The joins** come from each clip's cut record -- its `start`, `end` and `gaps`, the seconds its segment really
+ left out (between a clip's pieces too) -- which the schedule already reads. A record written before this slice
+ has them, so **an old take gets its marks from a chrome-only re-render, no re-cut**: `umtool look <p>
+ gapCue='{"mark":true}'`, then a `--chrome-only` take. The marks are on the schedule (`schedule.json`'s `gapCue`:
+ each mark's cut seconds, text, place, corner, rect). **The record decides**: a segment cut before its clip had
+ gaps (no `gaps` in its record) plays them, so it has no join to mark -- a `--chrome-only` pass draws none there and
+ says `<id>: its segment was cut before its gaps — the footage plays them and no gap mark is drawn for them; rebuild
+ it …`. Only with no record at all (Play's preview before any build) do the clip's play window and its gaps stand in.
+ - **Around a dissolve**: a mark is gone before the dissolve into the next segment begins (its picture is the next
+ clip's by then) -- one that would run on into it ends there, faded out by then, and one left shorter than 0.2 s is
+ not drawn; a mark cut short rises only as far as its ramps meet (as the drawtext's alpha does), never a flash to
+ full. A mark at a join inside the first dissolve of a clip that follows a full-frame item (a teaser, the intro, a
+ card the deck hides over) is not drawn until that item's dissolve out ends, as every layer that keeps no time of
+ its own (full-frame.mjs).
+ - **`place`** (`render.gapCue.place`, a clip's `gapCue.place`; `umtool look <p> gapCue='{"place":"deck"}'`, `umtool
+ set <p> <clip> gapCue.place=deck`, the bench's **where**, the Modules panel): `footage` (default) over the footage
+ box at its corner; `deck` in the deck's band, right-aligned at the end of the source line's row (22 px short of
+ the text column's end: left of the QR's plate and of a tally beside it), centred on the row, a size under the
+ source line (90 % of its text; an untitled clip's on its promoted row, in a two-line deck on the meta line). The
+ deck's own page is not touched -- the source line keeps every word, the source status at its end included -- so
+ the mark stands there only when the line at its longest (its status's long form too) and the mark both fit the
+ row with air between (24 px); otherwise (a long source title, a tally narrowing the column) it is drawn over the
+ footage instead, as `footage` draws it (the schedule's mark says `fell: "row"`). The line is reckoned in the face
+ the deck sets it in -- the brand's IBM Plex Mono when `render.brand` is set, else the wider of a sans's advances
+ and a mono's -- with the separators' padding (0.42 em either side of each dot) and the letter-spacing, each glyph
+ rounded up to a whole pixel (Plex Mono at 26 px: reckoned 544 px, drawn 543.7). **And the page never trusts the
+ reckoning alone**: it lays a hidden copy of the source line (the deck's markup, faces and size) on its row and,
+ once its faces are in, if the line's end and the air after it reach the mark, it stands the mark at its footage
+ place instead (`data-fell="line"` on the element). Likewise in the stacked vertical deck (its band is laid
+ otherwise: `fell: "stacked"`) and in a cut with no deck. (A segment that hides the deck, `fell: "hidden"`, is a
+ guard: a clip never hides it.) The live preview measures the line as the manifest has it, not a line typed in Play.
+ - **What re-renders**, under a deck (chunks: the hard-cut chunked encode's, keyed on the frames they read):
+ - the mark on for a take: no clip segment; one small page per mark and the chunks over its seconds (`--chrome-only`
+ does it);
+ - a corner, a place (footage ↔ deck), a label, a reason or a `why`: the pages whose text or rect changes, and
+ their chunks -- never a segment, never the deck's own page;
+ - `min`, or the mark off on a clip or a gap: those pages gone or added, and their chunks;
+ - with no deck (the drawtext path), as slice 1: the clip's segment, then the chunks over it.
+ The deck's lazy capture (only the frames the chunks to encode read) stays on beside the gap-cue pages: their frame
+ keys are composed without drawing a frame (compose-chrome `keysOnly`, build-video `deckWant`), so the chunks over
+ a mark's seconds are known before any layer is captured. Measured on a two-chunk test cut, the retrofit asks for
+ the 31 deck frames of the one chunk the mark is in and draws 8 (the rest keyed the same), where without it all 60
+ were asked for and 37 drawn (with any OTHER window module on, every deck frame is asked for, as before).
+ - **A take that drew marks into its segments under a deck** (possible since the first slice's merge with the mark on
+ -- it is off by default): its next build changes those segments' keys ONCE, back to the plain segment's (a
+ rebuild, or the plain one reused from the cache when it is there), and the chrome draws the marks from then on.
+ A `--chrome-only` pass over such a segment leaves the chrome's marks out for it (never twice) and says so, one note
+ per clip: while the mark is wanted, `<id>: its gap marks are drawn in its segment (built with no chrome drawing
+ them) — --chrome-only leaves the chrome's out for it; rebuild it (a build without --chrome-only, or --only <id>) to
+ let the chrome draw them`; once it is off, `<id>: its segment still shows gap marks that are no longer wanted —
+ --chrome-only cannot take them out; rebuild it …`. Play shows such a clip's marks with the element over its
+ footage at the deck's corner (Play plays the source, not the segment that carries them).
+- **Play the cut and the bench**: under a deck, **Play shows the module's own page** (a play layer, seeked on the
+ cut's clock: the build's pixels, at the build's place and corner, hopped as the build hops it) -- no second drawing.
+ With no deck, Play and the bench draw an element over the raw picture at the same seconds with the same text and
+ look (`lib/report/gapCueView.mjs` lays out the joins and asks gapCue.mjs, the build's own timing; `GapMarkChip`, from
+ the same `gapCueBoxStyle` the page's CSS is): it does not move off a hidden region or a code as the build does; a
+ vertical cut's page uses the deck's or the plain cut's corner; **the bench sizes it from the source picture** (3 %
+ of its short side as shown). A clip whose mark is placed in the deck shows no element over the bench's picture
+ (the band is not there): a line under it says `» 27 s · in the deck`. A long text the element cuts with `…` at its
+ box's width, without first drawing it smaller. On the drawtext path the record says where each was drawn
+ (`gapMarks` in `segments/<id>.cut.json`: its text as drawn, its corner and rect, the corner it asked for).
- **Play the cut** plays the clip as one item: its sound one span per kept piece on the cut's clock with the same
fades, the picture past the gap at the join, the clock and the scrub bar in cut seconds, a dashed tick on the reel
strip at each jump.
@@ -3011,9 +3083,9 @@ filter. A knob absent is its default, and a module whose knobs are all absent dr
| [Teaser](#teaser) `teaser` | A full-frame card of lines popping in on the beat, inserted as its own segment. (a segment cut into the timeline) | -- |
| [Intro](#intro) `intro` | The brand sting the cut opens with, a site's name swapped in on the chime. (a segment cut into the timeline) | `render.intro` |
| [Blur](#blur) `blur` | A clip's picture blurred at its encode, a caption on it, the sound as recorded. (a filter on the footage) | `render.blur` |
-| [Gap mark](#gap-mark) `gap-cue` | A small mark at each join a clip's gap leaves, saying how much was skipped. (a filter on the footage) | `render.gapCue` |
| [Posts feed](#posts-feed) `feed` | The cut's posts in a column beside the footage, each ticking in as its clip starts. (a page over the whole cut) | `render.chrome.deck.posts` |
| [Popup posts](#popup-posts) `popup-posts` | A clip's posts as cards over the footage, each window its own short page at its own second. (pages at their own seconds) | `render.chrome.deck.posts` |
+| [Gap mark](#gap-mark) `gap-cue` | A small mark at each join a clip's gap leaves, saying how much was skipped: a page per mark, at its own seconds. (pages at their own seconds) | `render.gapCue` |
| [Stamps](#stamps) `stamp` | Each counted mark's word, stamped over the footage as it lands. (a page over the whole cut) | `render.chrome.factcheck.stamp` |
| [Live chat](#live-chat) `chat` | A stream's chat replay scrolled in a column beside the footage, over the clips that ask for it. (a page over the whole cut) | `render.chrome.chat` |
| [Stats](#stats) `stats` | A frame scan's running numbers over the clips that declare them. (a page over the whole cut) | `render.chrome.stats` |
@@ -3046,7 +3118,7 @@ it can be seeked. `POST /api/report/chrome/preview` returns every such module th
build's predicate) as `layers: [{id, z, region, clock, ready, geometry, src | windows}]`; the client lays them
by z over the deck's page, a whole-cut page for the whole cut, a window module's page only inside each window.
-Declaring `play`: `stats`, `pair`, `status`, `fx`, `shelf`, `streak`, `diet`, `peak`, `goals`, `threads`, `dial`, `odometer`, `trail`, `flips`, `chapter`, `runs-finale`, `dial-finale`, `promise`.
+Declaring `play`: `gap-cue`, `stats`, `pair`, `status`, `fx`, `shelf`, `streak`, `diet`, `peak`, `goals`, `threads`, `dial`, `odometer`, `trail`, `flips`, `chapter`, `runs-finale`, `dial-finale`, `promise`.
Still drawn by their own paths (the response's `src`, `feed`, `posts`, `stamp` and `finale` keys), and what moving
each onto `play` needs: the deck (`shell`) -- its typed words patched in live (`deck:text`) and the `deck:ready`
@@ -3178,19 +3250,6 @@ The full reference is [A clip's picture, blurred](#a-clips-picture-blurred).
| `render.blur` | `on` · `off` (the uncensored variant) · default `on` | `umtool look <p> blur=off` |
| a clip's `blur` | `{on, caption?, strength?, from?, to?}` -- caption ≤ 120, strength 2–15 (default 5) | `umtool set <p> <clip> blur.on=true` |
-### Gap mark
-
-The full reference is [Gaps inside a clip](#gaps-inside-a-clip) (the mark at the join).
-
-| Knob | Range · default | From a terminal |
-|---|---|---|
-| `render.gapCue.mark` | `true` · `false` · default `false` (off: every cut renders as it did) | `umtool look <p> gapCue='{"mark":true}'` · a take: `--set render.gapCue.mark=true` |
-| `render.gapCue.min` | 0.5–60 s · default 2 (a shorter gap draws nothing) | `umtool look <p> gapCue='{"min":4}'` |
-| `render.gapCue.corner` | `auto` (the layout's free corner) · `tl` · `tr` · `bl` · `br` · default `auto` | `umtool look <p> gapCue='{"corner":"br"}'` |
-| `render.gapCue.label` | text holding `{s}` (the time skipped: `27 s`, from a minute `1:12`) and maybe `{why}` (the gap's reason); a part in `[ ]` is drawn only when the gap has one; at most 40 characters · default `» {s}[ · {why}]` (`» 27 s`, `» 26 s · dead air`) | `umtool look <p> gapCue='{"label":"{s} later"}'` |
-| a clip's `gapCue` | the same keys, over the project's | `umtool set <p> <clip> gapCue.mark=false gapCue.corner=tr` (`gapCue=` clears them) |
-| a gap's `mark`, `why`, `reason`, `corner` | `mark` `true` · `false` (over the clip's and the project's); `why` `dead-air` · `idle` · `other` (the mark says "dead air", "idle", nothing); `reason` its own words, 1-24 characters, said instead; `corner` `tl` · `tr` · `bl` · `br` (its mark there, over the clip's) | `umtool set <p> <clip> gap.mark=12.3:off gap.why=12.3:dead-air gap.reason=12.3:walks off gap.corner=12.3:tr` (`…:default`, `gap.reason=12.3:` drop one) · the bench: click the gap's band |
-
### Posts feed
`deck.posts.layout: "feed"` with posts to draw: a column for the whole cut, each post ticking in as its clip starts; no hold, no footage move. Shares `deck.posts` with the popup posts.
@@ -3214,6 +3273,20 @@ A clip's posts as cards over the footage (`deck.posts`, the `popup` layout), eac
| `deck.posts.shotMaxHeight` | null · 120–1080 px · default null (a full card of words) | same |
| `deck.posts.persist` | `true` · `{seconds 8–60, gap 0–30}` · `false`/absent (off: each clip's posts its own short window, as above) · default seconds 12, gap 6. On: the footage NEVER freezes (`hold` is ignored). A card comes up at its moment (`at`, as above) and stays up on its own clock for `seconds`, over clip joins and dissolves. A post whose moment comes while the bar is up, or within `gap` after it would go, keeps it up: a later clip's cards SWAP in (the cards up slide up and out as the new one lands — the bar holds one clip's posts at a time, so stale cards never pile up over the footage), a clip's own still stack. With no post soon it leaves (0.45 s fade). The bar never runs into a card, a teaser, an image or the finale: it is gone by the transition into one. `shift` spans it too: the footage stays aside across the joins the bar spans, every segment moving on the cut's clock, and glides back as the bar leaves (a segment that starts as it leaves comes in at its normal box). Absent, every render is byte for byte what it was | `umtool look <p> deck.posts.persist='{"seconds":12,"gap":6}'` (`deck.posts.persist=` off) |
+### Gap mark
+
+The full reference is [Gaps inside a clip](#gaps-inside-a-clip) (the mark at the join). Under a deck the mark is this module's page, one per mark; with no chrome over the picture it is drawn into the clip's segment.
+
+| Knob | Range · default | From a terminal |
+|---|---|---|
+| `render.gapCue.mark` | `true` · `false` · default `false` (off: every cut renders as it did) | `umtool look <p> gapCue='{"mark":true}'` · a take: `--set render.gapCue.mark=true` |
+| `render.gapCue.min` | 0.5–60 s · default 2 (a shorter gap draws nothing) | `umtool look <p> gapCue='{"min":4}'` |
+| `render.gapCue.place` | `footage` (over the footage, at its corner) · `deck` (in the deck's band, at the end of the source line, left of the QR -- over the footage where the row has no room, in the stacked vertical deck and in a cut with no deck; the page measures the line in its own faces and never stands the mark on it) · default `footage` | `umtool look <p> gapCue='{"place":"deck"}'` |
+| `render.gapCue.corner` | `auto` (the layout's free corner) · `tl` · `tr` · `bl` · `br` · default `auto` | `umtool look <p> gapCue='{"corner":"br"}'` |
+| `render.gapCue.label` | text holding `{s}` (the time skipped: `27 s`, from a minute `1:12`) and maybe `{why}` (the gap's reason); a part in `[ ]` is drawn only when the gap has one; at most 40 characters · default `» {s}[ · {why}]` (`» 27 s`, `» 26 s · dead air`) | `umtool look <p> gapCue='{"label":"{s} later"}'` |
+| a clip's `gapCue` | the same keys, over the project's | `umtool set <p> <clip> gapCue.mark=false gapCue.corner=tr gapCue.place=deck` (`gapCue=` clears them) |
+| a gap's `mark`, `why`, `reason`, `corner` | `mark` `true` · `false` (over the clip's and the project's); `why` `dead-air` · `idle` · `other` (the mark says "dead air", "idle", nothing); `reason` its own words, 1-24 characters, said instead; `corner` `tl` · `tr` · `bl` · `br` (its mark there, over the clip's) | `umtool set <p> <clip> gap.mark=12.3:off gap.why=12.3:dead-air gap.reason=12.3:walks off gap.corner=12.3:tr` (`…:default`, `gap.reason=12.3:` drop one) · the bench: click the gap's band |
+
### Stamps
Each counted mark's word stamped over the footage as it lands (`render.chrome.factcheck.stamp`); the word is the mark's `label`, else its series' `stampLabel`, else its label.
diff --git a/umtool/e2e/fixtures/make-fixture.mjs b/umtool/e2e/fixtures/make-fixture.mjs
@@ -2013,6 +2013,18 @@ makeMediaScenesFixture({ reports, deckManifest });
mkdirSync(path.join(dir, "out", "clips-raw"), { recursive: true });
copyFileSync(path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), path.join(dir, "out", "clips-raw", "gapcuevid_0.00-9.00.mp4"));
}
+// The gap mark under a DECK (lane gap-cue, slice 1d; gap-cue.spec.ts, which WRITES): the same two clips in a deck
+// cut, so the mark is the gap-cue module's page -- Play the cut lays it as a play layer. Its own project and window.
+{
+ const g = deckManifest("gapcue-deck-fixture", "The Gap Mark Deck Fixture", [
+ { type: "clip", id: "gd01", video: "gapdeckvid", start: 0.5, end: 8.5, cite: 1, section: 0, lock: true, quote: "a clip with a marked gap", onscreen: { title: "A marked gap" } },
+ { type: "clip", id: "gd02", video: "gapdeckvid", start: 1.0, end: 3.0, cite: 1, section: 0, lock: true, quote: "the clip after it", onscreen: { title: "After it" } },
+ ]);
+ g.render.fetchPad = 0;
+ const dir = writeProject("gapcue-deck-fixture", g);
+ mkdirSync(path.join(dir, "out", "clips-raw"), { recursive: true });
+ copyFileSync(path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), path.join(dir, "out", "clips-raw", "gapdeckvid_0.00-9.00.mp4"));
+}
// Fetch more from where the edge is now (clip-bench.spec.ts): one clip, r01 reachvid 300-306, on a
// recording a thousand seconds long; nothing cached -- the spec fetches through the editor stub.
writeProject(
diff --git a/umtool/e2e/gap-cue.spec.ts b/umtool/e2e/gap-cue.spec.ts
@@ -178,3 +178,55 @@ test("the Modules panel: the project's label, and Play's mark says it", async ({
const seen = await playAndWatch(page, 4.5);
expect(seen.filter((s) => s.t > 3.2 && s.t < 3.9).map((s) => s.text)).toContain("2 s later");
});
+
+// ---- under a deck (slice 1d): the mark is the gap-cue module's own page ----------------------------------------
+// gapcue-deck-fixture: the same two clips in a deck cut, never built -- Play plays it on the estimate's clock, where
+// gd01 plays 0.5-8.5 less 3.5-5.5 from the cut's start, so the mark is up 3.0-4.1 s.
+
+const DECK = "reports/gapcue-deck-fixture";
+const DECK_MANIFEST = path.join(HERE, "..", ".e2e-song", "reports", "gapcue-deck-fixture", "video.manifest.json");
+const readDeck = () => JSON.parse(readFileSync(DECK_MANIFEST, "utf8")) as Manifest;
+const deckToken = async (request: APIRequestContext, clip = "gd01") =>
+ ((await (await request.get(`/api/report/clip?project=${encodeURIComponent(DECK)}&clip=${clip}`)).json()) as { token: string }).token;
+const putDeckWindow = async (request: APIRequestContext, data: Record<string, unknown>) =>
+ request.put("/api/report/window", { data: { project: DECK, clip: "gd01", token: await deckToken(request), ...data } });
+const putDeckLook = async (request: APIRequestContext, patch: Record<string, unknown>) => {
+ const t = ((await (await request.get(`/api/report/render?project=${encodeURIComponent(DECK)}`)).json()) as { token: string }).token;
+ return request.put("/api/report/render", { data: { project: DECK, token: t, patch } });
+};
+/** The mark's element inside the gap-cue layer's own page, and its opacity there (the build's pixels, seeked by Play). */
+const layerMark = (page: Page) => page.frameLocator('[data-testid="play-layer-gap-cue-iframe"]').locator(".gm[data-gm]");
+
+test("under a deck, Play shows the gap-cue module's own page: up inside its window saying the reason, no hand-drawn chip; the bench's where writes place", async ({ page, request }) => {
+ let r = await putDeckWindow(request, { gaps: [{ from: 3.5, to: 5.5, why: "dead-air" }], gapCue: null });
+ expect(r.ok(), await r.text()).toBeTruthy();
+ r = await putDeckLook(request, { gapCue: { mark: true } });
+ expect(r.ok(), await r.text()).toBeTruthy();
+ await page.setViewportSize({ width: 1366, height: 1000 });
+ // 3.4 s into the cut: the mark is up (3.0-4.1).
+ await page.goto(urls.playHref(DECK, { clip: "gd01", at: 3.4 }));
+ const root = page.locator("[data-play-cut]");
+ await expect(root).toHaveAttribute("data-play-edges", "render", { timeout: 30_000 });
+ await expect(page.locator('[data-testid="play-deck"]')).toBeVisible({ timeout: 30_000 });
+ const layer = page.locator('[data-play-layer="gap-cue"]');
+ await expect(layer).toHaveAttribute("data-play-layer-segment", "gd01.g0", { timeout: 30_000 });
+ await expect(layer).toHaveAttribute("data-play-layer-up", "1");
+ await expect(page.getByTestId("play-layer-gap-cue")).toHaveAttribute("data-feed-ready", "1", { timeout: 30_000 });
+ await expect(layerMark(page)).toHaveAttribute("data-gm", "» 2 s · dead air");
+ await expect.poll(() => layerMark(page).evaluate((el) => Number(getComputedStyle(el).opacity)), { timeout: 10_000 }).toBeGreaterThan(0.8);
+ await expect(page.locator("[data-gap-mark-chip]")).toHaveCount(0);
+ await page.screenshot({ path: test.info().outputPath("play-deck-gap-mark.png") });
+ // Past its window: the layer is down.
+ await page.goto(urls.playHref(DECK, { clip: "gd01", at: 5 }));
+ await expect(root).toHaveAttribute("data-play-edges", "render", { timeout: 30_000 });
+ await expect(page.locator('[data-play-layer="gap-cue"][data-play-layer-up="1"]')).toHaveCount(0);
+
+ // The bench's where: in the deck (the CLI's gapCue.place).
+ await page.goto(urls.clipBenchHref(DECK, "gd01"));
+ await page.locator("[data-wave-box]").scrollIntoViewIfNeeded();
+ await page.locator("[data-gap-cue-place]").selectOption("deck");
+ await expect.poll(() => readDeck().timeline.find((e) => e.id === "gd01")!.gapCue?.place).toBe("deck");
+ // Back off for the next run.
+ expect((await putDeckWindow(request, { gaps: [{ from: 3.5, to: 5.5 }], gapCue: null })).ok()).toBeTruthy();
+ expect((await putDeckLook(request, { gapCue: null })).ok()).toBeTruthy();
+});
diff --git a/umtool/lib/report/knobsCli.mjs b/umtool/lib/report/knobsCli.mjs
@@ -58,7 +58,7 @@ const GAP_KEYS = ["gaps", "gap.add", "gap.remove", "gap.mark", "gap.why", "gap.r
/** A gap's own settings (`gapEdit` on the window writer): its mark, why, reason and corner. */
const GAP_OWN_SET_KEYS = ["gap.mark", "gap.why", "gap.reason", "gap.corner"];
/** The mark at this clip's gaps' joins (common gapCue.mjs): its own settings over the project's render.gapCue. */
-export const GAP_CUE_SET_KEYS = Object.freeze(["gapCue", "gapCue.mark", "gapCue.min", "gapCue.corner", "gapCue.label"]);
+export const GAP_CUE_SET_KEYS = Object.freeze(["gapCue", "gapCue.mark", "gapCue.min", "gapCue.corner", "gapCue.label", "gapCue.place"]);
export const VERTICAL_SET_KEYS = Object.freeze(["vertical", "vertical.crop", "vertical.layout", "vertical.aspect", "vertical.crops"]);
export const SIDE_SET_KEYS = Object.freeze(["side", "side.item", "side.post", "side.from", "side.to", "side.place"]);
/** The clip kit (lane clip-kit; report-to-video clip-kit.mjs): a clip's code in a per-clip build, its batch file name. */
@@ -144,6 +144,7 @@ export const SET_USAGE = [
" stands its mark in that corner (its seconds never move).",
" gapCue.mark=true|false gapCue.min=<s> gapCue.corner=auto|tl|tr|bl|br gapCue.label='» {s}' the mark at this",
" clip's gaps' joins, over the project's (umtool look <p> gapCue='{\"mark\":true}'); `gapCue=` clears them.",
+ " gapCue.place=footage|deck: over the footage at its corner, or in the deck's band at the end of the source line.",
].join("\n");
export const LOOK_USAGE = [
diff --git a/umtool/lib/report/layerPreview.test.mjs b/umtool/lib/report/layerPreview.test.mjs
@@ -48,6 +48,11 @@ test("the files route serves a layer's project by its name, a window's only for
assert.equal(layerPreviewOf("chapter-preview-b", ["a", "b"]), "chapter-preview-b");
assert.equal(layerPreviewOf("chapter-preview-zz", ["a", "b"]), null);
assert.equal(layerPreviewOf("chapter-preview-..", [".."]), null);
+ // The gap mark's windows are its marks (`<entry>.g<k>`), served for the cut's own entries only.
+ assert.equal(layerPreviewOf("gap-cue-preview-b.g0", ["a", "b"]), "gap-cue-preview-b.g0");
+ assert.equal(layerPreviewOf("gap-cue-preview-b.g12", ["b"]), "gap-cue-preview-b.g12");
+ assert.equal(layerPreviewOf("gap-cue-preview-zz.g0", ["a", "b"]), null);
+ assert.equal(layerPreviewOf("gap-cue-preview-b", ["b"]), null, "a mark id, not an entry's");
assert.equal(layerPreviewOf("deck-preview"), null);
assert.deepEqual(previewDirFor("/p", "sourced", ["status-preview", "index.html"], []), { dir: "/p/out/sourced/chrome/status-preview", rest: ["index.html"] });
// The deck's own preview, as it always was.
diff --git a/umtool/lib/report/onscreen.mjs b/umtool/lib/report/onscreen.mjs
@@ -47,6 +47,9 @@ import {
import { marksOf, rawMarksOf, roundStamps, stampSchedule } from "umtool-report-to-video/factcheck";
import { clipSourceStatus, subtitleStatusOn } from "umtool-report-to-video/source-status";
import { setMarks } from "./knobs.mjs";
+// The gap marks the gap-cue module draws (gap-cue-slice.mjs): as the settings are NOW, from the cut records.
+import { withGapCue } from "umtool-report-to-video/gap-cue-slice";
+import { gapCueWanted } from "yt-dlp-transcript-common/lib/report/gapCue.mjs";
import {
channelsDirFor,
cuePathFor,
@@ -197,7 +200,16 @@ export function scheduleMatches(schedule, entries) {
* claimsDraft?: Map<string, { id: string, verdict: string } | null> }} args
* @returns {DeckSchedule}
*/
-export function previewSchedule({ variantManifest, built, draft, metas, postsDraft = {}, claimsDraft = new Map() }) {
+export function previewSchedule({ variantManifest, built, draft, metas, postsDraft = {}, claimsDraft = new Map(), gapRecords = null }) {
+ // The gap marks as the settings are NOW (gap-cue-slice.mjs), over whichever schedule this is: the build's
+ // segments with the cut records' joins, or the estimate's with the play windows'. None wanted: the key absent.
+ const gapped = (doc) => withGapCue(doc, {
+ entries: variantManifest.timeline ?? [], render: variantManifest.render ?? {}, records: gapRecords, provenance: variantManifest.provenance ?? {},
+ });
+ return gapped(previewScheduleOf({ variantManifest, built, draft, metas, postsDraft, claimsDraft }));
+}
+
+function previewScheduleOf({ variantManifest, built, draft, metas, postsDraft, claimsDraft }) {
const entries = variantManifest.timeline ?? [];
const posts = applyPostsDraft(variantManifest.posts ?? [], postsDraft);
const patched = (e) => {
@@ -488,7 +500,24 @@ export async function scheduleForPreview(
const variantManifest = found.size
? { ...selected, posts: posts.map((p) => (!p.siteChannel && found.has(p.id) ? { ...p, siteChannel: found.get(p.id) } : p)) }
: selected;
- return { variantManifest, metas, schedule: previewSchedule({ variantManifest, built, draft, metas, postsDraft, claimsDraft }) };
+ // The cut records of the clips with a marked gap (the build's schedule's clock): what their marks are taken from.
+ const gapRecords = built ? await readGapRecords(project.dir, variant, variantManifest) : null;
+ return { variantManifest, metas, schedule: previewSchedule({ variantManifest, built, draft, metas, postsDraft, claimsDraft, gapRecords }) };
+}
+
+/** The cut records (`out/<variant>/segments/<id>.cut.json`) of the clips whose gaps are marked; the ones on disk. */
+async function readGapRecords(dir, variant, manifest) {
+ const out = new Map();
+ for (const e of manifest.timeline ?? []) {
+ if (e?.type !== "clip" || !Array.isArray(e.gaps) || !e.gaps.length || !gapCueWanted(manifest.render ?? {}, e)) continue;
+ if (!/^[A-Za-z0-9_.:-]+$/.test(String(e.id))) continue;
+ try {
+ out.set(e.id, JSON.parse(await readFile(path.join(dir, "out", variant, "segments", `${e.id}.cut.json`), "utf8")));
+ } catch {
+ // Not built yet: its play window stands in.
+ }
+ }
+ return out.size ? out : null;
}
/**
diff --git a/umtool/lib/report/onscreen.test.mjs b/umtool/lib/report/onscreen.test.mjs
@@ -504,3 +504,36 @@ test("composeStampPreview: compose-chrome's stamp region, into stamp-preview, re
/not \/proj\/out\/sourced\/chrome\/stamp-preview/,
);
});
+
+test("the gap marks over a matching build's schedule come from its cut records (review 1d, 10): the record's start and gaps, not the play window's; a record with no gaps marks nothing", async () => {
+ const dir = await mkdtemp(path.join(tmpdir(), "onscreen-gapcue-"));
+ try {
+ const m = cut();
+ m.render = { ...m.render, gapCue: { mark: true } };
+ m.timeline[2] = { ...m.timeline[2], gaps: [{ from: 33, to: 37 }] };
+ const seg = path.join(dir, "out", "sourced", "segments");
+ await mkdir(seg, { recursive: true });
+ await writeFile(path.join(dir, "out", "sourced", "schedule.json"), JSON.stringify(built()));
+ // Cut from 30.6 (snapped): the join 2.4 s into the segment -- the play window would put it at 3.
+ const rec = { version: 1, id: "c02", video: "v2", start: 30.6, end: 41, gaps: [{ from: 33, to: 37 }] };
+ await writeFile(path.join(seg, "c02.cut.json"), JSON.stringify(rec));
+ const { schedule } = await scheduleForPreview({ dir }, m, "sourced", new Map(), {}, { resolver: { find: async () => null } });
+ assert.equal(schedule.estimated, false, "the build's schedule");
+ assert.equal(schedule.gapCue.marks.length, 1);
+ assert.ok(Math.abs(schedule.gapCue.marks[0].at - (13.9 + 2.4)) < 1e-3, `at ${schedule.gapCue.marks[0].at}: the built segment's start + the record's join`);
+ assert.equal(schedule.gapCue.marks[0].text, "» 4 s");
+ // The segment cut before its gaps: the record decides, no mark.
+ const { gaps: _g, ...noGaps } = rec;
+ await writeFile(path.join(seg, "c02.cut.json"), JSON.stringify(noGaps));
+ const again = await scheduleForPreview({ dir }, m, "sourced", new Map(), {}, { resolver: { find: async () => null } });
+ assert.equal("gapCue" in again.schedule, false);
+ // Mark off: the key absent, the schedule the preview drew before.
+ const offM = { ...m, render: { ...m.render, gapCue: { mark: false } } };
+ const off = await scheduleForPreview({ dir }, offM, "sourced", new Map(), {}, { resolver: { find: async () => null } });
+ const plain = await scheduleForPreview({ dir }, { ...m, render: { ...cut().render } }, "sourced", new Map(), {}, { resolver: { find: async () => null } });
+ assert.equal("gapCue" in off.schedule, false);
+ assert.equal(JSON.stringify(off.schedule), JSON.stringify(plain.schedule));
+ } finally {
+ await rm(dir, { recursive: true, force: true });
+ }
+});
diff --git a/umtool/lib/report/serve.mjs b/umtool/lib/report/serve.mjs
@@ -1077,7 +1077,7 @@ export function previewDirFor(projectDir, variant, rest, segmentIds) {
// (Every module that declares `play` must be here, or Play's iframe of its page is a 404: the measure
// extras and the instruments too -- the dial's finale is a window its module names `dial-finale-preview`,
// never confused with the dial's `dial-preview-<segment>`.)
-export const LAYER_REGIONS = Object.freeze(["pair", "status", "chapter", "stats", "threads", "flips", "fx", "shelf", "diet", "peak", "goals", "promise", "streak", "dial", "odometer", "trail", "dial-finale", "runs-finale"]);
+export const LAYER_REGIONS = Object.freeze(["gap-cue", "pair", "status", "chapter", "stats", "threads", "flips", "fx", "shelf", "diet", "peak", "goals", "promise", "streak", "dial", "odometer", "trail", "dial-finale", "runs-finale"]);
/** The project name a layer preview is served under, or null when `head` is not one. */
export function layerPreviewOf(head, segmentIds = []) {
@@ -1088,7 +1088,9 @@ export function layerPreviewOf(head, segmentIds = []) {
if (head.startsWith(prefix)) {
const seg = head.slice(prefix.length);
if (!seg || /[\/\\\0]/.test(seg) || seg === "." || seg === "..") return null;
- return new Set(segmentIds).has(seg) ? head : null;
+ // The gap mark's windows are its marks, `<segment>.g<k>` (chrome-gap-cue.mjs): one of the cut's entries' marks.
+ const own = region === "gap-cue" ? /^(.+)\.g\d+$/.exec(seg)?.[1] ?? null : seg;
+ return own !== null && new Set(segmentIds).has(own) ? head : null;
}
}
return null;
diff --git a/umtool/report-to-video/build-video.mjs b/umtool/report-to-video/build-video.mjs
@@ -185,8 +185,11 @@ import {
} from "./gaps.mjs";
// The mark at a gap's join (gap-mark.mjs; the settings and timing: common gapCue.mjs).
import {
- centredIn, censorAvoidRects, gapMarkAsked, gapMarkDrift, gapMarkFilters, gapMarkPlaces, gapMarkSize, segmentGapJoins, segmentGapMarks, twoCropMarkBox, verticalMarkBox,
+ centredIn, censorAvoidRects, gapMarkAsked, gapMarkByChrome, gapMarkDrawtextWhy, gapMarkFilters, gapMarkPlaces, gapMarkSize, segmentGapJoins, segmentGapMarks,
+ twoCropMarkBox, verticalMarkBox,
} from "./gap-mark.mjs";
+// Under a deck the gap mark is the gap-cue module's pages, from the schedule's slice (gap-cue-slice.mjs).
+import { withGapCue } from "./gap-cue-slice.mjs";
import { clipGapCueOf, gapCueWanted } from "yt-dlp-transcript-common/lib/report/gapCue.mjs";
import { SYNC_FILE, writeSyncReport } from "./sync-report.mjs";
import { validateThreadEntries } from "./threads.mjs";
@@ -1839,12 +1842,15 @@ async function buildClipSegment(entry, meta, render, dirs, opts, chrome, nodes,
// finished picture -- after its hidden regions and its blur: it is chrome,
// not footage. Only when a gap is marked (render.gapCue, the clip's gapCue,
// a gap's own mark: common gapCue.mjs): otherwise none, and every graph and
- // record below is the one it always was.
+ // record below is the one it always was. And only where no chrome is laid
+ // over the picture (gap-mark.mjs gapMarkByChrome, `dirs.markByChrome`):
+ // under a deck the gap-cue module's pages draw it, so this segment draws
+ // none -- its argv and record are the plain ones, its key the one it had.
// A clip cut from its pieces takes its joins from the recording's seconds (piecedGaps): with no pad, the join
// between two pieces is no gap on the joined file's clock, but it is one the viewer jumps -- and Play and the
// bench, which read the recording's seconds, mark it.
const realStart = toReal(fetchStart + segA);
- const gapMarks = (pieced ? piecedGaps.length : segGaps.length) && gapCueWanted(render, clipE)
+ const gapMarks = !dirs.markByChrome && (pieced ? piecedGaps.length : segGaps.length) && gapCueWanted(render, clipE)
? segmentGapMarks({
render, entry: clipE, seconds: segSeconds,
joins: pieced
@@ -5905,29 +5911,77 @@ export async function planChunks({ segments, render, chrome = null, joins = null
}
/**
+ * What a chrome-only pass (`what`: --chrome-only / --chrome-preview) says of one clip's segment and its gaps, or
+ * null: a segment whose marks were drawn INTO it while the mark is still wanted (the chrome leaves its marks out;
+ * rebuild it to let the chrome draw them), or no longer wanted (the segment still shows them until it is rebuilt);
+ * a segment cut before its clip had the gaps it now has (the footage plays them; no mark is drawn for them).
+ */
+export function segmentGapNote({ entry, record, render, what }) {
+ if (entry?.type !== "clip" || !record) return null;
+ if (Array.isArray(record.gapMarks) && record.gapMarks.length) {
+ return gapCueWanted(render, entry)
+ ? `${entry.id}: its gap marks are drawn in its segment (built with no chrome drawing them) — ${what} leaves the chrome's out for it; rebuild it (a build without ${what}, or --only ${entry.id}) to let the chrome draw them`
+ : `${entry.id}: its segment still shows gap marks that are no longer wanted — ${what} cannot take them out; rebuild it (a build without ${what}, or --only ${entry.id})`;
+ }
+ const a = Number(record.start);
+ const b = Number(record.end);
+ if (!Array.isArray(record.gaps) && renderGaps(entry, render).some((g) => !(Number.isFinite(a) && Number.isFinite(b)) || (g.to > a && g.from < b))) {
+ return `${entry.id}: its segment was cut before its gaps — the footage plays them and no gap mark is drawn for them; rebuild it (a build without ${what}, or --only ${entry.id}) to cut them`;
+ }
+ return null;
+}
+
+/**
* The deck's `want` (compose-chrome): draw only the frames the chunked
* encode will read -- a fix `--from` a take whose frames were pruned captures
* the touched post's frames, not the whole cut's (mid-6: 11,996 captures,
- * 90 s). Only when the deck's shell is the cut's one overlay layer (another
- * layer's frames are in the same chunks' keys, and are captured beside it),
- * and the encode is chunked. `UMTOOL_CHROME_LAZY=0` draws every frame.
- */
-export function deckWant({ schedule, render, outDir, segments, joins = null, hardCut, env = process.env }) {
+ * 90 s). When the deck's shell is the cut's one overlay layer -- or the others
+ * are only LAZY_BESIDE's (the gap marks' windows), whose frame keys are
+ * composed here without drawing a frame (compose-chrome `keysOnly`), so the
+ * chunks' keys are known before any layer is captured -- and the encode is
+ * chunked. Any other layer's frames are in the same chunks' keys and are
+ * captured beside the deck's, so its keys are not known yet: every deck frame
+ * is drawn, as before. `UMTOOL_CHROME_LAZY=0` draws every frame.
+ */
+export function deckWant({ schedule, render, outDir, segments, joins = null, hardCut, env = process.env, manifestPath = null, variant = "sourced" }) {
if (env.UMTOOL_CHROME_LAZY === "0" || !chunkedEncodeOn(render, env)) return null;
const on = deckOverlays().filter((m) => m.on(schedule, render));
- if (on.length !== 1 || on[0].region !== "deck" || on[0].kind !== "overlay-whole") return null;
- const regions = on[0].regions(schedule, { render, outDir });
+ const shell = on.filter((m) => m.region === "deck");
+ const beside = on.filter((m) => m.region !== "deck");
+ if (shell.length !== 1 || shell[0].kind !== "overlay-whole") return null;
+ if (beside.length && (!manifestPath || beside.some((m) => !LAZY_BESIDE.has(m.region) || m.kind !== "overlay-window"))) return null;
+ const regions = shell[0].regions(schedule, { render, outDir });
const framesDir = regions[0].frames;
- return (fk) => framesNeeded({ framesDir, fk, segments, render, chrome: { regions, outLabel: "[hfout]" }, joins, workDir: outDir, hardCut });
+ // The layers in the order the build lays them (renderDeck: z order, each window its own), and what they leave out.
+ const windows = beside.flatMap((m) => m.regions(schedule, { render, outDir }));
+ const blackouts = chromeBlackouts(schedule);
+ const chrome = { regions: [...regions, ...windows.map(({ window: _w, ...r }) => r)], outLabel: "[hfout]", ...(blackouts.length ? { blackouts } : {}) };
+ const own = verticalOn(render) ? { render } : {};
+ return async (fk) => {
+ const keys = new Map([[framesDir, fk]]);
+ for (const pr of windows) {
+ const { composeChrome } = await import("./compose-chrome.mjs");
+ const k = await composeChrome({ manifestPath, outDir, variant, region: pr.name, window: pr.window, keysOnly: true, fps: render.fps, ...own });
+ // A page the model cannot key: its frames' bytes are not known before they are drawn -- every deck frame.
+ if (!k.fk || k.target !== pr.frames) return null;
+ keys.set(pr.frames, k.fk);
+ }
+ return framesNeeded({ framesDir, frameKeys: keys, segments, render, chrome, joins, workDir: outDir, hardCut });
+ };
}
+/** The layers beside the deck's shell whose frame keys deckWant composes without drawing: the gap marks' windows. */
+export const LAZY_BESIDE = new Set(["gap-cue"]);
+
/**
* The frames of chrome sequence `framesDir` the chunks to encode read
* (0-based), when its frame keys are `fk`: what a build asks the capture to
* draw (compose-chrome `want`). Every other frame is in a chunk on disk.
*/
-export async function framesNeeded({ framesDir, fk, ...job }) {
- const { todo, plan } = await planChunks({ ...job, frameKeys: new Map([[framesDir, fk]]), quiet: true });
+export async function framesNeeded({ framesDir, fk = null, frameKeys = null, ...job }) {
+ const keys = frameKeys ?? new Map([[framesDir, fk]]);
+ fk = keys.get(framesDir);
+ const { todo, plan } = await planChunks({ ...job, frameKeys: keys, quiet: true });
const need = new Set();
for (const p of todo) {
for (const inp of p.inputs) {
@@ -6547,12 +6601,16 @@ export async function measureChromeSchedule({ manifest, entries, segments, D, du
// A clip with gaps (gaps.mjs): the gaps its segment really left out, from
// its cut record. Read only for those: a cut without gaps measures what it did.
let clipGaps = null;
+ // And its whole record for the gap mark (gap-cue-slice.mjs: its `start`, `end` and `gaps` -- a record from
+ // before the mark was drawn by the chrome has them too -- and whether its segment drew the marks itself).
+ const gapRecords = new Map();
for (let i = 0; i < entries.length; i += 1) {
if (entries[i].type !== "clip" || !Array.isArray(entries[i].gaps) || !entries[i].gaps.length || !segments[i]) continue;
const rec = await readCutRecord(segments[i]).catch(() => null);
if (!rec) continue;
clipGaps ??= new Map();
clipGaps.set(entries[i].id, recordGaps(rec));
+ if (gapCueWanted(render, entries[i])) gapRecords.set(entries[i].id, rec);
}
// The measure slice (measure-slice.mjs): read only for a cut that writes
// one -- each clip's words for the second its figure is said, and the
@@ -6560,7 +6618,7 @@ export async function measureChromeSchedule({ manifest, entries, segments, D, du
const measure = measureOn(manifest) ? await measureInputs({ manifest, entries, segments, render, provenance }) : null;
// The variant's posts, placed on the clips this cut plays with their real
// upload dates. A manifest without posts writes the schedule it always did.
- return deckSchedule({
+ const doc = deckSchedule({
entries, durs, D, render, provenance, metas, posts: manifest.posts ?? [], frameScan: manifest.frameScan ?? null,
sourceStatus: manifest.sourceStatus ?? null,
...(fx ? { fxWords: fx.words, fxClock: fx.clock } : {}),
@@ -6570,6 +6628,8 @@ export async function measureChromeSchedule({ manifest, entries, segments, D, du
...(estimated ? { estimated: true } : {}),
...(measure ? { measure } : {}),
});
+ // The gap marks the gap-cue module draws (gap-cue-slice.mjs), on the measured clock: none wanted, the key absent.
+ return withGapCue(doc, { entries, render, records: gapRecords, provenance });
}
/**
@@ -7202,6 +7262,16 @@ export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly
if (vertical) dirs.vertical = { on: true, sections: opts.verticalSections ? new Map(Object.entries(opts.verticalSections)) : sectionTitlesOf(whole), stacked: stackedOn(render) };
// A desktop clip is drawn by the same per-clip branch, in its own geometry (vertical.mjs desktopGeometry).
if (desktop) dirs.vertical = { on: true, desktop: true, sections: opts.verticalSections ? new Map(Object.entries(opts.verticalSections)) : sectionTitlesOf(whole), stacked: false };
+ // WHO DRAWS THE GAP MARK (gap-mark.mjs gapMarkByChrome): the gap-cue module's pages where the deck is laid over
+ // the picture, else the drawtext in each clip's segment -- one or the other, said once per build that marks a gap.
+ dirs.markByChrome = deck && gapMarkByChrome(render, opts);
+ if ((manifest.timeline ?? []).some((e) => e?.type === "clip" && Array.isArray(e.gaps) && e.gaps.length && gapCueWanted(render, e))) {
+ EMIT("note", {
+ message: dirs.markByChrome
+ ? "gap mark: drawn by the gap-cue page (chrome)"
+ : `gap mark: drawn into the clip segments (no chrome for the picture: ${gapMarkDrawtextWhy(render, { ...opts, vertical: vertical || undefined })})`,
+ });
+ }
// THE CHANNEL PROMO (promo-card.mjs): a per-clip build (not the stacked deck) ends its LAST clip on the card, when
// the cut sets one (render.promo) and that clip does not say `promo: false`; `--no-promo` none, `--promo-knobs`
// its timing over the cut's.
@@ -7762,15 +7832,14 @@ export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly
...censorProblems({ entries: present.map((i) => entries[i]), records, render, provenance }),
];
if (problems.length) throw new Error(`${what}: ${problems.join("; ")}`);
- // The gap mark is in a clip's segment (gap-mark.mjs), which this pass does not rebuild: a mark changed since
- // (turned on or off, its label, a gap's reason or corner) is laid as it was built -- said, never silently.
+ // Under a deck the gap mark is the gap-cue module's (chrome): this pass draws it. A segment built with its
+ // marks drawn INTO it (`--no-chrome`, or a build before the module drew them) keeps them, and the chrome
+ // leaves that clip's out (gap-cue-slice.mjs inSegment: never both on one frame) -- said, never silently.
+ // A segment cut before its clip had gaps plays them: the record decides, so no mark is drawn at a join the
+ // picture does not have -- said too.
present.forEach((i, k) => {
- const e = entries[i];
- if (e?.type !== "clip" || !records[k]) return;
- const drift = gapMarkDrift({ render, entry: e, record: records[k] });
- if (drift) {
- EMIT("note", { message: `${e.id}: its gap mark changed since its segment was built (${drift}) — ${what} rebuilds no clip segment: build without it (or --only ${e.id}) to draw it` });
- }
+ const note = segmentGapNote({ entry: entries[i], record: records[k], render, what });
+ if (note) EMIT("note", { message: note });
});
}
for (const i of missing) {
@@ -7829,7 +7898,7 @@ export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly
}
const plan = await renderDeck({
- manifestPath, render, outDir, variant, schedule, drawOnly: deckWant({ schedule, render, outDir, segments: segs, joins, hardCut: D === 0 }),
+ manifestPath, render, outDir, variant, schedule, drawOnly: deckWant({ schedule, render, outDir, segments: segs, joins, hardCut: D === 0, manifestPath, variant }),
});
EMIT("chrome", { phase: "overlay" });
EMIT("concat", { mode: D === 0 ? "hardcut" : "xfade", n: segs.length });
@@ -7981,7 +8050,7 @@ export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly
// the deck's framing and leaves the panel off -- a fast look at the picture.
if (deck && !opts.noChrome) {
// Lazily (deckWant) when the cut's chunked encode is the deck's only reader.
- const want = !railPlan && (D === 0 || chunkedEncodeOn(render)) ? deckWant({ schedule, render, outDir, segments, joins, hardCut: D === 0 }) : null;
+ const want = !railPlan && (D === 0 || chunkedEncodeOn(render)) ? deckWant({ schedule, render, outDir, segments, joins, hardCut: D === 0, manifestPath, variant }) : null;
chromePlan = await renderDeck({ manifestPath, render, outDir, variant, schedule, drawOnly: want });
EMIT("chrome", { phase: "overlay" });
}
diff --git a/umtool/report-to-video/chrome-cues.mjs b/umtool/report-to-video/chrome-cues.mjs
@@ -95,7 +95,12 @@ function fontFaces(fonts) {
* @param {{ id: string, W: number, H: number, fps: number, fonts?: {regular?: string, bold?: string},
* gsapSrc?: string, css: string, body: string, init: object, cues: object[],
* whole?: { total: number, from?: number, duration?: number | null, ids?: string[] },
- * window?: { from: number, dur: number }, primeWindow?: boolean }} p
+ * window?: { from: number, dur: number }, primeWindow?: boolean, fit?: { loads: string[], run: string } }} p
+ *
+ * `fit` (opt-in, the gap mark's): `{ loads, run }` -- once the faces in
+ * `loads` (FontFace load strings, "26px DeckSans") are in, `run` (script) runs
+ * before the page says it is fitted: what a page measures in its own faces.
+ * Without it the page is what it always was.
*
* `primeWindow` (opt-in, the measure extras'): a WINDOW of a whole page is
* rendered once at its end and back at its start before anything seeks it. A
@@ -184,7 +189,12 @@ export function cuePageHtml(p) {
window.__timelines = window.__timelines || {};
window.__timelines["${id}"] = tl;
- const ready = document.fonts.ready.catch(() => {}).then(() => { document.documentElement.dataset.fit = "1"; });
+ const ready = ${p.fit
+ ? `Promise.all([${p.fit.loads.map((f) => `document.fonts.load(${JSON.stringify(f)})`).join(", ")}]).catch(() => {}).then(() => {
+ ${p.fit.run.replace(/\n/g, "\n ")}
+ document.documentElement.dataset.fit = "1";
+ });`
+ : `document.fonts.ready.catch(() => {}).then(() => { document.documentElement.dataset.fit = "1"; });`}
const params = new URLSearchParams(location.search);
const still = params.get("still");
if (still !== null) {
diff --git a/umtool/report-to-video/chrome-deck.mjs b/umtool/report-to-video/chrome-deck.mjs
@@ -737,6 +737,40 @@ ${calls.map(([sel, mode, name]) => ` const ${name} = (root) => (root || doc
}
/**
+ * The untitled arrangement's rows (deckLayout's text `t`): the source line promoted into the title's band a size
+ * up (`uSub*`), and in a two-line deck the head over the meta line, centred on the same block (`u2*`; `u2Y` 0 in a
+ * one-line deck). The page's CSS and the gap mark's deck place (gap-cue-slice.mjs) both read these.
+ */
+export function untitledRows(t) {
+ const uSubSize = Math.round(t.subtitleSize * 1.35);
+ const uSubBox = Math.round(uSubSize * 1.3);
+ const uSubY = Math.round(t.titleY + (t.subtitleY + t.subtitleBox - t.titleY - uSubBox - 14) / 2);
+ const u2HeadBox = Math.round(uSubSize * 1.25);
+ const u2Block = u2HeadBox + t.subtitleBox;
+ const u2Y = t.lines === 2 ? Math.round(t.titleY + (t.subtitleY + (t.headBox ?? 0) + t.subtitleBox - t.titleY - u2Block - 14) / 2) : 0;
+ return { uSubSize, uSubBox, uSubY, u2HeadBox, u2Block, u2Y };
+}
+
+/**
+ * The row a segment's SOURCE LINE stands on in the deck's band (band px, deckLayout's text `t`) and what it says --
+ * the rules the page's CSS lays it by: titled, under the title (in a two-line deck the meta line, under the head);
+ * untitled, promoted into the title's band (a size up when it is one line). Two lines only where the schedule gave
+ * the segment two (an entry's own one-line subtitle stays one line in a two-line deck).
+ *
+ * @returns {{ y: number, size: number, box: number, text: string, parts: unknown, two: boolean }}
+ */
+export function sourceLineRow(t, s) {
+ const two = t.lines === 2 && Array.isArray(s?.subtitleLines) && s.subtitleLines.length === 2;
+ const u = untitledRows(t);
+ const untitled = !s?.title;
+ const lp = two && Array.isArray(s.subtitleLinesParts) && s.subtitleLinesParts.length === 2 ? s.subtitleLinesParts[1] : null;
+ const said = two ? { text: String(s.subtitleLines[1] ?? ""), parts: lp } : { text: String(s?.subtitle ?? ""), parts: s?.subtitleParts ?? null };
+ if (untitled && two) return { y: u.u2Y + u.u2HeadBox, size: t.subtitleSize, box: t.subtitleBox, two, ...said };
+ if (untitled) return { y: u.uSubY, size: u.uSubSize, box: u.uSubBox, two, ...said };
+ return { y: t.subtitleY + (two ? t.headBox ?? 0 : 0), size: t.subtitleSize, box: t.subtitleBox, two, ...said };
+}
+
+/**
* The deck composition's HTML.
*
* `fonts` = `{ regular, bold }` asset-relative paths (DeckSans / DeckSansBold),
@@ -780,9 +814,7 @@ export function deckHtml(schedule, render, opts = {}) {
const top = panel ? mix(pal.bg, pal.fg, 0.095) : pal.bg;
const bottom = panel ? mix(pal.bg, pal.fg, 0.04) : pal.bg;
// The untitled arrangement, centred on the same block.
- const uSubSize = Math.round(t.subtitleSize * 1.35);
- const uSubBox = Math.round(uSubSize * 1.3);
- const uSubY = Math.round(t.titleY + (t.subtitleY + t.subtitleBox - t.titleY - uSubBox - 14) / 2);
+ const { uSubSize, uSubBox, uSubY, u2HeadBox, u2Block, u2Y } = untitledRows(t);
const uRuleY = uSubY + uSubBox + 6;
// A two-line subtitle (`subtitle.lines: 2`, deckLayout's `lines`): the head
// line (the source's title) a size up and brighter over the source line.
@@ -791,9 +823,6 @@ export function deckHtml(schedule, render, opts = {}) {
const two = t.lines === 2;
// A line carries the source status: only then does the page add its rule and its fit.
const hs = scheduleHasStatus(schedule);
- const u2HeadBox = Math.round(uSubSize * 1.25);
- const u2Block = u2HeadBox + t.subtitleBox;
- const u2Y = two ? Math.round(t.titleY + (t.subtitleY + (t.headBox ?? 0) + t.subtitleBox - t.titleY - u2Block - 14) / 2) : 0;
const plateX = qr ? qr.x - 46 : W;
const ink = panel ? mix(pal.bg, pal.fg, 0.085) : pal.bg; // what the marker's ring cuts back to
// In sections (`pip.color: "section"`): each section's colour fitted to the
diff --git a/umtool/report-to-video/chrome-gap-cue.mjs b/umtool/report-to-video/chrome-gap-cue.mjs
@@ -0,0 +1,125 @@
+// THE GAP MARK'S PAGE (module `gap-cue`, region `gap-cue`; lane gap-cue,
+// slice 1d): "» 27 s" at a clip gap's join, one short page per mark -- the
+// schedule's `gapCue.marks` (gap-cue-slice.mjs) -- laid at its own seconds
+// over the whole frame, so the mark stands over the footage or in the deck's
+// band as its `place` says, at the rect the slice gave it. A cue page
+// (chrome-cues.mjs): the element comes up over GAP_CUE_MOTION.in at the join,
+// holds, and goes over GAP_CUE_MOTION.out (common gapCue.mjs, the drawtext
+// path's own ramp: linear, to GAP_CUE_MOTION.peak).
+//
+// THE LOOK is common gapCue.mjs GAP_CUE_LOOK as CSS (gapCueCss): the deck's own
+// bold face (DeckSansBold), a real border, the box inside it. The page is its
+// live preview too (the module's `play`): Play the cut loads it as it is.
+//
+// PURE: a schedule and a render in, the page's HTML out.
+import { GAP_CUE_MOTION, gapCueCss } from "yt-dlp-transcript-common/lib/report/gapCue.mjs";
+import { compileCues, cuePageHtml, esc, r4 } from "./chrome-cues.mjs";
+import { subtitleMarkup } from "./chrome-deck.mjs";
+import { GAP_CUE_DECK_LINE } from "./gap-cue-slice.mjs";
+
+/**
+ * A mark's id (`<clip>.g<k>`): what its window, its project and its frames are named by. A clip id takes what the
+ * chapter's segment ids take (`.` and `:` too); never a `/`, `\`, NUL or space, and always after the `gap-cue-`
+ * prefix, so it names one directory entry. Play's route is stricter than this (serve.mjs layerPreviewOf): it also
+ * refuses `.` and `..`, and the `<clip>` must be one of the cut's entries.
+ */
+export const GAP_CUE_ID_RE = /^[A-Za-z0-9_.:-]+\.g\d+$/;
+
+/** The schedule's marks, each a window `{ segment: <its id>, from, to, mark }` on the cut's clock. */
+export function gapCueWindows(schedule) {
+ return (schedule?.gapCue?.marks ?? [])
+ .filter((m) => typeof m?.id === "string" && Number.isFinite(m.at) && Number.isFinite(m.until) && m.until > m.at)
+ .map((m) => ({ segment: m.id, from: m.at, to: m.until, mark: m }));
+}
+
+/** Where a placed mark stands, as CSS (`left`/`right`, `top`/`bottom`: the edges it is placed against). */
+function placeAt(m, W, H) {
+ const right = m.place === "deck" || String(m.corner ?? "").endsWith("r");
+ const bottom = m.place !== "deck" && String(m.corner ?? "").startsWith("b");
+ const r = m.rect;
+ return [
+ right ? `left: auto; right: ${W - (r.x + r.w)}px;` : `left: ${r.x}px; right: auto;`,
+ bottom ? `top: auto; bottom: ${H - (r.y + r.h)}px;` : `top: ${r.y}px; bottom: auto;`,
+ `max-width: ${Math.max(Number(m.room) || r.w, 1)}px;`,
+ ].join(" ");
+}
+
+/** A script string's literal (no `</script>` can close the page's script early). */
+const lit = (v) => JSON.stringify(v).replace(/</g, "\\u003c");
+
+/**
+ * One mark's page: the whole frame, transparent, the mark at its rect -- its right edge kept at the rect's when it
+ * stands at a right corner or in the deck, its bottom at the rect's at a bottom corner (the face's real width is the
+ * text's own, so the mark hugs the edges it is placed against) -- never wider than its `room` (cut "…" past it).
+ *
+ * IN THE DECK the page never trusts the slice's reckoning alone: it lays a copy of the source line (the deck's own
+ * markup, faces, size and letter-spacing; never shown) on the line's row, and once its faces are in, if the line's
+ * end and the air after it reach the mark's left edge, the mark stands at its `alt` place over the footage instead
+ * (`data-fell="line"`) -- so a mark is never drawn on the line's words, whatever face the brand gives it.
+ *
+ * @param {Record<string, any>} schedule
+ * @param {Record<string, any>} render
+ * @param {{ segment: string, from: number, to: number }} window the snapped window
+ * @param {{ fonts?: { regular?: string, bold?: string }, gsap?: string, look?: Record<string, unknown> }} [opts] `look` over
+ * GAP_CUE_LOOK's colours and box (the operator's stills of the variants; the build passes none)
+ */
+export function gapCueHtml(schedule, render, window, opts = {}) {
+ const w = gapCueWindows(schedule).find((x) => x.segment === window.segment);
+ if (!w) throw new Error(`gap-cue: no mark ${window.segment} in this schedule`);
+ const m = w.mark;
+ const W = render.width ?? 1920;
+ const H = render.height ?? 1080;
+ const fps = schedule.fps ?? render.fps ?? 30;
+ const from = r4(window.from);
+ const dur = r4(window.to - window.from);
+ const M = GAP_CUE_MOTION;
+ // On the window's clock: the mark's own seconds inside the snapped window.
+ const a = r4(m.at);
+ const b = r4(m.until);
+ // A mark shorter than its ramps (cut short before a dissolve) rises only as far as the drawtext's alpha does
+ // (common gapCueAlpha): to where its in and out ramps meet, never a flash to the peak.
+ const len = Math.max(0, b - a);
+ const short = len < M.in + M.out;
+ const inDur = short ? r4((len * M.in) / (M.in + M.out)) : M.in;
+ const outDur = short ? r4(len - inDur) : M.out;
+ const peak = short ? r4((M.peak * len) / (M.in + M.out)) : M.peak;
+ const { init, cues } = compileCues({ gm: { autoAlpha: 0 } }, [
+ { k: "gm", at: a, dur: inDur, to: { autoAlpha: peak }, ease: "none" },
+ { k: "gm", at: r4(b - outDur), dur: outDur, to: { autoAlpha: 0 }, ease: "none" },
+ ]);
+ const look = opts.look ? { look: opts.look } : {};
+ const line = m.place === "deck" ? GAP_CUE_DECK_LINE : 1.2;
+ const guard = m.place === "deck" && m.line && m.alt ? m : null;
+ let css = `${gapCueCss(".gm", { font: m.font, stroke: m.stroke, lineHeight: line, ...look })}
+ .gm { visibility: hidden; opacity: 0; ${placeAt(m, W, H)} }`;
+ let body = `<div class="gm" data-k="gm" data-gm="${esc(m.text)}" data-place="${esc(m.place)}">${esc(m.text)}</div>`;
+ let fit;
+ if (guard) {
+ const L = guard.line;
+ // The fallback: the mark's own place over the footage, its look at that size (it overrides every edge).
+ css += `
+ ${gapCueCss(".gm.fell", { font: guard.alt.font, stroke: guard.alt.stroke, lineHeight: 1.2, ...look })}
+ .gm.fell { ${placeAt(guard.alt, W, H)} }
+ /* The source line as the deck draws it (chrome-deck.mjs .deck-sub), never shown: what the mark keeps clear of. */
+ .gm-line { position: absolute; left: ${L.x}px; top: ${L.y}px; display: flex; white-space: nowrap; visibility: hidden;
+ font-size: ${L.size}px; letter-spacing: 0.005em; }
+ .gm-line .part, .gm-line .sep { flex: none; }
+ .gm-line .sep { padding: 0 0.42em; font-family: 'DeckSansBold', sans-serif; }`;
+ body += `\n <div class="gm-line" aria-hidden="true">${subtitleMarkup(L.text, L.parts)}</div>`;
+ fit = {
+ loads: [`${L.size}px DeckSans`, `${L.size}px DeckSansBold`, `${m.font}px DeckSansBold`],
+ run: `// The mark never touches the source line: measured in the faces the deck draws it in.
+(function () {
+ const gm = document.querySelector(".gm");
+ const ln = document.querySelector(".gm-line");
+ if (!gm || !ln || ln.getBoundingClientRect().right + ${Number(L.air) || 0} <= gm.getBoundingClientRect().left) return;
+ gm.classList.add("fell");
+ gm.textContent = ${lit(guard.alt.text)};
+ gm.dataset.gm = ${lit(guard.alt.text)};
+ gm.dataset.place = "footage";
+ gm.dataset.fell = "line";
+})();`,
+ };
+ }
+ return cuePageHtml({ id: "gap-cue", W, H, fps, fonts: opts.fonts, gsapSrc: opts.gsap, css, body, init, cues, window: { from, dur }, ...(fit ? { fit } : {}) });
+}
diff --git a/umtool/report-to-video/compose-chrome.mjs b/umtool/report-to-video/compose-chrome.mjs
@@ -994,7 +994,7 @@ export async function composeChrome({
schedule = null, preview = false, doRender = false,
fps = null, workers = null, quality = "high", format = "png-sequence",
still = null, png = null, from = 0, duration = null, window = null, segment = null, transition = null,
- lease = null, want = null, render: renderOverride = null, context = null,
+ lease = null, want = null, render: renderOverride = null, context = null, keysOnly = false,
}) {
// The variant's view, and its own out directory. Handed the whole manifest
// the band would draw claims this cut never makes, and the deck would name
@@ -1053,7 +1053,9 @@ export async function composeChrome({
const names = mod.names
? mod.names({ preview, window: win, entry: teaser, suffix })
: { project: wholeCut && preview ? `${region}-preview` : `${region}${suffix}`, stem: `${region}${suffix}` };
- const projDir = path.join(base, "chrome", names.project);
+ // `keysOnly` (build-video.mjs deckWant): the page composed in a scratch project of its own -- never the one its
+ // render may be drawing in at the same moment -- for its frame keys alone, then removed.
+ const projDir = path.join(base, "chrome", keysOnly ? `${names.project}.keys` : names.project);
const assetsDir = path.join(projDir, "assets");
// The deck's assets are rebuilt every time: a QR from a clip that has since
// left the cut must not sit in the directory the cache key hashes.
@@ -1086,6 +1088,20 @@ export async function composeChrome({
}
const result = { projDir, frames: null, still: null, cached: false, key, frameCount: frames, ...(win ? { window: win } : {}) };
+ // Its frame keys and where its frames go, nothing drawn (the same model as a render's, below).
+ if (keysOnly) {
+ let fk = null;
+ if (keyed && (wholeCut || mod.kind === "overlay-window" || mod.kind === "segment") && mod.frameKeys) {
+ try {
+ fk = frameKeys({ html, region, assets, fps: rate, frames, version: hf.version, items: pageItems });
+ } catch {
+ fk = null;
+ }
+ }
+ await rm(projDir, { recursive: true, force: true });
+ return { ...result, projDir: null, fk, target: path.join(base, "chrome", `${names.stem}-frames`) };
+ }
+
// The review still: seek and screenshot, no HyperFrames, ~2 s. It is the SAME
// seek the renderer performs for every frame, which is why a still that is
// right is evidence about the frames and not just about the markup. The
diff --git a/umtool/report-to-video/gap-cue-build.test.mjs b/umtool/report-to-video/gap-cue-build.test.mjs
@@ -0,0 +1,245 @@
+// The gap mark under a deck, built for real (lane gap-cue, slice 1d, review 1d): tiny encodes, the deck's renderer a
+// stub that writes transparent frames and logs how many each render drew. What a chrome-only pass does with the mark:
+//
+// - off (unset or `mark: false`): the schedule the build writes is the same bytes, no `gapCue` key;
+// - on, over an old take: the marks on the schedule from the cut records, no segment rebuilt, and the deck still
+// drawn ONLY where a chunk to encode reads it (deckWant keys the gap-cue windows without drawing them);
+// - a segment that drew its marks itself (`--no-chrome`): the chrome leaves its marks out, and says why, wanted or not;
+// - a segment cut before its clip had gaps: no mark at a join its picture does not have, and a note;
+// - `--clip-preview`: the module's marks, nothing drawn into the segment;
+// - a clip that is not first, after a real crossfade: its mark at that segment's start plus its join.
+//
+// Skipped without ffmpeg/ffprobe. Run with: pnpm test:scripts
+import assert from "node:assert/strict";
+import { spawnSync } from "node:child_process";
+import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import path from "node:path";
+import test from "node:test";
+
+// The corpus the build reads metadata and cues from: set before build-video (cues.mjs) is loaded.
+const CORPUS = mkdtempSync(path.join(tmpdir(), "rtv-gapcue-corpus-"));
+process.env.CHANNELS_DIR = CORPUS;
+const { buildVideo, measureChromeSchedule, setProgressMode } = await import("./build-video.mjs");
+const { MONO_BOLD_FONT_FILE, MONO_FONT_FILE } = await import("./brand.mjs");
+const { offsetIn } = await import("./gaps.mjs");
+test.after(() => rmSync(CORPUS, { recursive: true, force: true }));
+
+const have = ["ffmpeg", "ffprobe"].every((b) => spawnSync(b, ["-version"]).status === 0);
+const FPS = 10;
+const PALETTE = { bg: "#12101a", fg: "#f4f1ea", muted: "#9a93ad", accent: "#a97bff", amber: "#ffc860" };
+const RENDER = {
+ width: 640, height: 360, fps: FPS, audioRate: 48000, audioChannels: 2, preset: "ultrafast", transition: 0,
+ headerHeight: 0, footerHeight: 0, qr: false, palette: PALETTE, fontRegular: MONO_FONT_FILE, fontBold: MONO_BOLD_FONT_FILE,
+ fetchPad: 0, snapWindow: 0.05, silenceMinDur: 0.1,
+ chrome: { engine: "hyperframes", layout: "deck", deck: { qr: { show: false }, footageScale: 0.6 } },
+};
+{
+ const dir = path.join(CORPUS, "synth", "data", "vid1");
+ mkdirSync(dir, { recursive: true });
+ writeFileSync(path.join(CORPUS, "synth", "config.json"), JSON.stringify({ name: "Synth" }));
+ writeFileSync(path.join(dir, "transcript.cues.json"), JSON.stringify({ id: "vid1", title: "Synthetic", duration: 12, uploadDate: "20240102", cues: [{ start: 0.2, end: 11.8, text: "words" }] }));
+ writeFileSync(path.join(dir, "metadata.info.json"), JSON.stringify({ id: "vid1", title: "Synthetic", duration: 12, channel: "Synth", upload_date: "20240102" }));
+}
+
+const STUB = `#!/usr/bin/env node
+import { spawnSync } from "node:child_process";
+import { appendFileSync, copyFileSync, mkdirSync, readFileSync } from "node:fs";
+const a = process.argv.slice(2);
+const out = a[a.indexOf("--output") + 1];
+const fps = Number(a[a.indexOf("--fps") + 1]);
+const html = readFileSync(a.at(-1) + "/index.html", "utf8");
+const dur = Number(/data-composition-id="[^"]*"[^>]*data-duration="([\\d.]+)"/.exec(html)[1]);
+const id = /data-composition-id="([^"]*)"/.exec(html)[1];
+const w = Number((/data-width="(\\d+)"/.exec(html) ?? [0, 640])[1]);
+const h = Number((/data-height="(\\d+)"/.exec(html) ?? [0, 360])[1]);
+mkdirSync(out, { recursive: true });
+const one = out + "/.one.png";
+spawnSync("ffmpeg", ["-nostdin", "-v", "error", "-y", "-f", "lavfi", "-i", "color=c=black@0.0:size=" + w + "x" + h + ",format=rgba", "-frames:v", "1", one]);
+const n = Math.round(dur * fps);
+for (let i = 1; i <= n; i += 1) copyFileSync(one, out + "/frame_" + String(i).padStart(6, "0") + ".png");
+appendFileSync(process.env.HF_LOG, id + " " + n + "\\n");
+`;
+
+/** A project: c1 1–4 s and c2 5–11 s of one 12 s window (noise in bursts, never periodic); c2 may carry gaps. */
+function project(t, { c2 = {}, render = {} } = {}) {
+ const root = mkdtempSync(path.join(tmpdir(), "rtv-gapcue-"));
+ const env = { bin: process.env.HYPERFRAMES_BIN, log: process.env.HF_LOG };
+ t.after(() => {
+ for (const [k, v] of [["HYPERFRAMES_BIN", env.bin], ["HF_LOG", env.log]]) {
+ if (v === undefined) delete process.env[k];
+ else process.env[k] = v;
+ }
+ setProgressMode(() => {});
+ rmSync(root, { recursive: true, force: true });
+ });
+ const stub = path.join(root, "hf-stub.mjs");
+ writeFileSync(stub, STUB);
+ chmodSync(stub, 0o755);
+ process.env.HYPERFRAMES_BIN = stub;
+ const log = path.join(root, "renders.log");
+ process.env.HF_LOG = log;
+ mkdirSync(path.join(root, "out", "clips-raw"), { recursive: true });
+ const raw = path.join(root, "out", "clips-raw", "vid1_0.00-12.00.mp4");
+ const r = spawnSync("ffmpeg", [
+ "-v", "error", "-y", "-f", "lavfi", "-i", `testsrc2=s=640x360:r=${FPS}:d=12`,
+ "-f", "lavfi", "-i", "aevalsrc='0.2*(random(0)*2-1)*(0.25+0.75*gt(sin(2*PI*1.3*t+3*sin(2*PI*0.37*t)),0.2))':s=48000:d=12",
+ "-map", "0:v", "-map", "1:a", "-c:v", "libx264", "-preset", "ultrafast", "-c:a", "aac", "-shortest", raw,
+ ]);
+ assert.equal(r.status, 0, String(r.stderr));
+ const manifestPath = path.join(root, "video.manifest.json");
+ const manifest = {
+ slug: "gapcue", title: "Gap cue", provenance: { channelSlug: "synth", channelsDir: CORPUS },
+ render: { ...RENDER, ...render },
+ timeline: [
+ { type: "clip", id: "c1", channel: "synth", video: "vid1", start: 1, end: 4, cite: 1, quote: "q", onscreen: { title: "First" } },
+ { type: "clip", id: "c2", channel: "synth", video: "vid1", start: 5, end: 11, cite: 5, quote: "q", onscreen: { title: "Second" }, ...c2 },
+ ],
+ };
+ const v = path.join(root, "out", "sourced");
+ const notes = [];
+ const events = [];
+ setProgressMode((e) => {
+ events.push(e);
+ if (e.ev === "note") notes.push(e.message);
+ });
+ const p = {
+ root, v, manifestPath, notes, events,
+ write: (fn = null) => {
+ if (fn) fn(manifest);
+ writeFileSync(manifestPath, JSON.stringify(manifest));
+ },
+ build: async (opts = {}) => {
+ notes.length = 0;
+ events.length = 0;
+ const { only = null, ...o } = opts;
+ const res = await buildVideo({ manifestPath, ...(only ? { only } : {}), opts: { noNetwork: true, ...o } });
+ assert.equal(res.failures.length, 0, JSON.stringify(res.failures));
+ return res;
+ },
+ schedule: () => readFileSync(path.join(v, "schedule.json"), "utf8"),
+ record: (id) => JSON.parse(readFileSync(path.join(v, "segments", `${id}.cut.json`), "utf8")),
+ md5: (id) => spawnSync("md5sum", [path.join(v, "segments", `${id}.mp4`)]).stdout.toString().split(" ")[0],
+ drawn: () => (existsSync(log) ? readFileSync(log, "utf8").trim().split("\n").filter(Boolean).map((l) => ({ id: l.split(" ")[0], n: Number(l.split(" ")[1]) })) : []),
+ };
+ p.write();
+ return p;
+}
+const GAP = [{ from: 6.5, to: 9.5 }];
+
+test("--chrome-only, the mark off then on over an old take: the same schedule off; on, the marks from the records, no segment rebuilt, the deck drawn only where a chunk to encode reads it", { skip: !have && "needs ffmpeg" }, async (t) => {
+ const p = project(t, { c2: { gaps: GAP } });
+ await p.build();
+ const off = p.schedule();
+ assert.equal("gapCue" in JSON.parse(off), false, "off: no slice");
+ const seg0 = { c1: p.md5("c1"), c2: p.md5("c2") };
+ // Off said otherwise (`mark: false`): the very bytes, nothing drawn, nothing encoded.
+ p.write((m) => { m.render.gapCue = { mark: false }; });
+ const before = p.drawn().length;
+ await p.build({ chromeOnly: true });
+ assert.equal(p.schedule(), off, "mark false: the schedule the build wrote before, byte for byte");
+ assert.ok(p.notes.some((m) => /^final encode: (\d+)\/\1 chunk\(s\) unchanged/.test(m)), p.notes.join("\n"));
+ assert.equal(p.drawn().length, before, "nothing drawn");
+ // ON, by the switch alone: the retrofit.
+ p.write((m) => { m.render.gapCue = { mark: true }; });
+ await p.build({ chromeOnly: true });
+ const sched = JSON.parse(p.schedule());
+ const rec = p.record("c2");
+ assert.equal(rec.gapMarks, undefined, "the segment draws none");
+ assert.deepEqual({ c1: p.md5("c1"), c2: p.md5("c2") }, seg0, "no segment rebuilt");
+ assert.equal(sched.gapCue.marks.length, 1);
+ const k = sched.gapCue.marks[0];
+ const s2 = sched.segments[1];
+ assert.equal(k.segment, "c2");
+ assert.ok(Math.abs(k.at - (s2.start + offsetIn(6.5, rec.start, rec.gaps))) < 1e-3, `at ${k.at}: c2's start ${s2.start} + its join`);
+ assert.equal(k.text, "» 3 s");
+ // Lazy still (review 1d, 3): the deck's frames drawn only for the chunks the mark's window touches.
+ const read = p.notes.find((m) => /chunk\(s\) to encode read \d+ of \d+ deck-frames frames/.test(m));
+ assert.ok(read, p.notes.join("\n"));
+ const [, todo, chunks, need, frames] = /(\d+) of (\d+) chunk\(s\) to encode read (\d+) of (\d+) deck-frames/.exec(read).map(Number);
+ assert.ok(todo < chunks && need < frames, `only the mark's chunks: ${read}`);
+ const deckDrawn = p.drawn().slice(before).filter((d) => d.id === "deck");
+ assert.ok(deckDrawn.every((d) => d.n <= need), `the deck drew ${deckDrawn.map((d) => d.n)} of ${frames}`);
+ assert.ok(p.drawn().slice(before).some((d) => d.id === "gap-cue"), "the mark's page was drawn");
+ assert.ok(!readdirSync(path.join(p.v, "chrome")).some((f) => f.endsWith(".keys")), "the keys' scratch projects are gone");
+ t.diagnostic(`retrofit cost: ${read}; deck frames drawn ${deckDrawn.map((d) => d.n).join("+") || 0}`);
+ // Again: nothing to encode, and no deck frame drawn (the keys composed without drawing are the ones drawn). The
+ // mark's own few frames were pruned after the mux, as every window module's are: those are captured again.
+ const runs = p.drawn().length;
+ await p.build({ chromeOnly: true });
+ assert.ok(p.notes.some((m) => /^final encode: (\d+)\/\1 chunk\(s\) unchanged/.test(m)), p.notes.join("\n"));
+ assert.ok(p.notes.some((m) => /0 of \d+ chunk\(s\) to encode read 0 of \d+ deck-frames frames/.test(m)), p.notes.join("\n"));
+ assert.deepEqual(p.drawn().slice(runs).filter((d) => d.id === "deck"), [], "no deck frame drawn");
+ // What it cost before (the deck lazy only when it is the one layer): a label change re-encodes the same one chunk,
+ // but every deck frame is drawn.
+ const { LAZY_BESIDE } = await import("./build-video.mjs");
+ LAZY_BESIDE.delete("gap-cue");
+ try {
+ p.write((m) => { m.render.gapCue = { mark: true, label: "{s} later" }; });
+ const at = p.drawn().length;
+ await p.build({ chromeOnly: true });
+ // Every frame asked for (no "only those are drawn" note); the capture still skips frames it can key as the same.
+ assert.ok(!p.notes.some((m) => /deck-frames frames — only those are drawn/.test(m)), p.notes.join("\n"));
+ const all = p.drawn().slice(at).filter((d) => d.id === "deck").reduce((n, d) => n + d.n, 0);
+ const lazy = deckDrawn.reduce((n, d) => n + d.n, 0);
+ assert.ok(all > lazy, `not lazy: ${all} deck frames drawn, lazily ${lazy}`);
+ t.diagnostic(`without the gap-cue keys: all ${frames} deck frames asked for, ${all} drawn (lazily: ${need} asked for, ${lazy} drawn)`);
+ } finally {
+ LAZY_BESIDE.add("gap-cue");
+ }
+});
+
+test("--chrome-only over a segment that drew its own marks (--no-chrome): the chrome leaves its marks out and says so, wanted or not", { skip: !have && "needs ffmpeg" }, async (t) => {
+ const p = project(t, { c2: { gaps: GAP }, render: { gapCue: { mark: true } } });
+ await p.build({ noChrome: true });
+ assert.equal(p.record("c2").gapMarks?.length, 1, "--no-chrome drew it into the segment");
+ await p.build({ chromeOnly: true });
+ assert.deepEqual(JSON.parse(p.schedule()).gapCue, { marks: [], inSegment: ["c2"] });
+ assert.ok(p.notes.includes("c2: its gap marks are drawn in its segment (built with no chrome drawing them) — --chrome-only leaves the chrome's out for it; rebuild it (a build without --chrome-only, or --only c2) to let the chrome draw them"), p.notes.join("\n"));
+ assert.ok(!p.events.some((e) => e.ev === "chrome" && e.region === "gap-cue"), "no gap-cue page");
+ p.write((m) => { m.render.gapCue = { mark: false }; });
+ await p.build({ chromeOnly: true });
+ assert.ok(p.notes.includes("c2: its segment still shows gap marks that are no longer wanted — --chrome-only cannot take them out; rebuild it (a build without --chrome-only, or --only c2)"), p.notes.join("\n"));
+ assert.equal("gapCue" in JSON.parse(p.schedule()), false);
+});
+
+test("--chrome-only over a segment cut before its clip had gaps: no mark at a join the picture does not have, and a note", { skip: !have && "needs ffmpeg" }, async (t) => {
+ const p = project(t);
+ await p.build();
+ assert.equal(p.record("c2").gaps, undefined);
+ p.write((m) => {
+ m.timeline[1].gaps = GAP;
+ m.render.gapCue = { mark: true };
+ });
+ await p.build({ chromeOnly: true });
+ assert.equal("gapCue" in JSON.parse(p.schedule()), false, "no mark");
+ assert.ok(p.notes.includes("c2: its segment was cut before its gaps — the footage plays them and no gap mark is drawn for them; rebuild it (a build without --chrome-only, or --only c2) to cut them"), p.notes.join("\n"));
+});
+
+test("--clip-preview lays the deck over its clip: the module's mark, nothing drawn into the segment", { skip: !have && "needs ffmpeg" }, async (t) => {
+ const p = project(t, { c2: { gaps: GAP }, render: { gapCue: { mark: true } } });
+ await p.build({ clipPreview: "c2" });
+ assert.equal(p.record("c2").gapMarks, undefined);
+ const pv = JSON.parse(readFileSync(path.join(p.v, "clip-preview", "schedule.json"), "utf8"));
+ assert.equal(pv.gapCue.marks.length, 1);
+ assert.equal(pv.gapCue.marks[0].segment, "c2");
+ assert.ok(p.events.some((e) => e.ev === "chrome" && e.region === "gap-cue" && e.phase !== "compose"), "its page drawn");
+});
+
+test("a clip that is not first, after a real crossfade: measureChromeSchedule puts its mark at its segment's start plus its join", { skip: !have && "needs ffmpeg" }, async (t) => {
+ const p = project(t, { c2: { gaps: GAP }, render: { transition: 0.4, gapCue: { mark: true } } });
+ for (const id of ["c1", "c2"]) await p.build({ only: id });
+ const m = JSON.parse(readFileSync(p.manifestPath, "utf8"));
+ const segments = ["c1", "c2"].map((id) => path.join(p.v, "segments", `${id}.mp4`));
+ const sched = await measureChromeSchedule({ manifest: m, entries: m.timeline, segments, D: 0.4 });
+ const [s1, s2] = sched.segments;
+ assert.ok(Math.abs(s2.start - (s1.duration - 0.4)) < 1e-3, `c2 starts in c1's dissolve (${s2.start} vs ${s1.duration} - 0.4)`);
+ const rec = p.record("c2");
+ const k = sched.gapCue.marks[0];
+ assert.ok(Math.abs(k.at - (s2.start + offsetIn(6.5, rec.start, rec.gaps))) < 1e-3, `at ${k.at}`);
+ // The same with the mark off: no key; every other byte of the schedule the same.
+ const off = await measureChromeSchedule({ manifest: { ...m, render: { ...m.render, gapCue: { mark: false } } }, entries: m.timeline, segments, D: 0.4 });
+ const { gapCue: _g, ...rest } = sched;
+ assert.equal("gapCue" in off, false);
+ assert.equal(JSON.stringify(off), JSON.stringify(rest));
+});
diff --git a/umtool/report-to-video/gap-cue-slice.mjs b/umtool/report-to-video/gap-cue-slice.mjs
@@ -0,0 +1,310 @@
+// THE GAP MARKS ON THE CUT'S CLOCK (lane gap-cue, slice 1d): the schedule's
+// `gapCue` slice, which the gap-cue MODULE draws (modules/gap-cue.mjs: one
+// small HyperFrames page per mark, chrome-gap-cue.mjs) wherever a deck is drawn
+// -- so a mark turned on, moved, restyled or re-worded re-renders chrome only,
+// never a clip segment (gap-mark.mjs gapMarkByChrome: the segment then draws
+// none).
+//
+// THE JOINS come from what each clip's segment really left out: its cut record
+// (`start`, `end`, `gaps` -- the recording's seconds, between a clip's pieces
+// too), the record the schedule already reads for its gaps. A record written
+// before this slice carries all three, so an old take gets its marks from a
+// chrome-only pass: no re-cut. The record DECIDES: one written with no `gaps`
+// (a segment cut before its clip had them) plays them, so it has no join to
+// mark (the chrome-only pass says so, build-video.mjs segmentGapNote). Only
+// with no record at all (a preview before any build) do the clip's play window
+// and its own gaps stand in. The marks themselves -- the threshold, the merge
+// inside a life, the text -- are gap-mark-place.mjs recordGapMarks, the
+// drawtext path's own rule, then on the cut's clock: `segment.start + at`.
+//
+// A clip whose record carries `gapMarks` was built with its marks drawn INTO
+// its segment (the drawtext path: `--no-chrome`, or a build before this slice):
+// the slice leaves it out (`inSegment`), so a mark is never drawn twice on one
+// frame. A full build rebuilds that segment without them (its plain key) first.
+//
+// WHERE (`place`, the clip's over the project's):
+// footage in the footage box (deck.mjs overlayBox; a twocrop clip's crop one
+// inside the stacked deck's safe area), at its corner -- `auto` the
+// deck's bottom left (twocrop: top right) -- hopping to the next free
+// corner off a hidden region, a stamp, the posts' column, the chat
+// column, a chapter's cover, the stats panel and the effects'
+// screenshots while one is up (none free: the asked corner).
+// deck in the band, right-aligned at the end of the source line's row
+// (left of the QR's plate and a tally beside it), centred on the row,
+// a size under the source line's text. The deck's own page is not
+// touched: the source line keeps its words, the status part at its
+// end included. When the line (status and all, at its longest,
+// reckoned in the face the deck sets it in: deckLineWidth) and the
+// mark do not both fit the row, the mark is drawn over the footage
+// instead (`fell: "row"`); so it is in the stacked vertical deck (its
+// band is laid otherwise: `fell: "stacked"`) and over a segment that
+// hides the deck (`fell: "hidden"`). The PAGE checks again in its own
+// faces (chrome-gap-cue.mjs: `line`, `alt`), so a reckoning that is
+// short can never put the mark on the line's words.
+//
+// PURE: a schedule and a render in, the slice out. Byte for byte: no clip
+// wanting a mark, no slice (the key absent).
+import { GAP_CUE_LOOK, clipGapCueOf, gapCueWanted } from "yt-dlp-transcript-common/lib/report/gapCue.mjs";
+import { sourceLineRow, subtitleTokens } from "./chrome-deck.mjs";
+import { censorRegionsOf } from "./clip-censor.mjs";
+import { chatGeometry } from "./chrome-chat.mjs";
+import { chapterCover, chapterWindows } from "./chrome-story.mjs";
+import { deckGeometry, deckLayout, deckOn, deckScale, fxGeometry, overlayBox, playWindow, postsGeometry, stampGeometry, statsGeometry } from "./deck.mjs";
+import { FX_RECEIPTS_MAX } from "./fx.mjs";
+import { tallyOf } from "./factcheck.mjs";
+import { censorAvoidRects, gapMarkAsked, gapMarkPlaces, gapMarkSize, monoWidth, recordGapMarks, sansWidth, twoCropMarkBox } from "./gap-mark-place.mjs";
+import { recordGaps } from "./gaps.mjs";
+import { clipTwoCrop, stackedGeometry, stackedOn } from "./vertical-deck.mjs";
+
+const r4 = (v) => Math.round(v * 10000) / 10000;
+const rectOf = (b) => ({ x: b.x, y: b.y, w: b.w ?? b.width, h: b.h ?? b.height });
+const fin = (v) => typeof v === "number" && Number.isFinite(v);
+
+/**
+ * How wide a mark's text is reckoned in the deck's bold face, whatever face the brand gives it: the wider of a bold
+ * sans's advances (sansWidth) and a monospace's (monoWidth, Plex Mono -- the default deck's bold). A reckoning that
+ * errs wide places and hops the mark; the page sizes the element to its text, never cutting one that fits its room.
+ */
+export const deckFaceWidth = (text, fontSize) => Math.max(sansWidth(text, fontSize), monoWidth(text, fontSize));
+
+/** The shortest a mark is drawn for, seconds (its join too near the dissolve out of its segment: none). */
+export const GAP_CUE_MIN_UP = 0.2;
+
+/** The deck place's text against the source line's: a size under it (its box then sits inside the row and the air round it). */
+export const GAP_CUE_DECK_FONT = 0.9;
+/** The deck place's line box, in ems: the row is short, so the box is the text's own height. */
+export const GAP_CUE_DECK_LINE = 1;
+
+/**
+ * The basis a clip's marks are taken from. Its cut record DECIDES when it has one: the seconds it starts and ends at
+ * and the gaps it really left out (`gaps` absent = none: a segment cut before its gaps plays them, so it has no
+ * joins to mark -- null when the record cannot say where the segment starts). Only with no record at all (a
+ * preview before any build) do its play window and its own gaps inside it stand in, an estimate as a preview's
+ * segments are.
+ *
+ * @returns {{ start: number, end: number, gaps: Array<{ from: number, to: number }> } | null}
+ */
+export function basisOf(entry, render, rec) {
+ if (rec) {
+ if (!fin(Number(rec.start)) || !fin(Number(rec.end))) return null;
+ return { ...rec, gaps: recordGaps(rec) };
+ }
+ const pw = playWindow(entry, render);
+ const gaps = (Array.isArray(entry.gaps) ? entry.gaps : [])
+ .filter((g) => fin(g?.from) && fin(g?.to) && g.to > pw.from && g.from < pw.to)
+ .map((g) => ({ from: Math.max(pw.from, g.from), to: Math.min(pw.to, g.to) }))
+ .filter((g) => g.to > g.from);
+ return { start: pw.from, end: pw.to, gaps };
+}
+
+/** The air a deck-placed mark keeps after the source line's end, band px at 1080 (deckScale). */
+export const GAP_CUE_DECK_AIR = 24;
+
+/** Is the deck's regular face the brand's IBM Plex Mono (brand.mjs resolveBrandRender)? Read by its file's name. */
+const monoDeck = (render) => /IBMPlexMono-Regular\.[ot]tf$/i.test(String(render?.fontRegular ?? ""));
+
+/**
+ * How wide a source line draws, px, reckoned WIDE: its parts in the face the page sets them in (the brand's Plex
+ * Mono when `render.fontRegular` is it; else the wider of a sans's advances and a mono's, whatever face it is),
+ * each separator its bold dot and the 0.42 em of padding either side of it (chrome-deck.mjs `.deck-sub .sep`), and
+ * the line's 0.005 em letter-spacing on every character, each glyph's advance rounded up to a whole pixel. The page measures the line itself too, once its faces
+ * are in (chrome-gap-cue.mjs): this only decides where the mark is laid, never alone that it is clear of the text.
+ */
+export function deckLineWidth({ text, parts = null, size, render }) {
+ const said = subtitleTokens(text, parts)?.map((p) => p[1]) ?? String(text ?? "").split(" · ");
+ const mono = monoDeck(render);
+ // Per glyph, rounded up: the render browser lays a hinted face's advances on whole pixels (Plex Mono at 26 px
+ // draws 16 px a glyph, not 15.6).
+ const glyph = (ch) => (mono ? monoWidth(ch, size) : Math.max(sansWidth(ch, size), monoWidth(ch, size)));
+ const face = (v) => [...v].reduce((n, ch) => n + glyph(ch), 0);
+ const seps = Math.max(0, said.length - 1);
+ const chars = said.reduce((n, v) => n + [...v].length, 0) + seps;
+ return Math.ceil(said.reduce((n, v) => n + face(v), 0) + seps * (monoWidth("·", size) + 0.84 * size) + 0.005 * size * chars);
+}
+
+/**
+ * The deck place's rect for one mark's text, frame px, or why it cannot stand there (`fell`): right-aligned at the
+ * source line row's end, centred on the row (chrome-deck.mjs sourceLineRow: the rows the page lays the line on).
+ * `line` is what the page measures before it shows the mark: the line's row, its words and its size.
+ *
+ * @returns {{ rect: { x: number, y: number, w: number, h: number }, font: number, stroke: number, room: number,
+ * line: { x: number, y: number, size: number, air: number, text: string, parts: unknown } } | { fell: string }}
+ */
+export function gapCueDeckRect({ render, schedule, segment, text }) {
+ if (stackedOn(render)) return { fell: "stacked" };
+ if (segment.hideDeck) return { fell: "hidden" };
+ const { deck: band } = deckGeometry(render);
+ const lay = deckLayout(render, { tally: tallyOf(schedule, render), schedule });
+ const t = lay.text;
+ const k = deckScale(render);
+ const z = (v) => (k === 1 ? v : Math.round(v * k));
+ const row = sourceLineRow(t, segment);
+ const font = Math.max(12, Math.round(row.size * GAP_CUE_DECK_FONT));
+ const stroke = Math.max(GAP_CUE_LOOK.strokeMin, Math.round(Math.min(render.width ?? 1920, render.height ?? 1080) * GAP_CUE_LOOK.stroke));
+ const edge = Math.round(font * GAP_CUE_LOOK.pad) + stroke;
+ const w = deckFaceWidth(text, font) + 2 * edge;
+ const h = Math.ceil(font * GAP_CUE_DECK_LINE) + 2 * edge;
+ const right = t.x + t.width - z(22);
+ const air = z(GAP_CUE_DECK_AIR);
+ // The source line as it would draw at its longest (its status at its longest too), and air before the mark.
+ const lineW = deckLineWidth({ text: row.text, parts: row.parts, size: row.size, render });
+ if (t.x + lineW + air > right - w) return { fell: "row" };
+ return {
+ rect: { x: band.x + right - w, y: band.y + row.y + Math.round((row.box - h) / 2), w, h },
+ font, stroke,
+ // Its room: from the line's end (and the air after it) to the row's.
+ room: right - (t.x + lineW + air),
+ line: { x: band.x + t.x, y: band.y + row.y, size: row.size, air, text: row.text, parts: row.parts ?? null },
+ };
+}
+
+/**
+ * What stands over the footage that a mark keeps off, frame px, each over its cut seconds (`from`–`to`): the
+ * stamps while each is up, the posts' column while a clip's cards are, the chat column while a clip shows chat,
+ * a chapter's cover while its bumper is up, the stats panel while a clip shows its stats, the effects' screenshots
+ * (the receipts, the zoom) while each is up.
+ */
+export function moduleAvoids(schedule, render) {
+ const feed = schedule.layout === "feed";
+ const out = [];
+ const stamps = schedule.factcheck?.stamps ?? [];
+ if (stamps.length) {
+ const g = rectOf(stampGeometry(render, { feed }));
+ for (const s of stamps) if (fin(s.at) && Array.isArray(s.out)) out.push({ ...g, from: s.at, to: s.out[1] });
+ }
+ if (!feed && (schedule.posts ?? []).length) {
+ const g = rectOf(postsGeometry(render));
+ for (const p of schedule.posts) if (fin(p.appear) && Array.isArray(p.out)) out.push({ ...g, from: p.appear, to: p.out[1] });
+ }
+ for (const c of schedule.chat?.clips ?? []) {
+ out.push({ ...rectOf(chatGeometry(render, { feed })), from: c.in, to: c.out });
+ }
+ if (render?.chrome?.chapter) {
+ const g = rectOf(chapterCover(render, { feed }));
+ for (const w of chapterWindows(schedule, render)) out.push({ ...g, from: w.from, to: w.to });
+ }
+ // The stats panel while a clip that declares stats shows it.
+ if ((schedule.stats?.clips ?? []).length) {
+ const g = rectOf(statsGeometry(render, { feed }));
+ for (const c of schedule.stats.clips) if (fin(c.in) && fin(c.out)) out.push({ ...g, from: c.in, to: c.out });
+ }
+ out.push(...fxShotAvoids(schedule, render, feed));
+ return out;
+}
+
+/**
+ * Where the effects' screenshots stand while each is up (chrome-fx.mjs fxPlan), reckoned at their largest -- the
+ * page sizes a card to its shot, which the schedule does not know: the receipts' fan, a column on their side of the
+ * footage box as wide as `receipts.width` plus the fan's spread and inset, the whole box tall; the zoom's card, centred,
+ * `zoom.width` of the box wide and 84 % of it tall.
+ */
+function fxShotAvoids(schedule, render, feed) {
+ const fx = schedule.fx;
+ if (!fx) return [];
+ const geo = rectOf(fxGeometry(render, { feed }));
+ const px = (v) => Math.max(1, Math.round(v * (geo.w / 1574)));
+ const out = [];
+ if (fx.receipts?.clips?.length) {
+ const right = fx.receipts.position !== "left";
+ const w = Math.min(geo.w, Math.ceil((fx.receipts.width ?? 0.36) * geo.w) + px(48) + (FX_RECEIPTS_MAX - 1) * px(22) + px(8));
+ const rect = { x: right ? geo.x + geo.w - w : geo.x, y: geo.y, w, h: geo.h };
+ for (const r of fx.receipts.clips) if (fin(r.in) && fin(r.out)) out.push({ ...rect, from: r.in, to: r.out });
+ }
+ if (fx.zoom?.clips?.length) {
+ const w = Math.min(geo.w, Math.ceil((fx.zoom.width ?? 0.6) * geo.w) + 2 * px(8));
+ const h = Math.min(geo.h, Math.ceil(geo.h * 0.84) + px(36) + 2 * px(8));
+ const rect = { x: geo.x + Math.floor((geo.w - w) / 2), y: geo.y + Math.floor((geo.h - h) / 2), w, h };
+ for (const z of fx.zoom.clips) if (fin(z.in) && fin(z.out)) out.push({ ...rect, from: z.in, to: z.out });
+ }
+ return out;
+}
+
+/**
+ * The schedule's `gapCue` slice: `{ marks: [...], inSegment?: [clip ids] }`, or null when no clip wants a mark
+ * (or no deck is drawn). Each mark: `{ id, segment, at, until, seconds, count?, text, place, corner?, asked?,
+ * rect, room, font, stroke, fell? }` -- `at`/`until` the cut's seconds, `rect` frame px (its width reckoned wide:
+ * deckFaceWidth), `room` the widest the element may draw, `font`/`stroke` px.
+ *
+ * @param {Record<string, any>} schedule the deck's (deckSchedule): its segments, stamps, posts, chat
+ * @param {{ entries: any[], render: any, records?: Map<string, any> | null, provenance?: any }} o
+ */
+export function gapCueSlice(schedule, { entries, render, records = null, provenance = {} }) {
+ if (!deckOn(render)) return null;
+ const wanted = entries.filter((e) => e?.type === "clip" && Array.isArray(e.gaps) && e.gaps.length && gapCueWanted(render, e));
+ if (!wanted.length) return null;
+ const segs = new Map((schedule.segments ?? []).map((s) => [s.id, s]));
+ const lastSeg = (schedule.segments ?? []).at(-1) ?? null;
+ const D = Number(schedule.transition) > 0 ? Number(schedule.transition) : 0;
+ const W = render.width ?? 1920;
+ const H = render.height ?? 1080;
+ const size = gapMarkSize(W, H);
+ const feed = schedule.layout === "feed";
+ const avoids = moduleAvoids(schedule, render);
+ const marks = [];
+ const inSegment = [];
+ for (const e of wanted) {
+ const seg = segs.get(e.id);
+ if (!seg) continue;
+ const rec = records?.get(e.id) ?? null;
+ if (Array.isArray(rec?.gapMarks) && rec.gapMarks.length) {
+ inSegment.push(e.id);
+ continue;
+ }
+ const basis = basisOf(e, render, rec);
+ if (!basis) continue;
+ const own = recordGapMarks({ render, entry: e, record: basis });
+ if (!own.length) continue;
+ const cue = clipGapCueOf(render, e);
+ // Over the footage: the footage box (twocrop: crop one inside the safe area), the deck's free corner.
+ const twocrop = stackedOn(render) && clipTwoCrop(e);
+ const fb = twocrop ? twoCropMarkBox(stackedGeometry(render)) : { box: rectOf(overlayBox(render, { feed })), prefer: "bl" };
+ const base = rectOf(fb.box);
+ // A hidden region (clip-censor.mjs), mapped onto the box as the drawtext path maps it, over the cut's seconds.
+ const segSeconds = Number(basis.end) - Number(basis.start) - basis.gaps.reduce((n, g) => n + (g.to - g.from), 0);
+ const censor = twocrop
+ ? []
+ : censorAvoidRects(censorRegionsOf(e, render, provenance), {
+ sw: 1, sh: 1, dest: base, from: Number(basis.start), gaps: basis.gaps, seconds: segSeconds,
+ }).map((a) => ({ ...a, from: a.from == null ? null : seg.start + a.from, to: a.to == null ? null : seg.start + a.to }));
+ // On the cut's clock, and gone before the dissolve into the next segment begins (its picture is the next
+ // clip's by then): a mark that would run on into it ends there, fading out by then. One left shorter than
+ // GAP_CUE_MIN_UP is not drawn.
+ const outAt = segs.size && seg !== lastSeg ? seg.end - D : seg.end;
+ const onCut = own
+ .map((m) => ({ ...m, at: r4(seg.start + m.at), until: r4(Math.min(seg.start + m.until, outAt)) }))
+ .filter((m) => m.until - m.at >= GAP_CUE_MIN_UP);
+ if (!onCut.length) continue;
+ const places = gapMarkPlaces({ marks: onCut, box: base, want: cue.corner, prefer: fb.prefer, size, avoid: [...censor, ...avoids], measure: deckFaceWidth });
+ // Over the footage, a mark's room is its box less the insets.
+ const room = base.w - 2 * size.inset;
+ onCut.forEach((m, k) => {
+ const asked = gapMarkAsked(m, cue.corner);
+ const common = {
+ id: `${e.id}.g${k}`, segment: e.id, at: m.at, until: m.until, seconds: m.seconds, ...(m.count > 1 ? { count: m.count } : {}),
+ };
+ const p = places[k];
+ const footage = { text: p.text, place: "footage", corner: p.corner, ...(asked ? { asked } : {}), rect: p.rect, room, font: p.size.fontSize, stroke: p.size.stroke };
+ if (cue.place === "deck") {
+ const d = gapCueDeckRect({ render, schedule, segment: seg, text: m.text });
+ if ("rect" in d) {
+ // `line`: what the page measures in its own faces before it shows the mark; `alt`: where it stands
+ // instead when the line and the mark would touch (chrome-gap-cue.mjs) -- never on the text.
+ marks.push({ ...common, text: m.text, place: "deck", rect: d.rect, room: d.room, font: d.font, stroke: d.stroke, line: d.line, alt: footage });
+ return;
+ }
+ marks.push({ ...common, ...footage, fell: d.fell });
+ return;
+ }
+ marks.push({ ...common, ...footage });
+ });
+ }
+ if (!marks.length && !inSegment.length) return null;
+ return { marks, ...(inSegment.length ? { inSegment } : {}) };
+}
+
+/** `schedule` with its gap-cue slice (gapCueSlice) set -- or as it was, the key absent, when there is none. */
+export function withGapCue(schedule, o) {
+ const { gapCue: _was, ...rest } = schedule;
+ const slice = gapCueSlice(rest, o);
+ return slice ? { ...rest, gapCue: slice } : (_was === undefined ? schedule : rest);
+}
diff --git a/umtool/report-to-video/gap-cue-slice.test.mjs b/umtool/report-to-video/gap-cue-slice.test.mjs
@@ -0,0 +1,509 @@
+// The gap mark as a HyperFrames module (lane gap-cue, slice 1d): the schedule's `gapCue` slice (gap-cue-slice.mjs)
+// from the cut records the schedule already reads -- an old record with no `gapMarks` field included (the
+// retrofit: a chrome-only pass, no re-cut) -- its two places (over the footage at the corner, in the deck at the end
+// of the source line, beside the source status and the QR), the hop off a stamp while it is up, a clip whose
+// segment drew its own marks left out; the module's page and regions; and the mark off or unset is no slice, no
+// region, and no change to any page or schedule, byte for byte.
+//
+// Run with: node --test umtool/report-to-video/gap-cue-slice.test.mjs
+import assert from "node:assert/strict";
+import { createHash } from "node:crypto";
+import test from "node:test";
+
+import { deckHtml } from "./chrome-deck.mjs";
+import { gapCueHtml, gapCueWindows } from "./chrome-gap-cue.mjs";
+import { deckGeometry, deckLayout, estimateSchedule, overlayBox, stampGeometry } from "./deck.mjs";
+import { tallyOf } from "./factcheck.mjs";
+import { gapCueDeckRect, gapCueSlice, withGapCue } from "./gap-cue-slice.mjs";
+import { gapMarkByChrome } from "./gap-mark.mjs";
+import { verticalRender } from "./vertical.mjs";
+import gapCueModule from "./modules/gap-cue.mjs";
+
+const PALETTE = { bg: "#12101a", fg: "#f4f1ea", muted: "#9a93ad", accent: "#a97bff", amber: "#ffc860" };
+const FONTS = { regular: "assets/DeckSans.ttf", bold: "assets/DeckSansBold.ttf" };
+const sha = (s) => createHash("sha256").update(s).digest("hex");
+
+const clip = (id, video, start, extra = {}) => ({ id, type: "clip", video, start, end: start + 20, cite: start + 2, quote: "a synthetic line", ...extra });
+function manifest({ gapCue = undefined, deck = {}, chrome = {}, timeline = null, render = {} } = {}) {
+ return {
+ title: "Synthetic cut",
+ provenance: { channelSlug: "synth-channel", channel: "Synth Channel", siteOrigin: "https://archive.example.test" },
+ render: {
+ width: 1920, height: 1080, fps: 30, transition: 0.5, palette: PALETTE,
+ chrome: { engine: "hyperframes", layout: "deck", deck, ...chrome },
+ ...(gapCue !== undefined ? { gapCue } : {}),
+ ...render,
+ },
+ timeline: timeline ?? [
+ clip("c01", "synthvid001", 600, { onscreen: { title: "The first moment" }, gaps: [{ from: 605, to: 617 }] }),
+ clip("c02", "synthvid002", 1200, { onscreen: { title: "The second moment" } }),
+ ],
+ };
+}
+const META = (n) => ({ title: `Synthetic stream ${n}`, uploadDate: "20310301", channel: "Synth Channel", webpageUrl: `https://video.example.test/${n}` });
+const METAS = [META(1), META(2)];
+const scheduleOf = (m, metas = METAS) => estimateSchedule(m, { metas });
+/** A cut record as a build before this slice wrote it: start, end, gaps -- no gapMarks. */
+const OLD_RECORD = { version: 1, id: "c01", video: "synthvid001", start: 599.8, end: 620.1, snapped: { start: 599.8, end: 620.1 }, gaps: [{ from: 605, to: 617 }], framing: { layout: "deck" } };
+const sliceOf = (m, records = new Map([["c01", OLD_RECORD]]), metas = METAS) => gapCueSlice(scheduleOf(m, metas), { entries: m.timeline, render: m.render, records, provenance: m.provenance });
+
+test("who draws it: the module wherever the deck is laid over the picture, else the drawtext", () => {
+ const deck = manifest().render;
+ assert.equal(gapMarkByChrome(deck), true);
+ assert.equal(gapMarkByChrome(deck, { noChrome: true }), false, "--no-chrome");
+ assert.equal(gapMarkByChrome({ ...deck, chrome: undefined }), false, "the plain cut");
+ assert.equal(gapMarkByChrome(verticalRender({ ...deck, format: "vertical", vertical: { deck: "stacked" } })), true, "the stacked vertical deck");
+ assert.equal(gapMarkByChrome(verticalRender({ ...deck, format: "vertical", vertical: { deck: "bare" } })), false, "a bare vertical cut");
+});
+
+test("retrofit: an old record (no gapMarks field) gives the marks on the cut's clock -- the join, its life, its text", () => {
+ const m = manifest({ gapCue: { mark: true } });
+ const s = sliceOf(m);
+ const seg = scheduleOf(m).segments[0];
+ assert.equal(s.marks.length, 1);
+ const k = s.marks[0];
+ assert.equal(k.id, "c01.g0");
+ assert.equal(k.segment, "c01");
+ assert.equal(k.text, "» 12 s");
+ // The join is 5.2 s into the segment (599.8 → 605), on the cut's clock from the segment's start; up a life.
+ assert.ok(Math.abs(k.at - (seg.start + 5.2)) < 1e-3, `at ${k.at}`);
+ assert.ok(Math.abs(k.until - k.at - 1.1) < 1e-3, `until ${k.until}`);
+ assert.equal(k.place, "footage");
+ assert.equal(k.corner, "bl", "the deck's free corner");
+ const box = overlayBox(m.render);
+ assert.ok(k.rect.x >= box.x && k.rect.y + k.rect.h <= box.y + box.height, "inside the footage box, at its foot");
+ assert.equal(s.inSegment, undefined);
+});
+
+test("with no record (a preview before a build) the play window and the clip's own gaps stand in", () => {
+ const m = manifest({ gapCue: { mark: true } });
+ const s = sliceOf(m, null);
+ assert.equal(s.marks.length, 1);
+ assert.equal(s.marks[0].text, "» 12 s");
+});
+
+test("a pieced record: every second left out -- between the pieces too -- and joins inside a life are one mark", () => {
+ const rec = { ...OLD_RECORD, start: 600, end: 900, gaps: [{ from: 605, to: 617 }, { from: 617.5, to: 890 }] };
+ const m = manifest({ gapCue: { mark: true }, timeline: [clip("c01", "synthvid001", 600, { end: 900, gaps: [{ from: 605, to: 617 }, { from: 617.5, to: 890 }] }), clip("c02", "synthvid002", 1200)] });
+ const s = sliceOf(m, new Map([["c01", rec]]));
+ assert.equal(s.marks.length, 1, "merged");
+ assert.equal(s.marks[0].count, 2);
+ assert.equal(s.marks[0].text, "» 4:45", "12 s and 272.5 s");
+});
+
+test("a clip whose segment drew its own marks (the drawtext path) is left out: never both on one frame", () => {
+ const m = manifest({ gapCue: { mark: true } });
+ const s = sliceOf(m, new Map([["c01", { ...OLD_RECORD, gapMarks: [{ at: 5.2, until: 6.3, seconds: 12, text: "» 12 s", corner: "bl" }] }]]));
+ assert.deepEqual(s, { marks: [], inSegment: ["c01"] });
+ assert.equal(gapCueModule.on(withGapCue(scheduleOf(m), { entries: m.timeline, render: m.render, records: new Map([["c01", { ...OLD_RECORD, gapMarks: [{}] }]]) })), false);
+});
+
+test("place deck: right-aligned at the end of the source line's row, left of the QR's plate, centred on the row", () => {
+ const m = manifest({ gapCue: { mark: true, place: "deck" } });
+ const sched = scheduleOf(m);
+ const s = sliceOf(m);
+ const k = s.marks[0];
+ assert.equal(k.place, "deck");
+ const { deck: band } = deckGeometry(m.render);
+ const lay = deckLayout(m.render, { tally: tallyOf(sched, m.render), schedule: sched });
+ assert.ok(k.rect.x + k.rect.w <= band.x + lay.qr.x - 46 - 20, `left of the plate (${JSON.stringify(k.rect)})`);
+ assert.ok(k.rect.x + k.rect.w <= band.x + lay.text.x + lay.text.width, "inside the text column");
+ const mid = band.y + lay.text.subtitleY + lay.text.subtitleBox / 2;
+ assert.ok(Math.abs(k.rect.y + k.rect.h / 2 - mid) <= 1, "centred on the source line's row");
+ assert.ok(k.rect.y >= band.y + lay.text.titleY + lay.text.titleBox, "under the title's box");
+ assert.ok(k.font < lay.text.subtitleSize, "a size under the source line");
+});
+
+test("place deck beside the source status: it fits after the line's words, or it falls to the footage -- the narrowest column too", () => {
+ const STAMP = { refreshedAt: "2031-03-02T00:00:00.000Z", sources: { "synth-channel/synthvid001": { now: "members_only", since: null, asOf: "2031-03-01T20:00:00Z", first: "public", firstAt: "2031-03-01T10:05:00Z", firstWhen: "live", from: "corpus", evidence: [] } } };
+ const withStatus = { ...manifest({ gapCue: { mark: true, place: "deck" }, deck: { subtitle: { parts: ["channel", "date", "clock"], status: "end" } } }), sourceStatus: STAMP };
+ const s = sliceOf(withStatus);
+ const seg = scheduleOf(withStatus).segments[0];
+ assert.match(seg.subtitle, /members-only/, "the line carries its status");
+ assert.equal(s.marks[0].place, "deck", "a short line (channel, date, clock, status) leaves room for the mark");
+ // The narrowest column: a tally beside the QR (a stamped claim) and a long source title in the line too.
+ const LONG = [1, 2].map((n) => ({ ...META(n), title: `Synthetic stream ${n}: a long title about a great many things at once` }));
+ const narrow = {
+ ...manifest({
+ gapCue: { mark: true, place: "deck" },
+ deck: { subtitle: { status: "end" } },
+ chrome: { factcheck: { stamp: { seconds: 1 } } },
+ timeline: [
+ clip("c01", "synthvid001", 600, { onscreen: { title: "The first moment" }, gaps: [{ from: 605, to: 617 }], claim: { id: "k1", verdict: "CORROBORATED" } }),
+ clip("c02", "synthvid002", 1200, { claim: { id: "k2", verdict: "CORROBORATED" } }),
+ ],
+ }),
+ sourceStatus: STAMP,
+ };
+ const sch = scheduleOf(narrow, LONG);
+ const lay = deckLayout(narrow.render, { tally: tallyOf(sch, narrow.render), schedule: sch });
+ assert.ok(lay.tally, "a tally narrows the column");
+ const ns = sliceOf(narrow, undefined, LONG);
+ assert.equal(ns.marks[0].place, "footage", "no room on the row: over the footage, never over the line or the status");
+ assert.equal(ns.marks[0].fell, "row");
+ // Asked directly: the row's own answer.
+ assert.deepEqual(gapCueDeckRect({ render: narrow.render, schedule: sch, segment: sch.segments[0], text: "» 12 s" }), { fell: "row" });
+});
+
+test("place deck in the stacked vertical deck, or over a segment that hides the deck: over the footage", () => {
+ const m = manifest({ gapCue: { mark: true, place: "deck" } });
+ const v = { ...m, render: verticalRender({ ...m.render, format: "vertical" }) };
+ const s = gapCueSlice(scheduleOf(v), { entries: v.timeline, render: v.render, records: new Map([["c01", OLD_RECORD]]) });
+ assert.equal(s.marks[0].place, "footage");
+ assert.equal(s.marks[0].fell, "stacked");
+ const sch = scheduleOf(m);
+ assert.deepEqual(gapCueDeckRect({ render: m.render, schedule: sch, segment: { ...sch.segments[0], hideDeck: true }, text: "» 1 s" }), { fell: "hidden" });
+});
+
+test("over the footage it hops off a stamp while the stamp is up (its corner), and stays where asked otherwise", () => {
+ // A stamp at the bottom left, up over the join: the mark hops to the next free corner.
+ const m = manifest({
+ gapCue: { mark: true },
+ chrome: { factcheck: { stamp: { position: "bottom-left", seconds: 8 } } },
+ // Stamped just after the gap: the stamp slams in at the join and stays 8 s.
+ timeline: [clip("c01", "synthvid001", 600, { gaps: [{ from: 605, to: 617 }], claim: { id: "k1", verdict: "CORROBORATED", at: 617.2 } }), clip("c02", "synthvid002", 1200)],
+ });
+ const sch = scheduleOf(m);
+ const st = sch.factcheck.stamps[0];
+ const k = sliceOf(m).marks[0];
+ const g = stampGeometry(m.render);
+ assert.ok(st.at < k.until && st.out[1] > k.at, `the stamp is up while the mark is (${st.at}-${st.out[1]} vs ${k.at}-${k.until})`);
+ assert.notEqual(k.corner, "bl", "hopped off the stamp");
+ const r = k.rect;
+ assert.ok(!(r.x < g.x + g.width && g.x < r.x + r.w && r.y < g.y + g.height && g.y < r.y + r.h), "not over the stamp");
+ // Without the stamp, the deck's free corner.
+ const bare = manifest({ gapCue: { mark: true } });
+ assert.equal(sliceOf(bare).marks[0].corner, "bl");
+});
+
+test("the page: one mark, its text escaped, the look's CSS (a real border, the deck's face), cues at the join and the end", () => {
+ const m = manifest({ gapCue: { mark: true, label: "{s} <later>" } });
+ const sched = withGapCue(scheduleOf(m), { entries: m.timeline, render: m.render, records: new Map([["c01", OLD_RECORD]]) });
+ const [w] = gapCueWindows(sched);
+ const html = gapCueHtml(sched, m.render, w, { fonts: FONTS });
+ assert.match(html, /data-gm="12 s <later>"/);
+ assert.ok(!html.includes("<later>"), "escaped");
+ assert.match(html, /border: 2px solid rgba\(255, 255, 255, 0\.9\)/);
+ assert.match(html, /font-family: 'DeckSansBold'/);
+ assert.match(html, /id="gap-cue-data"/);
+ const data = JSON.parse(/<script id="gap-cue-data" type="application\/json">(.*?)<\/script>/s.exec(html)[1]);
+ assert.equal(data.cues.length, 2);
+ assert.equal(data.cues[0].at, Math.round(w.mark.at * 10000) / 10000);
+ assert.equal(data.cues[0].to.autoAlpha, 0.9);
+ assert.equal(data.cues[1].to.autoAlpha, 0);
+ assert.ok(Math.abs(data.cues[1].at + data.cues[1].dur - w.mark.until) < 1e-3, "gone by its end");
+ assert.equal(data.cues[0].ease, "none", "linear, as the drawtext's alpha");
+ // The module's regions: one window per mark, over the whole frame.
+ const regions = gapCueModule.regions(sched, { render: m.render, outDir: "/out" });
+ assert.equal(regions.length, 1);
+ assert.deepEqual([regions[0].x, regions[0].y, regions[0].width, regions[0].height], [0, 0, 1920, 1080]);
+ assert.equal(regions[0].segment, "c01.g0");
+ assert.equal(regions[0].frames, "/out/chrome/gap-cue-c01.g0-frames");
+ assert.ok(regions[0].frameCount >= 33 && regions[0].frameCount <= 35, `about a life of frames (${regions[0].frameCount})`);
+});
+
+test("BYTE FOR BYTE: the mark off or unset is no slice and no region, and the deck's schedule and page are the same", () => {
+ const base = manifest();
+ const b = scheduleOf(base);
+ const page = sha(deckHtml(b, base.render, { fonts: FONTS }));
+ for (const [what, gapCue, extra] of [["unset", undefined, {}], ["mark false", { mark: false }, {}], ["place deck, mark off", { place: "deck" }, {}], ["a clip's gapCue saying nothing on", undefined, { gapCue: { corner: "tr" } }]]) {
+ const m = manifest({ gapCue });
+ m.timeline[0] = { ...m.timeline[0], ...extra };
+ const s = scheduleOf(m);
+ const w = withGapCue(s, { entries: m.timeline, render: m.render, records: new Map([["c01", OLD_RECORD]]) });
+ assert.equal(w, s, `${what}: the same schedule object`);
+ assert.equal("gapCue" in w, false, `${what}: no key`);
+ assert.equal(gapCueModule.on(w), false, `${what}: no module`);
+ assert.deepEqual(gapCueModule.regions(w, { render: m.render, outDir: "/o" }), []);
+ assert.equal(sha(JSON.stringify(s)), sha(JSON.stringify(b)), `${what}: the schedule`);
+ assert.equal(sha(deckHtml(s, m.render, { fonts: FONTS })), page, `${what}: the deck's page`);
+ }
+ // ON: the deck's own page is the same bytes (the mark is a page of its own).
+ const on = manifest({ gapCue: { mark: true, place: "deck" } });
+ const so = withGapCue(scheduleOf(on), { entries: on.timeline, render: on.render, records: new Map([["c01", OLD_RECORD]]) });
+ assert.ok(so.gapCue.marks.length);
+ assert.equal(sha(deckHtml(so, on.render, { fonts: FONTS })), sha(deckHtml(scheduleOf(on), on.render, { fonts: FONTS })), "the deck's page does not read the slice");
+ // No deck: no slice, whatever is set (the drawtext path draws it).
+ const plain = manifest({ gapCue: { mark: true } });
+ delete plain.render.chrome;
+ assert.equal(gapCueSlice({ segments: [] }, { entries: plain.timeline, render: plain.render }), null);
+});
+
+test("byte for byte in the stacked vertical deck and with a twocrop clip: off, no slice; on, crop one's top right", () => {
+ const twocrop = { vertical: { layout: "twocrop", crops: [[0, 0, 0.5, 1], [0.5, 0, 0.5, 1]] } };
+ for (const gapCue of [undefined, { mark: false }]) {
+ const m = manifest({ gapCue });
+ m.timeline[0] = { ...m.timeline[0], ...twocrop };
+ const v = { ...m, render: verticalRender({ ...m.render, format: "vertical" }) };
+ const s = scheduleOf(v);
+ assert.equal(withGapCue(s, { entries: v.timeline, render: v.render, records: new Map([["c01", OLD_RECORD]]) }), s);
+ }
+ const m = manifest({ gapCue: { mark: true } });
+ m.timeline[0] = { ...m.timeline[0], ...twocrop };
+ const v = { ...m, render: verticalRender({ ...m.render, format: "vertical" }) };
+ const s = gapCueSlice(scheduleOf(v), { entries: v.timeline, render: v.render, records: new Map([["c01", OLD_RECORD]]) });
+ assert.equal(s.marks[0].corner, "tr");
+});
+
+test("composeChrome(gap-cue): one project and frame sequence per mark, keyed; the same mark cached, another corner a new key; frame keys model the page", async () => {
+ const { chmodSync, mkdtempSync, readFileSync, rmSync, writeFileSync } = await import("node:fs");
+ const { tmpdir } = await import("node:os");
+ const path = (await import("node:path")).default;
+ const { fileURLToPath } = await import("node:url");
+ const { composeChrome } = await import("./compose-chrome.mjs");
+ const { frameKeys } = await import("./frame-keys.mjs");
+ const HERE = path.dirname(fileURLToPath(import.meta.url));
+ const dir = mkdtempSync(path.join(tmpdir(), "gap-cue-c1-"));
+ const prevBin = process.env.HYPERFRAMES_BIN;
+ try {
+ // A stub renderer: as many empty frames as the page lasts, each run logged.
+ const stub = path.join(dir, "hf-stub.mjs");
+ writeFileSync(stub, `#!/usr/bin/env node
+import { appendFileSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
+import path from "node:path";
+const a = process.argv.slice(2);
+const out = a[a.indexOf("--output") + 1], fps = Number(a[a.indexOf("--fps") + 1]), proj = a[a.length - 1];
+const dur = Number(/data-duration="([\\d.]+)"/.exec(readFileSync(path.join(proj, "index.html"), "utf8"))[1]);
+mkdirSync(out, { recursive: true });
+for (let i = 1; i <= Math.round(dur * fps); i += 1) writeFileSync(path.join(out, "frame_" + String(i).padStart(6, "0") + ".png"), "");
+appendFileSync(${JSON.stringify(path.join(dir, "runs.log"))}, a.join(" ") + "\\n");
+`);
+ chmodSync(stub, 0o755);
+ process.env.HYPERFRAMES_BIN = stub;
+ const m = manifest({ gapCue: { mark: true } });
+ m.render.fontRegular = path.join(HERE, "fonts", "IBMPlexMono-Regular.ttf");
+ m.render.fontBold = path.join(HERE, "fonts", "IBMPlexMono-Bold.ttf");
+ const manifestPath = path.join(dir, "video.manifest.json");
+ writeFileSync(manifestPath, JSON.stringify({ slug: "t", ...m }));
+ const sched = withGapCue(scheduleOf(m), { entries: m.timeline, render: m.render, records: new Map([["c01", OLD_RECORD]]) });
+ const [w] = gapCueWindows(sched);
+ const runs = () => { try { return readFileSync(path.join(dir, "runs.log"), "utf8").trim().split("\n").length; } catch { return 0; } };
+ const first = await composeChrome({ manifestPath, region: "gap-cue", schedule: sched, window: { segment: w.segment, from: w.from, to: w.to }, doRender: true });
+ const [region] = gapCueModule.regions(sched, { render: m.render, outDir: path.join(dir, "out", "sourced") });
+ assert.equal(first.frames, region.frames, "where the overlay reads it");
+ assert.equal(first.frameCount, region.frameCount);
+ assert.equal(first.projDir, path.join(dir, "out", "sourced", "chrome", "gap-cue-c01.g0"));
+ const html = readFileSync(path.join(first.projDir, "index.html"), "utf8");
+ assert.match(html, /url\('assets\/DeckSansBold\.ttf'\)/);
+ assert.match(html, /data-composition-id="gap-cue"/);
+ assert.ok(frameKeys({ html, region: "gap-cue", assets: [], fps: 30, frames: first.frameCount, version: "x" }), "the frame-key model reads the page");
+ const again = await composeChrome({ manifestPath, region: "gap-cue", schedule: sched, segment: w.segment, doRender: true });
+ assert.equal(again.cached, true);
+ assert.equal(runs(), 1);
+ // Another corner: that page's key changes (and only that page's).
+ const moved = { ...sched, gapCue: { ...sched.gapCue, marks: sched.gapCue.marks.map((k) => ({ ...k, corner: "tr", rect: { ...k.rect, x: 1500 } })) } };
+ const third = await composeChrome({ manifestPath, region: "gap-cue", schedule: moved, segment: w.segment, doRender: true });
+ assert.equal(third.cached, false);
+ assert.notEqual(third.key, first.key);
+ // A preview composes beside it and never renders (Play's layer).
+ const prev = await composeChrome({ manifestPath, region: "gap-cue", schedule: sched, segment: w.segment, preview: true, doRender: true });
+ assert.equal(prev.projDir, path.join(dir, "out", "sourced", "chrome", "gap-cue-preview-c01.g0"));
+ assert.equal(prev.frames, null);
+ await assert.rejects(composeChrome({ manifestPath, region: "gap-cue", schedule: sched, segment: "c02.g0" }), /no gap mark c02\.g0/);
+ } finally {
+ if (prevBin === undefined) delete process.env.HYPERFRAMES_BIN;
+ else process.env.HYPERFRAMES_BIN = prevBin;
+ rmSync(dir, { recursive: true, force: true });
+ }
+});
+
+// ---- review 1d ---------------------------------------------------------------------------------------------------
+
+const { resolveBrandRender } = await import("./brand.mjs");
+const { sourceLineRow, untitledRows } = await import("./chrome-deck.mjs");
+const { deckLineWidth, basisOf, moduleAvoids, GAP_CUE_DECK_AIR, GAP_CUE_MIN_UP } = await import("./gap-cue-slice.mjs");
+const { sansWidth } = await import("./gap-mark-place.mjs");
+const STATUS_STAMP = { refreshedAt: "2031-03-02T00:00:00.000Z", sources: { "synth-channel/synthvid001": { now: "members_only", since: null, asOf: "2031-03-01T20:00:00Z", first: "public", firstAt: "2031-03-01T10:05:00Z", firstWhen: "live", from: "corpus", evidence: [] } } };
+const branded = (extra = {}) => resolveBrandRender({ width: 1920, height: 1080, fps: 30, transition: 0.5, brand: "archilyzer-media", chrome: { engine: "hyperframes", layout: "deck", deck: { subtitle: { status: "end" } } }, gapCue: { mark: true, place: "deck" }, ...extra });
+
+test("review 1d, 1: a source line is reckoned in the face the deck sets it in (the brand's Plex Mono), its separators' padding and letter-spacing -- never under what the browser draws", () => {
+ const line = "Synth Channel · Mar 1, 2031 · 12:34";
+ // Measured in the render browser (Chromium, the deck's .deck-sub CSS) at 26 px: Plex Mono 543.7 px; Plex Sans 448.7, Fira Sans 411.7.
+ const mono = deckLineWidth({ text: line, size: 26, render: branded() });
+ assert.ok(mono >= 543.7 && mono <= 546, `branded: ${mono}`);
+ assert.ok(sansWidth(line, 26) < 543.7, "the bold-sans table alone was short of it (the defect)");
+ const other = deckLineWidth({ text: line, size: 26, render: { fontRegular: "/fonts/Some-Sans.ttf" } });
+ assert.ok(other >= 543.7, `any other face: at least the mono's (${other})`);
+ const long = "Synth Channel · Synthetic stream 1: a long title · Mar 1, 2031 · 1:02:34 · now members-only (public when streamed)";
+ const longMono = deckLineWidth({ text: long, size: 26, render: branded() });
+ assert.ok(longMono >= 1797.1 && longMono <= 1800, `branded long line: ${longMono} (Chromium 1797.1)`);
+});
+
+test("review 1d, 1: on a BRANDED deck a long source line with its status sends the mark over the footage, where the old reckoning stood it on the line", () => {
+ const render = branded();
+ const tl = [clip("c01", "synthvid001", 600, { onscreen: { title: "The first moment" }, gaps: [{ from: 605, to: 617 }] }), clip("c02", "synthvid002", 1200)];
+ const m = { title: "T", provenance: { channelSlug: "synth-channel", channel: "Synth Channel", siteOrigin: "https://archive.example.test" }, sourceStatus: STATUS_STAMP, render, timeline: tl };
+ const metasOf = (n) => [{ ...META(1), title: `Synthetic stream: ${"x".repeat(n)}` }, META(2)];
+ for (const [n, want] of [[10, "deck"], [20, "footage"]]) {
+ const sch = estimateSchedule(m, { metas: metasOf(n) });
+ const seg = sch.segments[0];
+ assert.match(seg.subtitle, /members-only \(public when streamed\)$/, "the status at its longest ends the line");
+ const lay = deckLayout(render, { tally: tallyOf(sch, render), schedule: sch });
+ const row = sourceLineRow(lay.text, seg);
+ const k = gapCueSlice(sch, { entries: tl, render, records: new Map([["c01", OLD_RECORD]]), provenance: m.provenance }).marks[0];
+ assert.equal(k.place, want, `${n}: ${k.place} (${k.fell ?? ""})`);
+ const { deck: band } = deckGeometry(render);
+ const lineEnd = band.x + lay.text.x + deckLineWidth({ text: row.text, parts: row.parts, size: row.size, render });
+ if (want === "deck") {
+ assert.ok(k.rect.x >= lineEnd + GAP_CUE_DECK_AIR, `clear of the line (${k.rect.x} vs ${lineEnd})`);
+ // What the page measures before it shows it, and where it goes if it must.
+ assert.equal(k.line.text, row.text);
+ assert.equal(k.line.x, band.x + lay.text.x);
+ assert.equal(k.alt.place, "footage");
+ assert.equal(k.alt.corner, "bl");
+ } else {
+ assert.equal(k.fell, "row");
+ // The bold-sans table alone would have stood it in the deck, on the line's end.
+ assert.ok(lay.text.x + sansWidth(row.text, row.size) + GAP_CUE_DECK_AIR < lay.text.x + lay.text.width - 22 - k.rect.w, "the old reckoning had room");
+ }
+ }
+});
+
+test("review 1d, 1: the deck mark's page measures the source line in its own faces and stands over the footage when they would touch", () => {
+ const render = branded();
+ const tl = [clip("c01", "synthvid001", 600, { onscreen: { title: "The first moment" }, gaps: [{ from: 605, to: 617 }] }), clip("c02", "synthvid002", 1200)];
+ const m = { title: "T", provenance: { channelSlug: "synth-channel", channel: "Synth Channel", siteOrigin: "https://archive.example.test" }, sourceStatus: STATUS_STAMP, render, timeline: tl };
+ const sched = withGapCue(estimateSchedule(m, { metas: METAS }), { entries: tl, render, records: new Map([["c01", OLD_RECORD]]), provenance: m.provenance });
+ const [w] = gapCueWindows(sched);
+ assert.equal(w.mark.place, "deck");
+ const html = gapCueHtml(sched, render, w, { fonts: FONTS });
+ // The line as the deck draws it: its parts, its separators, its size, on its row; never shown.
+ assert.match(html, /<div class="gm-line" aria-hidden="true"><span class="part" data-p="[a-z]+">/);
+ assert.match(html, /\.gm-line \{ position: absolute; left: \d+px; top: \d+px; display: flex; white-space: nowrap; visibility: hidden;/);
+ assert.match(html, /\.gm-line \.sep \{ padding: 0 0\.42em; font-family: 'DeckSansBold'/);
+ assert.match(html, new RegExp(`font-size: ${w.mark.line.size}px; letter-spacing: 0\\.005em;`));
+ // Measured once its faces are in, before the page says it is fitted; the fallback is the footage place.
+ assert.match(html, /Promise\.all\(\[document\.fonts\.load\("\d+px DeckSans"\)/);
+ assert.match(html, /gm\.classList\.add\("fell"\)[\s\S]*gm\.dataset\.fell = "line";[\s\S]*document\.documentElement\.dataset\.fit = "1";/);
+ assert.match(html, /\.gm\.fell \{ left: \d+px; right: auto; top: auto; bottom: \d+px;/);
+ // A footage mark carries no measure (its page is what it was).
+ const foot = withGapCue(scheduleOf(manifest({ gapCue: { mark: true } })), { entries: manifest().timeline, render: manifest({ gapCue: { mark: true } }).render, records: new Map([["c01", OLD_RECORD]]) });
+ const fh = gapCueHtml(foot, manifest().render, gapCueWindows(foot)[0], { fonts: FONTS });
+ assert.ok(!fh.includes("gm-line") && !fh.includes("fonts.load"), "no line, no measure");
+});
+
+test("review 1d, 2: a cut record DECIDES -- one with no gaps (a segment cut before its gaps) has no joins to mark; only with no record the play window stands in", () => {
+ const m = manifest({ gapCue: { mark: true } });
+ const { gaps: _g, ...noGaps } = OLD_RECORD;
+ assert.equal(sliceOf(m, new Map([["c01", noGaps]])), null, "no mark where the picture has no join");
+ assert.deepEqual(basisOf(m.timeline[0], m.render, noGaps).gaps, []);
+ assert.equal(basisOf(m.timeline[0], m.render, { version: 1, id: "c01" }), null, "a record that cannot say where it starts: none");
+ assert.equal(sliceOf(m, null).marks.length, 1, "no record at all: the play window's gaps");
+});
+
+test("review 1d, 4: an untitled clip in a two-line deck: the mark on the META line's row, as the page lays it", () => {
+ const m = manifest({ gapCue: { mark: true, place: "deck" }, deck: { subtitle: { lines: 2 } } });
+ m.timeline[0] = { ...m.timeline[0], onscreen: undefined };
+ const sch = scheduleOf(m);
+ const seg = sch.segments[0];
+ assert.equal(seg.title, "", "untitled");
+ assert.equal(seg.subtitleLines?.length, 2, "two lines");
+ const lay = deckLayout(m.render, { tally: tallyOf(sch, m.render), schedule: sch });
+ const u = untitledRows(lay.text);
+ const html = deckHtml(sch, m.render, { fonts: FONTS });
+ const top = Number(/\.seg\.untitled\.two \.sc \{ top: (\d+)px; height: (\d+)px; \}/.exec(html)[1]);
+ assert.equal(top, u.u2Y, "the page's row is untitledRows'");
+ const row = sourceLineRow(lay.text, seg);
+ assert.equal(row.y, u.u2Y + u.u2HeadBox, "the meta line, under the promoted head");
+ assert.equal(row.size, lay.text.subtitleSize);
+ const k = sliceOf(m).marks[0];
+ assert.equal(k.place, "deck");
+ const { deck: band } = deckGeometry(m.render);
+ assert.ok(Math.abs(k.rect.y + k.rect.h / 2 - (band.y + row.y + row.box / 2)) <= 1, `centred on the meta row (${k.rect.y})`);
+ assert.notEqual(row.y, lay.text.subtitleY + lay.text.headBox, "not the titled two-line row (the defect)");
+ // Titled, one line in a two-line deck (an entry's own one-line subtitle): its own row, not the meta's.
+ const one = sourceLineRow(lay.text, { ...seg, title: "A title", subtitleLines: null });
+ assert.equal(one.y, lay.text.subtitleY);
+});
+
+test("review 1d, 5: over the footage the mark keeps off the stats panel and the effects' screenshots while each is up", async () => {
+ const { statsGeometry, fxGeometry } = await import("./deck.mjs");
+ const m = manifest({ gapCue: { mark: true }, chrome: { stats: { position: "bottom-left" } } });
+ const base = scheduleOf(m);
+ const k0 = sliceOf(m).marks[0];
+ assert.equal(k0.corner, "bl");
+ const overlaps = (r, g) => r.x < g.x + g.width && g.x < r.x + r.w && r.y < g.y + g.height && g.y < r.y + r.h;
+ const run = (sched) => gapCueSlice(sched, { entries: m.timeline, render: m.render, records: new Map([["c01", OLD_RECORD]]) }).marks[0];
+ // The stats panel up over the join, bottom left: the mark hops off it.
+ const withStats = { ...base, stats: { clips: [{ segment: "c01", in: k0.at - 1, out: k0.until + 1, name: null, states: [] }] } };
+ const ks = run(withStats);
+ assert.notEqual(ks.corner, "bl");
+ assert.ok(!overlaps(ks.rect, statsGeometry(m.render)), "not over the stats panel");
+ // Up only after the mark is gone: it stays.
+ assert.equal(run({ ...base, stats: { clips: [{ segment: "c01", in: k0.until + 1, out: k0.until + 4 }] } }).corner, "bl");
+ // A zoom's card (centred, up to 84 % of the box tall) and the receipts' fan (their side's column).
+ const box = fxGeometry(m.render);
+ const right = run({ ...base, fx: { receipts: { position: "left", width: 0.36, clips: [{ segment: "c01", in: k0.at - 1, out: k0.until + 1 }] } } });
+ assert.notEqual(right.corner, "bl", "off the receipts' column on the left");
+ assert.ok(right.rect.x > box.x + box.width / 2, "to the right");
+ // The zoom's card at its largest, centred, over its seconds (a corner it covers is hopped off like any other).
+ const zs = { ...base, fx: { zoom: { width: 0.56, clips: [{ segment: "c01", in: 3, out: 9 }] } } };
+ const [z] = moduleAvoids(zs, m.render);
+ assert.deepEqual([z.from, z.to], [3, 9]);
+ assert.ok(z.w >= Math.ceil(0.56 * box.width) && z.h >= Math.ceil(0.84 * box.height), `at its largest (${JSON.stringify(z)})`);
+ assert.ok(Math.abs(z.x + z.w / 2 - (box.x + box.width / 2)) <= 1 && Math.abs(z.y + z.h / 2 - (box.y + box.height / 2)) <= 1, "centred on the box");
+ assert.equal(run(zs).corner, "bl", "a 56 % card leaves the corners free");
+});
+
+test("review 1d, 6: a clip id with '.' or ':' names its marks, its window and its frames", () => {
+ const m = manifest({ gapCue: { mark: true }, timeline: [clip("c.01:a", "synthvid001", 600, { gaps: [{ from: 605, to: 617 }] }), clip("c02", "synthvid002", 1200)] });
+ const sched = withGapCue(scheduleOf(m), { entries: m.timeline, render: m.render, records: new Map([["c.01:a", { ...OLD_RECORD, id: "c.01:a" }]]) });
+ const [w] = gapCueWindows(sched);
+ assert.equal(w.segment, "c.01:a.g0");
+ const snapped = gapCueModule.window(sched, { segment: "c.01:a.g0", fps: 30, total: sched.total });
+ assert.equal(snapped.segment, "c.01:a.g0");
+ assert.equal(gapCueModule.names({ preview: false, window: snapped }).stem, "gap-cue-c.01:a.g0");
+ for (const bad of ["a/b.g0", "a\\b.g0", "a b.g0", "x"]) {
+ assert.throws(() => gapCueModule.window(sched, { window: { segment: bad, from: w.from, to: w.to }, fps: 30, total: sched.total }), /is not a mark id/, bad);
+ }
+});
+
+test("review 1d, 8: a mark is gone before the dissolve into the next segment; a short one rises only as the drawtext's does", () => {
+ // The join 0.5 s before c01's dissolve out begins: its life cut there, its ramps meeting under the peak.
+ const sch0 = scheduleOf(manifest({ gapCue: { mark: true } }));
+ const seg = sch0.segments[0];
+ const D = sch0.transition;
+ const outAt = seg.end - D;
+ const join = outAt - 0.5 - seg.start; // segment seconds
+ const rec = { ...OLD_RECORD, start: 600, end: 600 + seg.duration + 3, gaps: [{ from: 600 + join, to: 600 + join + 3 }] };
+ const m = manifest({ gapCue: { mark: true }, timeline: [clip("c01", "synthvid001", 600, { end: 600 + seg.duration + 3, gaps: [{ from: 600 + join, to: 600 + join + 3 }] }), clip("c02", "synthvid002", 1200)] });
+ const sch = scheduleOf(m);
+ const k = gapCueSlice(sch, { entries: m.timeline, render: m.render, records: new Map([["c01", rec]]) }).marks[0];
+ const end = sch.segments[0].end - sch.transition;
+ assert.ok(k.until <= end + 1e-4, `until ${k.until} <= the dissolve's start ${end}`);
+ assert.ok(k.until - k.at < 1.1 && k.until - k.at >= GAP_CUE_MIN_UP);
+ const sched = withGapCue(sch, { entries: m.timeline, render: m.render, records: new Map([["c01", rec]]) });
+ const data = JSON.parse(/<script id="gap-cue-data" type="application\/json">(.*?)<\/script>/s.exec(gapCueHtml(sched, m.render, gapCueWindows(sched)[0], { fonts: FONTS }))[1]);
+ const len = k.until - k.at;
+ assert.ok(Math.abs(data.cues[0].to.autoAlpha - (0.9 * len) / 0.5) < 1e-3, `peak ${data.cues[0].to.autoAlpha} for a ${len} s mark`);
+ assert.ok(Math.abs(data.cues[1].at + data.cues[1].dur - k.until) < 1e-3, "faded out by its end");
+ // A join inside the last GAP_CUE_MIN_UP before the dissolve: none.
+ const late = outAt - 0.1 - seg.start;
+ const rec2 = { ...rec, gaps: [{ from: 600 + late, to: 600 + late + 3 }] };
+ const m2 = manifest({ gapCue: { mark: true }, timeline: [clip("c01", "synthvid001", 600, { end: 600 + seg.duration + 3, gaps: [{ from: 600 + late, to: 600 + late + 3 }] }), clip("c02", "synthvid002", 1200)] });
+ assert.equal(gapCueSlice(scheduleOf(m2), { entries: m2.timeline, render: m2.render, records: new Map([["c01", rec2]]) }), null);
+ // The LAST segment has no dissolve out: its own end.
+ const lastOnly = manifest({ gapCue: { mark: true }, timeline: [clip("c02", "synthvid002", 1200), clip("c01", "synthvid001", 600, { gaps: [{ from: 605, to: 617 }] })] });
+ const kl = gapCueSlice(scheduleOf(lastOnly), { entries: lastOnly.timeline, render: lastOnly.render, records: new Map([["c01", OLD_RECORD]]) }).marks[0];
+ assert.ok(Math.abs(kl.until - kl.at - 1.1) < 1e-3, "a whole life");
+});
+
+test("review 1d, 10: a windowed take (its timeline the window's entries) and a preview window: the marks on that cut's clock, only the windows it covers", async () => {
+ const { windowEntries } = await import("../lib/report/takeMaker.mjs");
+ const m = manifest({ gapCue: { mark: true }, timeline: [clip("c00", "synthvid002", 1200), clip("c01", "synthvid001", 600, { gaps: [{ from: 605, to: 617 }] }), clip("c02", "synthvid002", 1300)] });
+ const whole = scheduleOf(m, [META(2), META(1), META(2)]);
+ const ids = windowEntries(m.timeline, { at: whole.segments[1].start + 1, dur: 2 }, { render: m.render }).ids;
+ assert.deepEqual(ids, ["c01"]);
+ const take = { ...m, timeline: m.timeline.filter((e) => ids.includes(e.id)) };
+ const ts = scheduleOf(take, [META(1)]);
+ const k = gapCueSlice(ts, { entries: take.timeline, render: take.render, records: new Map([["c01", OLD_RECORD]]) }).marks[0];
+ assert.ok(Math.abs(k.at - (ts.segments[0].start + 5.2)) < 1e-3, "on the take's own clock: its first segment's start");
+ // A preview window of the whole cut: the windows it touches, shifted into its clock.
+ const sched = withGapCue(whole, { entries: m.timeline, render: m.render, records: new Map([["c01", OLD_RECORD]]) });
+ const w = gapCueWindows(sched)[0];
+ const at = w.from - 0.5;
+ const hit = gapCueModule.regions(sched, { render: m.render, outDir: "/o", shift: at, clip: { at, dur: 2 } });
+ assert.equal(hit.length, 1);
+ assert.ok(Math.abs(hit[0].offset - 0.5) < 0.05, `offset ${hit[0].offset} into the window`);
+ assert.deepEqual(gapCueModule.regions(sched, { render: m.render, outDir: "/o", shift: 0, clip: { at: 0, dur: 1 } }), [], "a window before it: none");
+});
diff --git a/umtool/report-to-video/gap-mark-place.mjs b/umtool/report-to-video/gap-mark-place.mjs
@@ -0,0 +1,329 @@
+// WHERE THE GAP MARK STANDS (lane gap-cue): the pure half of gap-mark.mjs --
+// the marks a segment's joins make, their sizes, their corner and the hop off
+// what must stay clear -- with no font file and nothing of node's, so the
+// deck's schedule (deck.mjs, the gap-cue module's slice) and umtool's pages
+// import it as they import gaps.mjs. gap-mark.mjs re-exports it and adds the
+// drawtext that draws a mark into a clip's segment.
+//
+// WHERE. In a box the layout names -- the footage as it plays (the deck's
+// footage box, the plain cut's picture, a vertical cut's picture or crop one
+// inside its safe area) -- at a corner `inset` in from its edges: the
+// layout's own free corner (`auto`: the deck's stamp stands top-left and its
+// posts top-right, so bottom-left; the plain cut's captions sit at its foot
+// and its code at the bottom right, so top-left; a vertical split's captions
+// at its picture's foot, so top-right), or the one `corner` says. A hidden
+// region up while the mark is, or a code, under that corner moves it to the
+// next free one (tl, tr, bl, br); none free, it stays where it was asked. A
+// mark too wide for its box is drawn smaller, then cut ("…"): never off it.
+//
+// PURE: no fs, no ffmpeg run.
+import { GAP_CUE_LOOK, clipGapCueOf, gapCueText, gapCueWanted, gapCues, gapMarkOn, gapOwnSays } from "yt-dlp-transcript-common/lib/report/gapCue.mjs";
+import { offsetIn, renderGaps } from "./gaps.mjs";
+
+/** Plex Mono's advance, in ems: every glyph the same width. */
+const ADVANCE = 0.6;
+
+const EPS = 1e-6;
+
+/**
+ * The mark's sizes for a `W` × `H` frame (GAP_CUE_LOOK): its font size, the
+ * box round the text (`border`, drawtext's boxborderw), the border's stroke,
+ * and the inset from the box it stands in. `look` overrides GAP_CUE_LOOK's
+ * numbers (the operator's stills of the variants).
+ */
+export function gapMarkSize(W, H, look = GAP_CUE_LOOK) {
+ const L = { ...GAP_CUE_LOOK, ...look };
+ const s = Math.min(W, H);
+ const fontSize = Math.max(12, Math.round(s * L.font));
+ return {
+ fontSize,
+ border: Math.round(fontSize * L.pad),
+ stroke: L.stroke > 0 ? Math.max(L.strokeMin, Math.round(s * L.stroke)) : 0,
+ inset: Math.max(8, Math.round(s * L.inset)),
+ };
+}
+
+/** How wide a text draws in Plex Mono at `fontSize` px: every glyph ADVANCE em (the drawtext's face). */
+export const monoWidth = (text, fontSize) => Math.ceil([...String(text)].length * ADVANCE * fontSize);
+
+/**
+ * About how wide a text draws in the deck's bold sans at `fontSize` px -- each character at a bold sans's advance
+ * for its kind, a little over the measured widths (as deck.mjs markerLabelWidth reckons a label), so a mark called
+ * fitting does fit. What the gap-cue module's page (DeckSansBold) is placed and hopped by; the page itself sizes
+ * the element to its text.
+ */
+export function sansWidth(text, fontSize) {
+ let em = 0;
+ for (const ch of String(text)) {
+ if (ch === " ") em += 0.26;
+ else if (/[.,:;'!|’‘·]/.test(ch)) em += 0.3;
+ else if (/[0-9]/.test(ch)) em += 0.58;
+ else if (/[MWmw@&]/.test(ch)) em += 0.88;
+ else if (/[A-Z]/.test(ch)) em += 0.66;
+ else if (/[»«…]/.test(ch)) em += 0.6;
+ else em += 0.56;
+ }
+ return Math.ceil(em * fontSize);
+}
+
+/**
+ * The rect a text of `chars` characters takes with its box and border, at `size` (gapMarkSize) -- `textW` its
+ * text's own width when it is measured otherwise (a proportional face: sansWidth), else the mono advance.
+ */
+export function gapMarkRect(chars, size, textW = null) {
+ const edge = size.border + (size.stroke ?? 0);
+ return { w: (textW ?? Math.ceil(chars * ADVANCE * size.fontSize)) + 2 * edge, h: Math.ceil(size.fontSize * 1.2) + 2 * edge };
+}
+
+/**
+ * A segment's JOINS on its own clock, from the gaps it really left out:
+ * `segGaps` (gaps.mjs gapsOnSegment, seconds from its first frame, before
+ * the gaps are taken out) and the clip's gaps as the render applies them
+ * (`clipGaps`, source seconds -- with their own `mark` -- on the clock
+ * `segStart` is on). `toReal` maps that clock to the recording's (a clip cut
+ * from its pieces), so the seconds a join says are the recording's.
+ *
+ * @param {{ segGaps: Array<{ from: number, to: number }>, clipGaps: Array<{ from: number, to: number, mark?: boolean }>,
+ * segStart: number, cue: { mark: boolean }, toReal?: (t: number) => number }} o
+ * Each join says its reason (gapWhyWord: the clip's gaps it is agreeing, else
+ * none) and its own corner (the first of them that names one), only when it
+ * has them.
+ *
+ * @returns {Array<{ at: number, seconds: number, mark: boolean, why?: string, corner?: string }>}
+ */
+export function segmentGapJoins({ segGaps, clipGaps, segStart, cue, toReal = (t) => t }) {
+ let removed = 0;
+ return (segGaps ?? []).map((g) => {
+ const a = segStart + g.from;
+ const b = segStart + g.to;
+ // The clip's gaps this one is (gapsOnSegment may have joined two that touch on the frame grid).
+ const own = (clipGaps ?? []).filter((c) => c.to > a - 0.05 && c.from < b + 0.05);
+ const join = { at: g.from - removed, seconds: toReal(b) - toReal(a), mark: own.length ? own.some((c) => gapMarkOn(cue, c)) : cue.mark, ...gapOwnSays(own) };
+ removed += g.to - g.from;
+ return join;
+ });
+}
+
+/**
+ * The marks one segment draws: its joins (segmentGapJoins) under the clip's
+ * settings (clipGapCueOf: `min`, and `label` for the text). [] when nothing
+ * is marked -- the segment's graph is then the one it always was.
+ *
+ * @param {{ render: any, entry: any, joins: Array<{ at: number, seconds: number, mark: boolean }>, seconds: number }} o
+ * @returns {Array<{ at: number, until: number, seconds: number, count: number, text: string }>}
+ */
+export function segmentGapMarks({ render, entry, joins, seconds }) {
+ const cue = clipGapCueOf(render, entry);
+ return gapCues(joins, { min: cue.min, seconds }).map((c) => ({ ...c, text: gapCueText(c.seconds, cue.label, c.why) }));
+}
+
+/**
+ * The marks a segment built with cut record `record` (its `start`, `end` and `gaps`: the recording's seconds,
+ * every second left out -- between a clip's pieces too) draws under the settings NOW (`render`, the clip's `entry`):
+ * its joins from the record, as the build takes them for a clip cut from its pieces. [] when nothing is marked.
+ *
+ * @param {{ render: any, entry: any, record: { start?: number, end?: number, gaps?: Array<{ from: number, to: number }> } | null }} o
+ */
+export function recordGapMarks({ render, entry, record }) {
+ const gaps = Array.isArray(record?.gaps) ? record.gaps : [];
+ const start = Number(record?.start);
+ const end = Number(record?.end);
+ if (!gaps.length || !Number.isFinite(start) || !Number.isFinite(end) || !gapCueWanted(render, entry)) return [];
+ const seconds = end - start - gaps.reduce((n, g) => n + (g.to - g.from), 0);
+ return segmentGapMarks({
+ render, entry, seconds,
+ joins: segmentGapJoins({ segGaps: gaps.map((g) => ({ from: g.from - start, to: g.to - start })), clipGaps: renderGaps(entry, render), segStart: start, cue: clipGapCueOf(render, entry) }),
+ });
+}
+
+/**
+ * What the corner a mark ASKS for is (its gap's own, else the clip's; "auto" none): what a record keeps beside
+ * the corner it stood at, so a change of it is seen.
+ *
+ * @param {{ corner?: string }} mark @param {string} want the clip's (clipGapCueOf)
+ */
+export const gapMarkAsked = (mark, want) => (typeof mark.corner === "string" && mark.corner ? mark.corner : want && want !== "auto" ? want : null);
+
+/**
+ * Do a segment's recorded marks (its cut record's `gapMarks`: each `{at, until, seconds, text, corner, asked?}`)
+ * still say what the settings now draw (recordGapMarks)? null when they do, else what changed, in words -- for a
+ * pass that rebuilds no segment (`--chrome-only`), which would otherwise lay the old marks (or none) without a word.
+ * A recorded text cut to fit ("…") agrees with the text it was cut from.
+ *
+ * @param {{ render: any, entry: any, record: any }} o
+ * @returns {string | null}
+ */
+export function gapMarkDrift({ render, entry, record }) {
+ const now = recordGapMarks({ render, entry, record });
+ const was = Array.isArray(record?.gapMarks) ? record.gapMarks : [];
+ if (!now.length && !was.length) return null;
+ if (!was.length) return `${now.length} mark${now.length === 1 ? "" : "s"} to draw, none drawn`;
+ if (!now.length) return `its ${was.length} mark${was.length === 1 ? "" : "s"} no longer wanted`;
+ if (now.length !== was.length) return `${was.length} mark${was.length === 1 ? "" : "s"} drawn, ${now.length} now`;
+ const want = clipGapCueOf(render, entry).corner;
+ const sameText = (drawn, says) => drawn === says || (typeof drawn === "string" && drawn.endsWith("…") && says.startsWith(drawn.slice(0, -1).trimEnd()));
+ for (const [k, m] of now.entries()) {
+ const w = was[k];
+ if (Math.abs(m.at - Number(w?.at)) > 0.01 || Math.abs(m.until - Number(w?.until)) > 0.01) return `the mark at ${m.at} s moved`;
+ if (!sameText(w?.text, m.text)) return `"${w?.text}" now says "${m.text}"`;
+ if ((w?.asked ?? null) !== gapMarkAsked(m, want)) return `the mark at ${m.at} s asks for another corner`;
+ }
+ return null;
+}
+
+const CORNERS = ["tl", "tr", "bl", "br"];
+
+/**
+ * A rect on `box`'s corner `c`, `inset` in.
+ *
+ * @param {{ x: number, y: number, w: number, h: number }} box
+ * @param {string} c
+ * @param {{ w: number, h: number }} r
+ * @param {number} inset
+ */
+function cornerRect(box, c, r, inset) {
+ const x = c.endsWith("l") ? box.x + inset : box.x + box.w - inset - r.w;
+ const y = c.startsWith("t") ? box.y + inset : box.y + box.h - inset - r.h;
+ // Never out of its box: a mark wider (or taller) than the box less its insets stands at the box's own edge.
+ const cx = Math.max(box.x, Math.min(x, box.x + box.w - r.w));
+ const cy = Math.max(box.y, Math.min(y, box.y + box.h - r.h));
+ return { x: Math.round(cx), y: Math.round(cy), w: r.w, h: r.h };
+}
+
+/** The smallest a mark's face is shrunk to, to fit its box (of its size): past it, its text is cut. */
+export const GAP_MARK_FIT_MIN = 0.75;
+
+/**
+ * A mark's text and size to fit `maxW` px (its box less its insets): as it is when it fits; else its face shrunk,
+ * to GAP_MARK_FIT_MIN of its size at most (the box and border with it); still too wide, cut to what fits, ending
+ * "…". A long label and a long reason on a 1080-wide vertical frame (64 characters, about 1230 px at 32 px).
+ *
+ * @param {string} text
+ * @param {ReturnType<typeof gapMarkSize>} size
+ * @param {number} maxW
+ * @param {(text: string, fontSize: number) => number} [measure] the face's width (monoWidth: the drawtext's)
+ * @returns {{ text: string, size: ReturnType<typeof gapMarkSize> }}
+ */
+export function gapMarkFit(text, size, maxW, measure = monoWidth) {
+ const chars = [...text];
+ const rectAt = (t, s) => gapMarkRect([...t].length, s, measure(t, s.fontSize));
+ if (rectAt(text, size).w <= maxW) return { text, size };
+ const pad = size.fontSize > 0 ? size.border / size.fontSize : 0;
+ const at = (fontSize) => ({ ...size, fontSize, border: Math.round(fontSize * pad) });
+ const floor = Math.max(12, Math.ceil(size.fontSize * GAP_MARK_FIT_MIN));
+ for (let f = size.fontSize - 1; f >= floor; f -= 1) {
+ if (rectAt(text, at(f)).w <= maxW) return { text, size: at(f) };
+ }
+ const s = at(Math.min(floor, size.fontSize));
+ if (measure !== monoWidth) {
+ // A proportional face: the longest head that fits with its "…".
+ for (let n = chars.length - 1; n >= 1; n -= 1) {
+ const t = `${chars.slice(0, n).join("").trimEnd()}…`;
+ if (rectAt(t, s).w <= maxW) return { text: t, size: s };
+ }
+ return { text: "…", size: s };
+ }
+ const edge = s.border + (s.stroke ?? 0);
+ const n = Math.max(1, Math.floor((maxW - 2 * edge) / (ADVANCE * s.fontSize)));
+ return { text: n >= chars.length ? text : `${chars.slice(0, Math.max(0, n - 1)).join("").trimEnd()}…`, size: s };
+}
+
+const overlaps = (a, b) => a.x < b.x + b.w && b.x < a.x + a.w && a.y < b.y + b.h && b.y < a.y + a.h;
+
+/**
+ * The corner each mark stands at: `want` (the clip's `corner`; `auto` is the
+ * layout's `prefer`), else -- when something to keep clear of (`avoid`: rects
+ * in the frame, each over `from`–`to` segment seconds, or always) is under
+ * it while the mark is up -- the next free one in tl, tr, bl, br; none free,
+ * `want`'s. A corner in `busy` (a code the layout draws there) is never free.
+ *
+ * @param {{ marks: Array<{ at: number, until: number, text: string, corner?: string }>, box: { x: number, y: number, w: number, h: number },
+ * want: string, prefer: string, size: ReturnType<typeof gapMarkSize>,
+ * avoid?: Array<{ x: number, y: number, w: number, h: number, from?: number | null, to?: number | null }>, busy?: string[],
+ * measure?: (text: string, fontSize: number) => number }} o
+ * Each place carries the mark's `text` and `size` as fitted to the box
+ * (gapMarkFit): what is drawn, and what the record says.
+ *
+ * @returns {Array<{ corner: string, rect: { x: number, y: number, w: number, h: number }, text: string, size: ReturnType<typeof gapMarkSize> }>}
+ */
+export function gapMarkPlaces({ marks, box, want, prefer, size, avoid = [], busy = [], measure = monoWidth }) {
+ return marks.map((m) => {
+ // A mark's own corner (its gap's `corner`) over the clip's.
+ const asked = typeof m.corner === "string" && CORNERS.includes(m.corner) ? m.corner : want;
+ const first = asked === "auto" || !CORNERS.includes(asked) ? prefer : asked;
+ const order = [first, ...CORNERS.filter((c) => c !== first)];
+ // Fitted to its box (gapMarkFit): never wider than the box less its insets.
+ const fit = gapMarkFit(m.text, size, box.w - 2 * size.inset, measure);
+ const r = gapMarkRect([...fit.text].length, fit.size, measure(fit.text, fit.size.fontSize));
+ const up = avoid.filter((a) => (a.from ?? -Infinity) < m.until - EPS && (a.to ?? Infinity) > m.at + EPS);
+ for (const c of order) {
+ if (busy.includes(c)) continue;
+ const rect = cornerRect(box, c, r, size.inset);
+ if (!up.some((a) => overlaps(rect, a))) return { corner: c, rect, text: fit.text, size: fit.size };
+ }
+ return { corner: first, rect: cornerRect(box, first, r, size.inset), text: fit.text, size: fit.size };
+ });
+}
+
+/**
+ * A picture's hidden regions (clip-censor.mjs censorRegionsOf: fractions of
+ * the SOURCE picture, source seconds) as rects in the frame to keep the mark
+ * off, over their seconds on the segment's clock: the source picture `sw` ×
+ * `sh`, its part `region` (source px; the whole of it when fitted) shown in
+ * `dest` (frame px). `from` / `gaps` / `seconds` as censorParts reads them.
+ */
+export function censorAvoidRects(regions, { sw, sh, region = null, dest, from = 0, gaps = [], seconds = Infinity }) {
+ const src = region ?? { x: 0, y: 0, w: sw, h: sh };
+ return (regions ?? []).map((g) => {
+ const [bx, by, bw, bh] = g.box;
+ const x0 = dest.x + ((bx * sw - src.x) / src.w) * dest.w;
+ const y0 = dest.y + ((by * sh - src.y) / src.h) * dest.h;
+ const x1 = dest.x + (((bx + bw) * sw - src.x) / src.w) * dest.w;
+ const y1 = dest.y + (((by + bh) * sh - src.y) / src.h) * dest.h;
+ return {
+ x: Math.floor(x0), y: Math.floor(y0), w: Math.ceil(x1 - x0), h: Math.ceil(y1 - y0),
+ from: g.from === null || g.from === undefined ? null : Math.max(0, offsetIn(g.from, from, gaps)),
+ to: g.to === null || g.to === undefined ? null : Math.min(seconds, offsetIn(g.to, from, gaps)),
+ };
+ });
+}
+
+/** The part of rect `a` inside rect `b` (each `{x, y, w, h}`): a mark's box kept inside a safe area. Empty: `b`. */
+export function insideRect(a, b) {
+ const x0 = Math.max(a.x, b.x);
+ const y0 = Math.max(a.y, b.y);
+ const x1 = Math.min(a.x + a.w, b.x + b.w);
+ const y1 = Math.min(a.y + a.h, b.y + b.h);
+ return x1 > x0 && y1 > y0 ? { x: x0, y: y0, w: x1 - x0, h: y1 - y0 } : { ...b };
+}
+
+const rectOf = (b) => ({ x: b.x, y: b.y, w: b.w ?? b.width, h: b.h ?? b.height });
+const safeRect = (a) => ({ x: a.x0, y: a.y0, w: a.x1 - a.x0, h: a.y1 - a.y0 });
+
+/**
+ * Where a vertical clip's mark stands (vertical.mjs clipGeometry / desktopGeometry `geo`, its safe area `safe`
+ * `{x0, y0, x1, y1}`): always inside the safe area -- the platform draws its own buttons and bands outside it. A
+ * framed or quote layout's picture's top left (a framed picture's hook stands above it; a quote has no tag); a
+ * split's picture's top right (its tag is top left, its captions at the picture's foot, the side post under it);
+ * a full-bleed (full, overlay) or desktop clip's safe area's top right (the tag and the hook are at its left).
+ *
+ * @param {{ layout: string, video: { x: number, y: number, w?: number, h?: number, width?: number, height?: number } }} geo
+ * @param {{ x0: number, y0: number, x1: number, y1: number }} safe
+ * @returns {{ box: { x: number, y: number, w: number, h: number }, prefer: "tl" | "tr" }}
+ */
+export function verticalMarkBox(geo, safe) {
+ const fullBleed = !["framed", "quote", "split"].includes(geo.layout);
+ return { box: fullBleed ? safeRect(safe) : insideRect(rectOf(geo.video), safeRect(safe)), prefer: fullBleed || geo.layout === "split" ? "tr" : "tl" };
+}
+
+/**
+ * Where a twocrop clip's mark stands in the stacked deck (vertical-deck.mjs stackedGeometry `g`): crop one's top
+ * right, inside the safe area (the source line and the rail stand above crop one, the strip under it).
+ *
+ * @param {{ safe: { x0: number, y0: number, x1: number, y1: number }, twocrop: { crop1: { x: number, y: number, width: number, height: number } } }} g
+ */
+export const twoCropMarkBox = (g) => ({ box: insideRect(rectOf(g.twocrop.crop1), safeRect(g.safe)), prefer: /** @type {const} */ ("tr") });
+
+/** A fitted picture's rect in a box (force_original_aspect_ratio=decrease, centred): `fitted` is its size. */
+export const centredIn = (box, fitted) => ({ x: box.x + Math.floor((box.w - fitted.w) / 2), y: box.y + Math.floor((box.h - fitted.h) / 2), w: fitted.w, h: fitted.h });
+
diff --git a/umtool/report-to-video/gap-mark.mjs b/umtool/report-to-video/gap-mark.mjs
@@ -27,281 +27,41 @@
// the border's colour and wider by the stroke. No sound.
//
// PURE: no fs, no ffmpeg run. The build writes each mark's text file.
-import { GAP_CUE_LOOK, GAP_CUE_MOTION, clipGapCueOf, gapCueText, gapCueWanted, gapCues, gapMarkOn, gapOwnSays } from "yt-dlp-transcript-common/lib/report/gapCue.mjs";
+import { GAP_CUE_LOOK, GAP_CUE_MOTION } from "yt-dlp-transcript-common/lib/report/gapCue.mjs";
import { MONO_BOLD_FONT_FILE } from "./brand.mjs";
-import { offsetIn, renderGaps } from "./gaps.mjs";
+import { deckOn } from "./deck.mjs";
-/** Plex Mono's advance, in ems: every glyph the same width. */
-const ADVANCE = 0.6;
+// The placement, the marks and their records: pure, in gap-mark-place.mjs (the deck's schedule reads them too).
+export * from "./gap-mark-place.mjs";
-const EPS = 1e-6;
const f3 = (n) => Number(n.toFixed(3)).toString();
/**
- * The mark's sizes for a `W` × `H` frame (GAP_CUE_LOOK): its font size, the
- * box round the text (`border`, drawtext's boxborderw), the border's stroke,
- * and the inset from the box it stands in. `look` overrides GAP_CUE_LOOK's
- * numbers (the operator's stills of the variants).
- */
-export function gapMarkSize(W, H, look = GAP_CUE_LOOK) {
- const L = { ...GAP_CUE_LOOK, ...look };
- const s = Math.min(W, H);
- const fontSize = Math.max(12, Math.round(s * L.font));
- return {
- fontSize,
- border: Math.round(fontSize * L.pad),
- stroke: L.stroke > 0 ? Math.max(L.strokeMin, Math.round(s * L.stroke)) : 0,
- inset: Math.max(8, Math.round(s * L.inset)),
- };
-}
-
-/** The rect a text of `chars` characters takes with its box and border, at `size` (gapMarkSize). */
-export function gapMarkRect(chars, size) {
- const edge = size.border + (size.stroke ?? 0);
- return { w: Math.ceil(chars * ADVANCE * size.fontSize) + 2 * edge, h: Math.ceil(size.fontSize * 1.2) + 2 * edge };
-}
-
-/**
- * A segment's JOINS on its own clock, from the gaps it really left out:
- * `segGaps` (gaps.mjs gapsOnSegment, seconds from its first frame, before
- * the gaps are taken out) and the clip's gaps as the render applies them
- * (`clipGaps`, source seconds -- with their own `mark` -- on the clock
- * `segStart` is on). `toReal` maps that clock to the recording's (a clip cut
- * from its pieces), so the seconds a join says are the recording's.
- *
- * @param {{ segGaps: Array<{ from: number, to: number }>, clipGaps: Array<{ from: number, to: number, mark?: boolean }>,
- * segStart: number, cue: { mark: boolean }, toReal?: (t: number) => number }} o
- * Each join says its reason (gapWhyWord: the clip's gaps it is agreeing, else
- * none) and its own corner (the first of them that names one), only when it
- * has them.
- *
- * @returns {Array<{ at: number, seconds: number, mark: boolean, why?: string, corner?: string }>}
- */
-export function segmentGapJoins({ segGaps, clipGaps, segStart, cue, toReal = (t) => t }) {
- let removed = 0;
- return (segGaps ?? []).map((g) => {
- const a = segStart + g.from;
- const b = segStart + g.to;
- // The clip's gaps this one is (gapsOnSegment may have joined two that touch on the frame grid).
- const own = (clipGaps ?? []).filter((c) => c.to > a - 0.05 && c.from < b + 0.05);
- const join = { at: g.from - removed, seconds: toReal(b) - toReal(a), mark: own.length ? own.some((c) => gapMarkOn(cue, c)) : cue.mark, ...gapOwnSays(own) };
- removed += g.to - g.from;
- return join;
- });
-}
-
-/**
- * The marks one segment draws: its joins (segmentGapJoins) under the clip's
- * settings (clipGapCueOf: `min`, and `label` for the text). [] when nothing
- * is marked -- the segment's graph is then the one it always was.
- *
- * @param {{ render: any, entry: any, joins: Array<{ at: number, seconds: number, mark: boolean }>, seconds: number }} o
- * @returns {Array<{ at: number, until: number, seconds: number, count: number, text: string }>}
- */
-export function segmentGapMarks({ render, entry, joins, seconds }) {
- const cue = clipGapCueOf(render, entry);
- return gapCues(joins, { min: cue.min, seconds }).map((c) => ({ ...c, text: gapCueText(c.seconds, cue.label, c.why) }));
-}
-
-/**
- * The marks a segment built with cut record `record` (its `start`, `end` and `gaps`: the recording's seconds,
- * every second left out -- between a clip's pieces too) draws under the settings NOW (`render`, the clip's `entry`):
- * its joins from the record, as the build takes them for a clip cut from its pieces. [] when nothing is marked.
- *
- * @param {{ render: any, entry: any, record: { start?: number, end?: number, gaps?: Array<{ from: number, to: number }> } | null }} o
- */
-export function recordGapMarks({ render, entry, record }) {
- const gaps = Array.isArray(record?.gaps) ? record.gaps : [];
- const start = Number(record?.start);
- const end = Number(record?.end);
- if (!gaps.length || !Number.isFinite(start) || !Number.isFinite(end) || !gapCueWanted(render, entry)) return [];
- const seconds = end - start - gaps.reduce((n, g) => n + (g.to - g.from), 0);
- return segmentGapMarks({
- render, entry, seconds,
- joins: segmentGapJoins({ segGaps: gaps.map((g) => ({ from: g.from - start, to: g.to - start })), clipGaps: renderGaps(entry, render), segStart: start, cue: clipGapCueOf(render, entry) }),
- });
-}
-
-/**
- * What the corner a mark ASKS for is (its gap's own, else the clip's; "auto" none): what a record keeps beside
- * the corner it stood at, so a change of it is seen.
+ * WHO DRAWS THE MARK (lane gap-cue, slice 1d), one predicate for the build: the gap-cue MODULE -- a HyperFrames
+ * page per mark, laid by the chrome over the cut -- wherever a deck is drawn over the picture (`render.chrome`:
+ * the HyperFrames deck, landscape, the feed, or the stacked vertical deck, twocrop clips too), and the build lays
+ * its chrome (not `--no-chrome`). Everywhere else the DRAWTEXT into the clip's segment: no `render.chrome` (the
+ * plain letterbox cut), `--no-chrome`, a bare vertical cut, `--desktop`, `--short` (their renders carry no deck).
+ * Never both on one frame: with the module, a segment draws no mark (its argv and record are the plain ones).
*
- * @param {{ corner?: string }} mark @param {string} want the clip's (clipGapCueOf)
+ * @param {any} render the build's render (a short's, a desktop's, a vertical's: as transformed)
+ * @param {{ noChrome?: boolean }} [opts]
*/
-export const gapMarkAsked = (mark, want) => (typeof mark.corner === "string" && mark.corner ? mark.corner : want && want !== "auto" ? want : null);
+export const gapMarkByChrome = (render, opts = {}) => deckOn(render) && !opts.noChrome;
/**
- * Do a segment's recorded marks (its cut record's `gapMarks`: each `{at, until, seconds, text, corner, asked?}`)
- * still say what the settings now draw (recordGapMarks)? null when they do, else what changed, in words -- for a
- * pass that rebuilds no segment (`--chrome-only`), which would otherwise lay the old marks (or none) without a word.
- * A recorded text cut to fit ("…") agrees with the text it was cut from.
+ * Why a build draws its marks into the segments (gapMarkByChrome false), in words for its note.
*
- * @param {{ render: any, entry: any, record: any }} o
- * @returns {string | null}
+ * @param {any} render @param {{ noChrome?: boolean, short?: unknown, desktop?: unknown, vertical?: unknown }} [opts]
*/
-export function gapMarkDrift({ render, entry, record }) {
- const now = recordGapMarks({ render, entry, record });
- const was = Array.isArray(record?.gapMarks) ? record.gapMarks : [];
- if (!now.length && !was.length) return null;
- if (!was.length) return `${now.length} mark${now.length === 1 ? "" : "s"} to draw, none drawn`;
- if (!now.length) return `its ${was.length} mark${was.length === 1 ? "" : "s"} no longer wanted`;
- if (now.length !== was.length) return `${was.length} mark${was.length === 1 ? "" : "s"} drawn, ${now.length} now`;
- const want = clipGapCueOf(render, entry).corner;
- const sameText = (drawn, says) => drawn === says || (typeof drawn === "string" && drawn.endsWith("…") && says.startsWith(drawn.slice(0, -1).trimEnd()));
- for (const [k, m] of now.entries()) {
- const w = was[k];
- if (Math.abs(m.at - Number(w?.at)) > 0.01 || Math.abs(m.until - Number(w?.until)) > 0.01) return `the mark at ${m.at} s moved`;
- if (!sameText(w?.text, m.text)) return `"${w?.text}" now says "${m.text}"`;
- if ((w?.asked ?? null) !== gapMarkAsked(m, want)) return `the mark at ${m.at} s asks for another corner`;
- }
- return null;
+export function gapMarkDrawtextWhy(render, opts = {}) {
+ if (opts.short) return "--short";
+ if (opts.desktop) return "--desktop";
+ if (deckOn(render) && opts.noChrome) return "--no-chrome";
+ if (render?.format === "vertical") return "a bare vertical cut";
+ return "no deck (render.chrome)";
}
-const CORNERS = ["tl", "tr", "bl", "br"];
-
-/**
- * A rect on `box`'s corner `c`, `inset` in.
- *
- * @param {{ x: number, y: number, w: number, h: number }} box
- * @param {string} c
- * @param {{ w: number, h: number }} r
- * @param {number} inset
- */
-function cornerRect(box, c, r, inset) {
- const x = c.endsWith("l") ? box.x + inset : box.x + box.w - inset - r.w;
- const y = c.startsWith("t") ? box.y + inset : box.y + box.h - inset - r.h;
- // Never out of its box: a mark wider (or taller) than the box less its insets stands at the box's own edge.
- const cx = Math.max(box.x, Math.min(x, box.x + box.w - r.w));
- const cy = Math.max(box.y, Math.min(y, box.y + box.h - r.h));
- return { x: Math.round(cx), y: Math.round(cy), w: r.w, h: r.h };
-}
-
-/** The smallest a mark's face is shrunk to, to fit its box (of its size): past it, its text is cut. */
-export const GAP_MARK_FIT_MIN = 0.75;
-
-/**
- * A mark's text and size to fit `maxW` px (its box less its insets): as it is when it fits; else its face shrunk,
- * to GAP_MARK_FIT_MIN of its size at most (the box and border with it); still too wide, cut to what fits, ending
- * "…". A long label and a long reason on a 1080-wide vertical frame (64 characters, about 1230 px at 32 px).
- *
- * @param {string} text
- * @param {ReturnType<typeof gapMarkSize>} size
- * @param {number} maxW
- * @returns {{ text: string, size: ReturnType<typeof gapMarkSize> }}
- */
-export function gapMarkFit(text, size, maxW) {
- const chars = [...text];
- if (gapMarkRect(chars.length, size).w <= maxW) return { text, size };
- const pad = size.fontSize > 0 ? size.border / size.fontSize : 0;
- const at = (fontSize) => ({ ...size, fontSize, border: Math.round(fontSize * pad) });
- const floor = Math.max(12, Math.ceil(size.fontSize * GAP_MARK_FIT_MIN));
- for (let f = size.fontSize - 1; f >= floor; f -= 1) {
- if (gapMarkRect(chars.length, at(f)).w <= maxW) return { text, size: at(f) };
- }
- const s = at(Math.min(floor, size.fontSize));
- const edge = s.border + (s.stroke ?? 0);
- const n = Math.max(1, Math.floor((maxW - 2 * edge) / (ADVANCE * s.fontSize)));
- return { text: n >= chars.length ? text : `${chars.slice(0, Math.max(0, n - 1)).join("").trimEnd()}…`, size: s };
-}
-
-const overlaps = (a, b) => a.x < b.x + b.w && b.x < a.x + a.w && a.y < b.y + b.h && b.y < a.y + a.h;
-
-/**
- * The corner each mark stands at: `want` (the clip's `corner`; `auto` is the
- * layout's `prefer`), else -- when something to keep clear of (`avoid`: rects
- * in the frame, each over `from`–`to` segment seconds, or always) is under
- * it while the mark is up -- the next free one in tl, tr, bl, br; none free,
- * `want`'s. A corner in `busy` (a code the layout draws there) is never free.
- *
- * @param {{ marks: Array<{ at: number, until: number, text: string, corner?: string }>, box: { x: number, y: number, w: number, h: number },
- * want: string, prefer: string, size: ReturnType<typeof gapMarkSize>,
- * avoid?: Array<{ x: number, y: number, w: number, h: number, from?: number | null, to?: number | null }>, busy?: string[] }} o
- * Each place carries the mark's `text` and `size` as fitted to the box
- * (gapMarkFit): what is drawn, and what the record says.
- *
- * @returns {Array<{ corner: string, rect: { x: number, y: number, w: number, h: number }, text: string, size: ReturnType<typeof gapMarkSize> }>}
- */
-export function gapMarkPlaces({ marks, box, want, prefer, size, avoid = [], busy = [] }) {
- return marks.map((m) => {
- // A mark's own corner (its gap's `corner`) over the clip's.
- const asked = typeof m.corner === "string" && CORNERS.includes(m.corner) ? m.corner : want;
- const first = asked === "auto" || !CORNERS.includes(asked) ? prefer : asked;
- const order = [first, ...CORNERS.filter((c) => c !== first)];
- // Fitted to its box (gapMarkFit): never wider than the box less its insets.
- const fit = gapMarkFit(m.text, size, box.w - 2 * size.inset);
- const r = gapMarkRect([...fit.text].length, fit.size);
- const up = avoid.filter((a) => (a.from ?? -Infinity) < m.until - EPS && (a.to ?? Infinity) > m.at + EPS);
- for (const c of order) {
- if (busy.includes(c)) continue;
- const rect = cornerRect(box, c, r, size.inset);
- if (!up.some((a) => overlaps(rect, a))) return { corner: c, rect, text: fit.text, size: fit.size };
- }
- return { corner: first, rect: cornerRect(box, first, r, size.inset), text: fit.text, size: fit.size };
- });
-}
-
-/**
- * A picture's hidden regions (clip-censor.mjs censorRegionsOf: fractions of
- * the SOURCE picture, source seconds) as rects in the frame to keep the mark
- * off, over their seconds on the segment's clock: the source picture `sw` ×
- * `sh`, its part `region` (source px; the whole of it when fitted) shown in
- * `dest` (frame px). `from` / `gaps` / `seconds` as censorParts reads them.
- */
-export function censorAvoidRects(regions, { sw, sh, region = null, dest, from = 0, gaps = [], seconds = Infinity }) {
- const src = region ?? { x: 0, y: 0, w: sw, h: sh };
- return (regions ?? []).map((g) => {
- const [bx, by, bw, bh] = g.box;
- const x0 = dest.x + ((bx * sw - src.x) / src.w) * dest.w;
- const y0 = dest.y + ((by * sh - src.y) / src.h) * dest.h;
- const x1 = dest.x + (((bx + bw) * sw - src.x) / src.w) * dest.w;
- const y1 = dest.y + (((by + bh) * sh - src.y) / src.h) * dest.h;
- return {
- x: Math.floor(x0), y: Math.floor(y0), w: Math.ceil(x1 - x0), h: Math.ceil(y1 - y0),
- from: g.from === null || g.from === undefined ? null : Math.max(0, offsetIn(g.from, from, gaps)),
- to: g.to === null || g.to === undefined ? null : Math.min(seconds, offsetIn(g.to, from, gaps)),
- };
- });
-}
-
-/** The part of rect `a` inside rect `b` (each `{x, y, w, h}`): a mark's box kept inside a safe area. Empty: `b`. */
-export function insideRect(a, b) {
- const x0 = Math.max(a.x, b.x);
- const y0 = Math.max(a.y, b.y);
- const x1 = Math.min(a.x + a.w, b.x + b.w);
- const y1 = Math.min(a.y + a.h, b.y + b.h);
- return x1 > x0 && y1 > y0 ? { x: x0, y: y0, w: x1 - x0, h: y1 - y0 } : { ...b };
-}
-
-const rectOf = (b) => ({ x: b.x, y: b.y, w: b.w ?? b.width, h: b.h ?? b.height });
-const safeRect = (a) => ({ x: a.x0, y: a.y0, w: a.x1 - a.x0, h: a.y1 - a.y0 });
-
-/**
- * Where a vertical clip's mark stands (vertical.mjs clipGeometry / desktopGeometry `geo`, its safe area `safe`
- * `{x0, y0, x1, y1}`): always inside the safe area -- the platform draws its own buttons and bands outside it. A
- * framed or quote layout's picture's top left (a framed picture's hook stands above it; a quote has no tag); a
- * split's picture's top right (its tag is top left, its captions at the picture's foot, the side post under it);
- * a full-bleed (full, overlay) or desktop clip's safe area's top right (the tag and the hook are at its left).
- *
- * @param {{ layout: string, video: { x: number, y: number, w?: number, h?: number, width?: number, height?: number } }} geo
- * @param {{ x0: number, y0: number, x1: number, y1: number }} safe
- * @returns {{ box: { x: number, y: number, w: number, h: number }, prefer: "tl" | "tr" }}
- */
-export function verticalMarkBox(geo, safe) {
- const fullBleed = !["framed", "quote", "split"].includes(geo.layout);
- return { box: fullBleed ? safeRect(safe) : insideRect(rectOf(geo.video), safeRect(safe)), prefer: fullBleed || geo.layout === "split" ? "tr" : "tl" };
-}
-
-/**
- * Where a twocrop clip's mark stands in the stacked deck (vertical-deck.mjs stackedGeometry `g`): crop one's top
- * right, inside the safe area (the source line and the rail stand above crop one, the strip under it).
- *
- * @param {{ safe: { x0: number, y0: number, x1: number, y1: number }, twocrop: { crop1: { x: number, y: number, width: number, height: number } } }} g
- */
-export const twoCropMarkBox = (g) => ({ box: insideRect(rectOf(g.twocrop.crop1), safeRect(g.safe)), prefer: /** @type {const} */ ("tr") });
-
-/** A fitted picture's rect in a box (force_original_aspect_ratio=decrease, centred): `fitted` is its size. */
-export const centredIn = (box, fitted) => ({ x: box.x + Math.floor((box.w - fitted.w) / 2), y: box.y + Math.floor((box.h - fitted.h) / 2), w: fitted.w, h: fitted.h });
-
/**
* The drawtext filters for the marks (`marks` with their `places`), each text
* read from `files[k]` (written by the caller -- `places[k].text`, the mark's
diff --git a/umtool/report-to-video/gaps-render.test.mjs b/umtool/report-to-video/gaps-render.test.mjs
@@ -258,6 +258,10 @@ test("the gap mark draws a reason as written: a % and a backslash are words, the
// The deck (its footage framed for the chrome), a bare vertical cut (full), and the stacked vertical deck's
// twocrop: each built with a gap, then with render.gapCue mark false (and a clip's gapCue saying nothing new),
// then with the mark on and off again -- off, the same key and the same bytes as with nothing set.
+// SLICE 1d: under a deck (the deck, the stacked deck's twocrop) the mark is the gap-cue module's pages, so ON the
+// segment is STILL the plain one -- reused, the same key and bytes, no gapMarks -- and the schedule's slice
+// (gap-cue-slice.mjs) carries the mark from that very record; `--no-chrome` draws it into the segment instead,
+// and then the slice leaves the clip out (never both on one frame). A bare vertical cut draws it into the segment.
const { verticalRender } = await import("./vertical.mjs");
const LAYOUTS = {
@@ -303,16 +307,58 @@ for (const [name, L] of Object.entries(LAYOUTS)) {
assert.equal(b.md5, plain.md5);
}
await setManifest(p, (m) => { m.render.gapCue = { mark: true }; delete m.timeline[0].gapCue; });
+ const { gapCueSlice } = await import("./gap-cue-slice.mjs");
+ const sliceOf = async (rec) => {
+ const m = JSON.parse(await readFile(p.manifestPath, "utf8"));
+ const R = name === "twocrop" ? verticalRender(m.render) : m.render;
+ const sched = { segments: [{ id: "c1", type: "clip", start: 10, duration: 2, end: 12, title: "", subtitle: "" }] };
+ return gapCueSlice(sched, { entries: m.timeline, render: R, records: new Map([["c1", rec]]) });
+ };
+ if (name !== "vertical") {
+ // Under a deck: the plain segment, reused; the mark on the schedule from its record, at the cut's second.
+ const on = await build();
+ assert.ok(on.reused, `${name}: reused with the mark on (the module draws it)`);
+ assert.equal(on.rec.segKey, plain.rec.segKey, `${name}: the same key with the mark on`);
+ assert.equal(on.md5, plain.md5, `${name}: the same bytes with the mark on`);
+ assert.equal(on.rec.gapMarks, undefined, `${name}: nothing drawn into the segment`);
+ assert.ok(events.some((e) => e.ev === "note" && e.message === "gap mark: drawn by the gap-cue page (chrome)"), `${name}: the build says who draws it`);
+ const slice = await sliceOf(on.rec);
+ assert.equal(slice.marks.length, 1);
+ assert.equal(slice.marks[0].text, "» 3 s · idle");
+ near(slice.marks[0].at, 10 + 2.5 - on.rec.start, 0.01, "on the cut's clock: the segment's start plus the join");
+ assert.equal(slice.marks[0].place, "footage");
+ assert.equal(slice.marks[0].corner, name === "twocrop" ? "tr" : "bl");
+ if (name === "twocrop") {
+ await setManifest(p, (m) => { delete m.render.gapCue; });
+ return;
+ }
+ // --no-chrome: drawn into the segment; the slice then leaves the clip out (inSegment).
+ events.length = 0;
+ setProgressMode((e) => events.push(e));
+ const r = await buildVideo({ manifestPath: p.manifestPath, only: "c1", opts: { noNetwork: true, noChrome: true } });
+ assert.equal(r.failures.length, 0, JSON.stringify(r.failures));
+ assert.ok(events.some((e) => e.ev === "note" && e.message === "gap mark: drawn into the clip segments (no chrome for the picture: --no-chrome)"));
+ const seg = await segOf();
+ const nc = JSON.parse(await readFile(seg.replace(/\.mp4$/, ".cut.json"), "utf8"));
+ assert.equal(nc.gapMarks?.length, 1, "--no-chrome draws it into the segment");
+ assert.equal(nc.gapMarks[0].corner, "bl");
+ const left = await sliceOf(nc);
+ assert.deepEqual(left, { marks: [], inSegment: ["c1"] }, "the chrome leaves a clip whose segment drew its marks");
+ await setManifest(p, (m) => { delete m.render.gapCue; });
+ const back = await build();
+ assert.equal(back.rec.segKey, plain.rec.segKey, `${name}: off again, the plain key`);
+ assert.equal(back.md5, plain.md5, `${name}: off again, the plain bytes`);
+ return;
+ }
const on = await build();
assert.ok(!on.reused, `${name}: rebuilt with the mark on`);
assert.notEqual(on.rec.segKey, plain.rec.segKey);
assert.equal(on.rec.gapMarks?.length, 1);
assert.equal(on.rec.gapMarks[0].text, "» 3 s · idle");
- // Drawn by that layout's path, where it puts it (gap-mark.mjs verticalMarkBox, twoCropMarkBox).
+ // Drawn by that layout's path, where it puts it (gap-mark.mjs verticalMarkBox).
const { rect, corner } = on.rec.gapMarks[0];
- if (name === "deck") assert.equal(corner, "bl");
- else {
- assert.equal(on.rec.vertical?.layout, name === "twocrop" ? "twocrop" : "full");
+ {
+ assert.equal(on.rec.vertical?.layout, "full");
assert.equal(corner, "tr");
const { safeArea } = await import("./vertical.mjs");
const a = safeArea(verticalRender(L.render), 1080, 1920);
diff --git a/umtool/report-to-video/modules/config-loader.test.mjs b/umtool/report-to-video/modules/config-loader.test.mjs
@@ -174,14 +174,14 @@ test("the panel: a module's fields from its descriptor, a save as the writers ta
assert.deepEqual(setPath({ a: { b: 1 } }, "a.b", null), {});
});
-test("the panel: the gap mark (an input module, a look key the writer merges) is listed, and a field cleared is sent as null", async () => {
+test("the panel: the gap mark (a window module of its own, a look key the writer merges) is listed, and a field cleared is sent as null", async () => {
const { applyLookPatch } = await import("yt-dlp-transcript-common/lib/report/look.mjs");
const m = { ...manifest(), render: { ...manifest().render, gapCue: { mark: true, min: 4 } } };
const row = panelState(m, m, {}).find((r) => r.id === "gap-cue");
assert.ok(row, "the gap mark is in the panel");
assert.equal(row.base, "render.gapCue");
assert.deepEqual(row.fields, { mark: true, min: 4 });
- assert.deepEqual(row.ui.map((f) => f.key), ["mark", "min", "corner", "label"]);
+ assert.deepEqual(row.ui.map((f) => f.key), ["mark", "min", "place", "corner", "label"]);
// min cleared, the label set: min goes as null, so the merging writer drops it.
const w = panelWrite(m, "gap-cue", { fields: { min: null, label: "{s} later" } });
assert.deepEqual(w.render, { gapCue: { min: null, mark: true, label: "{s} later" } });
diff --git a/umtool/report-to-video/modules/gap-cue.mjs b/umtool/report-to-video/modules/gap-cue.mjs
@@ -1,40 +1,97 @@
-// THE GAP MARK (module `gap-cue`, an input): "» 27 s" at the join a clip's gap
-// leaves, drawn into the clip's segment over its seconds (report-to-video
-// gap-mark.mjs; the settings, the label and the timing: common
-// lib/report/gapCue.mjs, which umtool's pages read too). It draws on the
-// footage at its encode, so it has no page and no region.
-import { GAP_CUE_CORNERS, GAP_CUE_DEFAULTS, GAP_CUE_LABEL_MAX, GAP_CUE_MIN, GAP_REASON_MAX, validateGapCue } from "yt-dlp-transcript-common/lib/report/gapCue.mjs";
-import { defineModule } from "./contract.mjs";
+// THE GAP MARK (module `gap-cue`, region `gap-cue`): "» 27 s" at the join a
+// clip's gap leaves. Wherever a deck is drawn it is THIS page -- one short page
+// per mark, laid at its own second over the frame (chrome-gap-cue.mjs; the
+// marks, their seconds and their place: the schedule's `gapCue` slice,
+// gap-cue-slice.mjs) -- so turning the mark on, moving it, restyling it or
+// changing its words re-renders chrome only, never a clip segment. Where no
+// chrome is laid over the picture (the plain cut, --no-chrome, a bare vertical
+// cut, --desktop, --short) the build draws it into the clip's segment instead
+// (gap-mark.mjs, gapMarkByChrome says which); never both on one frame. The
+// settings, the label and the timing: common lib/report/gapCue.mjs.
+import path from "node:path";
+
+import {
+ GAP_CUE_CORNERS, GAP_CUE_DEFAULTS, GAP_CUE_LABEL_MAX, GAP_CUE_MIN, GAP_CUE_PLACES, GAP_REASON_MAX, validateGapCue,
+} from "yt-dlp-transcript-common/lib/report/gapCue.mjs";
+import { snapWindow } from "../deck.mjs";
+import { GAP_CUE_ID_RE, gapCueHtml, gapCueWindows } from "../chrome-gap-cue.mjs";
+import { assertRegion, defineModule } from "./contract.mjs";
export default defineModule({
id: "gap-cue",
- version: 1,
- z: 3,
- kind: "input",
+ version: 2,
+ // Over the popup posts (30), under the stamps (40).
+ z: 35,
+ kind: "overlay-window",
slot: "footage",
- // Its form in the stacked vertical deck (vertical-deck.mjs): drawn in the segment, as the blur is.
- vertical: { slot: "input" },
+ // Its form in the stacked vertical deck (vertical-deck.mjs): over the picture.
+ vertical: { slot: "picture" },
title: "Gap mark",
- summary: "A small mark at each join a clip's gap leaves, saying how much was skipped.",
+ summary: "A small mark at each join a clip's gap leaves, saying how much was skipped: a page per mark, at its own seconds.",
configKey: "render.gapCue",
defaults: { ...GAP_CUE_DEFAULTS },
validate: (_value, { manifest }) => validateGapCue(manifest),
ui: [
{ key: "mark", type: "boolean", label: "Mark the gaps' joins", default: GAP_CUE_DEFAULTS.mark },
{ key: "min", type: "number", min: GAP_CUE_MIN.min, max: GAP_CUE_MIN.max, step: 0.5, label: "Shortest gap marked (s)", default: GAP_CUE_DEFAULTS.min },
- { key: "corner", type: "enum", options: [...GAP_CUE_CORNERS], label: "Corner", default: GAP_CUE_DEFAULTS.corner },
+ { key: "place", type: "enum", options: [...GAP_CUE_PLACES], label: "Where (over the footage, or in the deck)", default: GAP_CUE_DEFAULTS.place },
+ { key: "corner", type: "enum", options: [...GAP_CUE_CORNERS], label: "Corner (over the footage)", default: GAP_CUE_DEFAULTS.corner },
{ key: "label", type: "text", label: "Label ({s} the time skipped, {why} the reason, [ ] only with one)", default: GAP_CUE_DEFAULTS.label },
],
docs: {
heading: "Gap mark",
- intro: "The full reference is [Gaps inside a clip](#gaps-inside-a-clip) (the mark at the join).",
+ intro: "The full reference is [Gaps inside a clip](#gaps-inside-a-clip) (the mark at the join). Under a deck the mark is this module's page, one per mark; with no chrome over the picture it is drawn into the clip's segment.",
rows: [
["`render.gapCue.mark`", "`true` · `false` · default `false` (off: every cut renders as it did)", "`umtool look <p> gapCue='{\"mark\":true}'` · a take: `--set render.gapCue.mark=true`"],
["`render.gapCue.min`", `${GAP_CUE_MIN.min}–${GAP_CUE_MIN.max} s · default ${GAP_CUE_DEFAULTS.min} (a shorter gap draws nothing)`, "`umtool look <p> gapCue='{\"min\":4}'`"],
+ ["`render.gapCue.place`", "`footage` (over the footage, at its corner) · `deck` (in the deck's band, at the end of the source line, left of the QR -- over the footage where the row has no room, in the stacked vertical deck and in a cut with no deck; the page measures the line in its own faces and never stands the mark on it) · default `footage`", "`umtool look <p> gapCue='{\"place\":\"deck\"}'`"],
["`render.gapCue.corner`", "`auto` (the layout's free corner) · `tl` · `tr` · `bl` · `br` · default `auto`", "`umtool look <p> gapCue='{\"corner\":\"br\"}'`"],
["`render.gapCue.label`", `text holding \`{s}\` (the time skipped: \`27 s\`, from a minute \`1:12\`) and maybe \`{why}\` (the gap's reason); a part in \`[ ]\` is drawn only when the gap has one; at most ${GAP_CUE_LABEL_MAX} characters · default \`${GAP_CUE_DEFAULTS.label}\` (\`» 27 s\`, \`» 26 s · dead air\`)`, "`umtool look <p> gapCue='{\"label\":\"{s} later\"}'`"],
- ["a clip's `gapCue`", "the same keys, over the project's", "`umtool set <p> <clip> gapCue.mark=false gapCue.corner=tr` (`gapCue=` clears them)"],
+ ["a clip's `gapCue`", "the same keys, over the project's", "`umtool set <p> <clip> gapCue.mark=false gapCue.corner=tr gapCue.place=deck` (`gapCue=` clears them)"],
["a gap's `mark`, `why`, `reason`, `corner`", `\`mark\` \`true\` · \`false\` (over the clip's and the project's); \`why\` \`dead-air\` · \`idle\` · \`other\` (the mark says "dead air", "idle", nothing); \`reason\` its own words, 1-${GAP_REASON_MAX} characters, said instead; \`corner\` \`tl\` · \`tr\` · \`bl\` · \`br\` (its mark there, over the clip's)`, "`umtool set <p> <clip> gap.mark=12.3:off gap.why=12.3:dead-air gap.reason=12.3:walks off gap.corner=12.3:tr` (`…:default`, `gap.reason=12.3:` drop one) · the bench: click the gap's band"],
],
},
+ region: "gap-cue",
+ workers: "narrow",
+ noun: "the gap mark's",
+ on: (schedule) => gapCueWindows(schedule).length > 0,
+ check: (schedule) => (gapCueWindows(schedule).length ? null : "the gap mark needs a clip with a marked gap under a deck (render.gapCue.mark, or a clip's or a gap's own)"),
+ window(schedule, { window = null, segment = null, fps, total }) {
+ const want = window ?? gapCueWindows(schedule).find((w) => w.segment === segment);
+ if (!want) throw new Error(segment ? `no gap mark ${segment} in this schedule` : "the gap mark needs a window (or a mark id)");
+ if (!GAP_CUE_ID_RE.test(String(want.segment))) throw new Error(`gap-cue: ${want.segment} is not a mark id`);
+ return snapWindow({ segment: want.segment, from: want.from, to: want.to }, { fps, total });
+ },
+ names: ({ preview, window }) => ({ project: `gap-cue-${preview ? "preview-" : ""}${window.segment}`, stem: `gap-cue-${window.segment}` }),
+ async page(ctx) {
+ // The deck's own bold face: the mark is part of the deck's family.
+ const fonts = await ctx.fonts({ regular: "DeckSans", bold: "DeckSansBold" }, { strict: true });
+ return gapCueHtml(ctx.schedule, ctx.render, ctx.window, { fonts });
+ },
+ /**
+ * One window per mark, each over the whole frame (a mark stands over the footage or in the deck's band, and Play
+ * lays a layer's windows at one geometry), snapped to the frame grid. `shift`/`clip` as popup-posts' regions.
+ */
+ regions(schedule, { render, outDir, shift = 0, clip = null }) {
+ const fps = Number(schedule.fps ?? render.fps);
+ const W = render.width ?? 1920;
+ const H = render.height ?? 1080;
+ return gapCueWindows(schedule)
+ .map((w) => ({ w, s: snapWindow({ segment: w.segment, from: w.from, to: w.to }, { fps, total: schedule.total }) }))
+ .filter(({ s }) => !clip || (s.from < clip.at + clip.dur && s.to > clip.at))
+ .map(({ w, s }) => assertRegion({
+ name: "gap-cue",
+ segment: s.segment,
+ window: { segment: w.segment, from: w.from, to: w.to },
+ frames: path.join(outDir, "chrome", `gap-cue-${s.segment}-frames`),
+ x: 0, y: 0, width: W, height: H,
+ offset: s.from - shift,
+ frameCount: s.frames,
+ }, "window"));
+ },
+ preview: (_slice, { render }) => ({ region: "gap-cue", geometry: { x: 0, y: 0, width: render.width ?? 1920, height: render.height ?? 1080 } }),
+ // Its page is its live preview: Play the cut seeks it in the cut's seconds (contract.mjs, PLAY).
+ play: { clock: "cut", ready: "gap-cue:ready" },
+ // A window of the cut: frame n is cut time `from` + n / fps; its frames are reused unless its text, rect, look or seconds change.
+ frameKeys: { data: "gap-cue-data", omit: ["init", "cues", "from", "dur"], offset: "from" },
});
diff --git a/umtool/report-to-video/modules/registry.test.mjs b/umtool/report-to-video/modules/registry.test.mjs
@@ -46,10 +46,10 @@ test("the registry: unique ids and regions, sorted by z, the deck's overlays in
const ids = MODULES.map((m) => m.id);
assert.equal(new Set(ids).size, ids.length);
for (let i = 1; i < MODULES.length; i += 1) assert.ok(MODULES[i - 1].z <= MODULES[i].z);
- // The order the build has always laid them in, the measure's instruments beside the side panel; the
+ // The order the build has always laid them in (the gap mark's pages over the posts, under the stamps), the measure's instruments beside the side panel; the
// finale over all of them but the dial's finale and the promise clock, drawn over it (z 95 both); the shelf's
// note page under the measure extras (it never meets them: they stand in slots of their own beside it).
- assert.deepEqual(deckOverlays().map((m) => m.region), ["deck", "feed", "posts", "stamp", "chat", "stats", "pair", "status", "fx", "shelf", "streak", "diet", "peak", "goals", "threads", "dial", "odometer", "trail", "flips", "chapter", "finale", "runs-finale", "dial-finale", "promise"]);
+ assert.deepEqual(deckOverlays().map((m) => m.region), ["deck", "feed", "posts", "gap-cue", "stamp", "chat", "stats", "pair", "status", "fx", "shelf", "streak", "diet", "peak", "goals", "threads", "dial", "odometer", "trail", "flips", "chapter", "finale", "runs-finale", "dial-finale", "promise"]);
assert.equal(moduleOfRegion("deck").id, "shell");
assert.equal(regionModule("posts").id, "popup-posts");
assert.throws(() => regionModule("nope"), /unknown chrome region: nope/);
@@ -60,7 +60,7 @@ test("the registry: unique ids and regions, sorted by z, the deck's overlays in
test("placement and caching come from the module's kind", () => {
for (const r of ["deck", "feed", "stamp", "chat", "stats", "fx", "threads", "flips", "dial", "odometer", "trail"]) assert.equal(placementOf(r), "whole", r);
- for (const r of ["posts", "finale", "dial-finale"]) assert.equal(placementOf(r), "window", r);
+ for (const r of ["posts", "gap-cue", "finale", "dial-finale"]) assert.equal(placementOf(r), "window", r);
assert.equal(placementOf("chart"), null);
assert.equal(placementOf("teaser"), null);
assert.deepEqual(regionCaching("deck"), { keyed: true, wholeCut: true });
@@ -153,7 +153,7 @@ test("play: a live-preview contract only an overlay with a page and regions decl
assert.throws(() => defineModule({ ...base, play: { clock: "cut", ready: "x" } }), /play must be/);
assert.throws(() => defineModule({ ...base, page: undefined, play: { clock: "cut", ready: "x:ready" } }), /only an overlay with a page/);
assert.throws(() => defineModule({ ...base, kind: "segment", play: { clock: "cut", ready: "x:ready" } }), /only an overlay with a page/);
- assert.deepEqual(playModules().map((m) => m.id), ["stats", "pair", "status", "fx", "shelf", "streak", "diet", "peak", "goals", "threads", "dial", "odometer", "trail", "flips", "chapter", "runs-finale", "dial-finale", "promise"]);
+ assert.deepEqual(playModules().map((m) => m.id), ["gap-cue", "stats", "pair", "status", "fx", "shelf", "streak", "diet", "peak", "goals", "threads", "dial", "odometer", "trail", "flips", "chapter", "runs-finale", "dial-finale", "promise"]);
for (const m of playModules()) assert.equal(m.play.ready, `${m.region}:ready`, m.id);
});
diff --git a/umtool/report-to-video/package.json b/umtool/report-to-video/package.json
@@ -58,6 +58,8 @@
"./frames-cut": "./frames-cut.mjs",
"./fx": "./fx.mjs",
"./gaps": "./gaps.mjs",
+ "./gap-cue-slice": "./gap-cue-slice.mjs",
+ "./gap-mark-place": "./gap-mark-place.mjs",
"./ladder-chunks": "./ladder-chunks.mjs",
"./ledger-totals": "./ledger-totals.mjs",
"./measure-slice": "./measure-slice.mjs",