commit 850d47f6b5259536c702a42b75df5995ac8b96b9
parent 27c58f8bed26b5ad2cc16ae864bc007e651401de
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Fri, 20 Nov 2026 17:31:03 -0500
umtool: under a deck the gap mark is the gap-cue module's pages (slice 1d)
The gap mark becomes a registered HyperFrames module (overlay-window, z 35):
one short transparent page per mark over the frame, at its own seconds,
from the schedule's new gapCue slice (gap-cue-slice.mjs). Wherever a deck is
drawn over the picture the clip's segment draws no mark, so its argv, record
and key are the plain ones; turning the mark on, moving it, restyling it or
changing its words re-renders chrome only. The drawtext stays for builds with
no chrome over the picture (the plain cut, --no-chrome, a bare vertical cut,
--desktop, --short); a segment that drew its own marks is left out of the
chrome's (never both on one frame). The build says which drew them.
- joins from the cut records the schedule already reads (start, end, gaps),
so a take cut before this gets its marks from a chrome-only pass
- render.gapCue.place / a clip's gapCue.place: footage (default) or deck, at
the end of the source line left of the QR; over the footage when the line
(its source status at its longest) and the mark do not both fit the row,
in the stacked deck, or over a segment that hides the deck
- the mark hops off hidden regions, a stamp, the posts' column, the chat
column and a chapter's cover while each is up
- the look from GAP_CUE_LOOK as CSS (common gapCueBoxStyle / gapCueCss): a
real border, the deck's bold face; GapMarkChip draws the same box
- Play the cut under a deck shows the module's page (the chip is gone
there); the bench says "in the deck" for a deck-placed mark
- gap-mark.mjs split: gap-mark-place.mjs is the pure placement
- CLI gapCue.place, the bench's where, the Modules panel's row; knobs.md
(where it is drawn, reversed, and what re-renders), modules docs, changelog
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
22 files changed, 1325 insertions(+), 383 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
@@ -1,6 +1,19 @@
# Changelog
## [Unreleased]
+- **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.
- **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,8 @@ 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 });
+ // (Only without a deck: under one, the gap-cue module's page draws it, ModuleLayers.)
+ const gapCorner = gapMarkCorner(gapMark?.corner ?? cueEntry?.gapCue?.corner, { deck: false });
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,9 +509,7 @@ 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 && (
- <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" />
- )}
+ {/* The gap mark under a deck is the gap-cue module's own page (a play layer, below): its live preview. */}
{/* Over a full-frame item (full-frame.mjs) a layer that keeps no time of its own is not drawn (layerOff):
kept mounted, transparent, so its page is ready and seeked when the item after it comes up. The feed
follows the deck (followsDeck), as the deck's own page does: off over a video entry or an analysis item. */}
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
@@ -282,23 +282,28 @@ 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 (not an effect's shot box). 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
@@ -308,23 +313,66 @@ 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).
+ - **`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). 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, reckoned at the deck face's advance) and the mark both fit the row with air between; 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"`). Likewise in the stacked vertical deck (its band is laid otherwise:
+ `fell: "stacked"`), over a segment that hides the deck (`fell: "hidden"`), and in a cut with no deck.
+ - **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.
+ With a gap-cue page in the cut the deck is no longer its one overlay layer, so the deck's lazy capture (only the
+ frames the chunks to encode read) is off for that build, as with any other window module.
+ - **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 (`<id>: its gap marks are drawn into its segment … build without --chrome-only (or --only <id>) to have
+ the chrome draw 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.
@@ -3009,9 +3057,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` |
@@ -3044,7 +3092,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`
@@ -3176,19 +3224,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.
@@ -3212,6 +3247,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, the deck is hidden or stacked, and in a cut with no deck) · 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/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/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/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
@@ -6547,12 +6553,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 +6570,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 +6580,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 +7214,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 +7784,13 @@ 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.
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` });
- }
+ if (e?.type !== "clip" || !Array.isArray(records[k]?.gapMarks) || !records[k].gapMarks.length) return;
+ EMIT("note", { message: `${e.id}: its gap marks are drawn into its segment (built without the chrome drawing them) — ${what} leaves the chrome's out for it; build without ${what} (or --only ${e.id}) to have the chrome draw them` });
});
}
for (const i of missing) {
diff --git a/umtool/report-to-video/chrome-gap-cue.mjs b/umtool/report-to-video/chrome-gap-cue.mjs
@@ -0,0 +1,71 @@
+// 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 { 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. */
+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 }));
+}
+
+/**
+ * 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 (the face's real width may differ from the slice's reckoning, so the
+ * mark hugs the edge it is placed against).
+ *
+ * @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 }} [opts]
+ */
+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);
+ const len = Math.max(0, b - a);
+ const inDur = Math.min(M.in, len / 2);
+ const outDur = Math.min(M.out, len / 2);
+ const { init, cues } = compileCues({ gm: { autoAlpha: 0 } }, [
+ { k: "gm", at: a, dur: inDur, to: { autoAlpha: M.peak }, ease: "none" },
+ { k: "gm", at: b - outDur, dur: outDur, to: { autoAlpha: 0 }, ease: "none" },
+ ]);
+ const right = m.place === "deck" || String(m.corner ?? "").endsWith("r");
+ const bottom = m.place !== "deck" && String(m.corner ?? "").startsWith("b");
+ const r = m.rect;
+ const at = [
+ right ? `right: ${W - (r.x + r.w)}px;` : `left: ${r.x}px;`,
+ bottom ? `bottom: ${H - (r.y + r.h)}px;` : `top: ${r.y}px;`,
+ ].join(" ");
+ const line = m.place === "deck" ? GAP_CUE_DECK_LINE : 1.2;
+ const css = `${gapCueCss(".gm", { font: m.font, stroke: m.stroke, lineHeight: line })}
+ .gm { visibility: hidden; opacity: 0; ${at} max-width: ${Math.max(r.w, 1)}px; }`;
+ const body = `<div class="gm" data-k="gm" data-gm="${esc(m.text)}" data-place="${esc(m.place)}">${esc(m.text)}</div>`;
+ return cuePageHtml({ id: "gap-cue", W, H, fps, fonts: opts.fonts, gsapSrc: opts.gsap, css, body, init, cues, window: { from, dur } });
+}
diff --git a/umtool/report-to-video/gap-cue-slice.mjs b/umtool/report-to-video/gap-cue-slice.mjs
@@ -0,0 +1,212 @@
+// 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. With no record (a preview before any build) 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 and a chapter's cover 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) 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"`).
+//
+// 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 { censorRegionsOf } from "./clip-censor.mjs";
+import { chatGeometry } from "./chrome-chat.mjs";
+import { chapterCover, chapterWindows } from "./chrome-story.mjs";
+import { deckGeometry, deckLayout, deckOn, deckScale, overlayBox, playWindow, postsGeometry, stampGeometry } from "./deck.mjs";
+import { tallyOf } from "./factcheck.mjs";
+import { censorAvoidRects, gapMarkAsked, gapMarkPlaces, gapMarkSize, recordGapMarks, sansWidth, twoCropMarkBox } from "./gap-mark-place.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);
+
+/** 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 when it has one (`start`, `end`, `gaps`), else its
+ * play window and its own gaps inside it (an estimate, as a preview's segments are).
+ */
+function basisOf(entry, render, rec) {
+ if (rec && fin(Number(rec.start)) && fin(Number(rec.end)) && Array.isArray(rec.gaps)) return 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 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.
+ *
+ * @returns {{ rect: { x: number, y: number, w: number, h: number }, font: number, stroke: number } | { 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 untitled = !segment.title;
+ const two = t.lines === 2;
+ // The source line's row: under the title (its meta line in two lines); untitled, promoted into the title's band
+ // a size up (chrome-deck.mjs's untitled arrangement).
+ const uSize = Math.round(t.subtitleSize * 1.35);
+ const uBox = Math.round(uSize * 1.3);
+ const rowSize = untitled && !two ? uSize : t.subtitleSize;
+ const rowBox = untitled && !two ? uBox : t.subtitleBox;
+ const rowY = untitled && !two
+ ? Math.round(t.titleY + (t.subtitleY + t.subtitleBox - t.titleY - uBox - 14) / 2)
+ : t.subtitleY + (two ? t.headBox ?? 0 : 0);
+ const font = Math.max(12, Math.round(rowSize * 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 = sansWidth(text, font) + 2 * edge;
+ const h = Math.ceil(font * GAP_CUE_DECK_LINE) + 2 * edge;
+ const right = t.x + t.width - z(22);
+ // The source line as it would draw at its longest (its status at its longest too), and air before the mark.
+ const lineText = two && Array.isArray(segment.subtitleLines) ? String(segment.subtitleLines.at(-1) ?? "") : String(segment.subtitle ?? "");
+ const lineW = sansWidth(lineText, rowSize);
+ if (t.x + lineW + z(24) > right - w) return { fell: "row" };
+ return { rect: { x: band.x + right - w, y: band.y + rowY + Math.round((rowBox - h) / 2), w, h }, font, stroke };
+}
+
+/**
+ * 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.
+ */
+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 });
+ }
+ 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, font, stroke, fell? }` -- `at`/`until` the cut's seconds, `rect` frame px, `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 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);
+ 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 }));
+ const onCut = own.map((m) => ({ ...m, at: r4(seg.start + m.at), until: r4(seg.start + m.until) }));
+ const places = gapMarkPlaces({ marks: onCut, box: base, want: cue.corner, prefer: fb.prefer, size, avoid: [...censor, ...avoids], measure: sansWidth });
+ 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 } : {}),
+ };
+ if (cue.place === "deck") {
+ const d = gapCueDeckRect({ render, schedule, segment: seg, text: m.text });
+ if ("rect" in d) {
+ marks.push({ ...common, text: m.text, place: "deck", rect: d.rect, font: d.font, stroke: d.stroke });
+ return;
+ }
+ const p = places[k];
+ marks.push({ ...common, text: p.text, place: "footage", fell: d.fell, corner: p.corner, ...(asked ? { asked } : {}), rect: p.rect, font: p.size.fontSize, stroke: p.size.stroke });
+ return;
+ }
+ const p = places[k];
+ marks.push({ ...common, text: p.text, place: "footage", corner: p.corner, ...(asked ? { asked } : {}), rect: p.rect, font: p.size.fontSize, stroke: p.size.stroke });
+ });
+ }
+ 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,246 @@
+// 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");
+});
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, the deck is hidden or stacked, and in a cut with no deck) · 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",