Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit bb007c25771a4daf0c8219daaadd6fd3d3f1cd22
parent 7deb11a1b5e6ee399301b8f768cb854dabcdd9dc
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Fri, 20 Nov 2026 14:30:27 -0500

umtool: the gap mark says why, has a border, and can stand in a gap's own corner

Operator rulings, 20 Nov, after mocks on real footage.

- "Add the reason to the mark." A gap's why is dead-air, idle or other.
  The mark says "dead air" or "idle", and nothing for other. A gap may
  instead carry its own words (reason, 1 to 24 characters on one line). The
  label takes {why} and a part in [ ] that is drawn only when the gap has a
  reason. The default is "» {s}[ · {why}]", so a gap with no reason reads
  "» 27 s" exactly as before and one with a reason reads
  "» 26 s · dead air". A merged mark says a reason only when all of its
  gaps give the same one. CLI: gap.why=<s>:idle, gap.reason=<s>:<words>
  (gap.reason=<s>: drops them). The bench has a why select and a words
  field.
- "More visible and readable with a border." Every number for the mark is
  in common GAP_CUE_LOOK:
  - Plex Mono Bold at 3 % of the frame's short side (32 px at 1080);
  - a #101010 box at 86 %, 0.38 em around the text;
  - a 2 px white border at 90 %.
  The build draws the border with a second drawtext under the first: the
  same text, unseen, with its box in the border's colour and wider by the
  stroke. The pages' element reads the same constants, so its inside matches
  the build's composite. The brand palette no longer colours the mark.
- "Per-clip positioning": the clip's corner is on the bench. A gap now
  has its own corner (tl, tr, bl, br) that places its mark over the
  clip's corner, since a stream's layout can change within one clip. In a
  merged mark, the first gap that names a corner wins. CLI:
  gap.corner=<s>:tr. knobs.md now says the automatic corner avoids only our
  own hidden regions and codes, not a stream's burned-in chat or banners.
  The default corner is unchanged.
- gapOwnSays (the reason and corner that a join's own gaps give) is in
  common, so the build and the pages take it from one place.
- Tests: common gapCue (reason, label parts, merged reason, corner);
  gap-mark (sizes, two-box filter, per-mark corner, joins' reason and
  corner); gaps (idle, reason, corner kept, edited, refused); gapCueView
  (page equals build with a reason and a corner); gaps-writer (gap.reason
  and gap.corner through set, the list writer refuses a bad corner);
  gaps-render (the box's luma read inside the new border). knobs.md's gaps
  section and Modules rows, and cli.md, were regenerated or updated, plus a
  changelog entry in editor/CHANGELOG.md.

Co-Authored-By: Claude <noreply@anthropic.com>

Diffstat:
Mcommon/lib/report/gapCue.d.mts | 18++++++++++++++----
Mcommon/lib/report/gapCue.mjs | 125++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------
Mcommon/lib/report/gapCue.test.ts | 30+++++++++++++++++++++++++++---
Meditor/CHANGELOG.md | 16++++++++++++++++
Mumtool/components/projects/ClipBench.tsx | 3++-
Mumtool/components/projects/bench/GapCueTools.tsx | 62+++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
Mumtool/components/projects/bench/useGapEditor.ts | 12++++++++++--
Mumtool/components/projects/review/GapMarkChip.tsx | 29+++++++++++++++++++++--------
Mumtool/components/projects/review/playCore.tsx | 2+-
Mumtool/docs/cli.md | 2+-
Mumtool/docs/knobs.md | 47++++++++++++++++++++++++++++++++---------------
Mumtool/lib/cli/groups.mjs | 2+-
Mumtool/lib/report/gapCueView.mjs | 18++++++++++--------
Mumtool/lib/report/gapCueView.test.mjs | 14++++++++++++++
Mumtool/lib/report/gaps-writer.test.mjs | 9+++++++++
Mumtool/lib/report/knobsCli.mjs | 34++++++++++++++++++++++------------
Mumtool/lib/report/manifest.mjs | 6++++++
Mumtool/report-to-video/build-video.mjs | 2+-
Mumtool/report-to-video/gap-mark.mjs | 85++++++++++++++++++++++++++++++++++++++++++++++---------------------------------
Mumtool/report-to-video/gap-mark.test.mjs | 28++++++++++++++++++++++------
Mumtool/report-to-video/gaps-render.test.mjs | 7++++---
Mumtool/report-to-video/gaps.mjs | 31++++++++++++++++++++++++-------
Mumtool/report-to-video/gaps.test.mjs | 10++++++++--
Mumtool/report-to-video/modules/gap-cue.mjs | 8++++----
24 files changed, 459 insertions(+), 141 deletions(-)

diff --git a/common/lib/report/gapCue.d.mts b/common/lib/report/gapCue.d.mts @@ -5,15 +5,23 @@ 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 GapCueMark = { at: number; until: number; seconds: number; count: number }; -export type GapJoin = { at: number; seconds: number; mark: boolean; play?: number }; +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_CORNERS: readonly GapCueCorner[]; export const GAP_CUE_MIN: Readonly<{ min: number; max: number }>; export const GAP_CUE_LABEL_MAX: number; -export const GAP_WHY: readonly ("dead-air" | "other")[]; +export const GAP_WHY: readonly GapWhy[]; +export const GAP_WHY_WORDS: Readonly<Record<GapWhy, string>>; +export const GAP_REASON_MAX: number; +export const GAP_OWN_CORNERS: readonly ("tl" | "tr" | "bl" | "br")[]; +export const GAP_CUE_LOOK: Readonly<{ + font: number; pad: number; inset: number; stroke: number; strokeMin: number; + fg: string; box: string; boxAlpha: number; strokeColor: string; strokeAlpha: number; +}>; export const GAP_CUE_MOTION: Readonly<{ in: number; hold: number; out: number; peak: number }>; export const GAP_CUE_LIFE: number; @@ -24,7 +32,9 @@ export function clipGapCueOf(render: Render, entry: Entry): GapCue; export function gapMarkOn(cue: { mark: boolean }, gap: ({ mark?: unknown } & Record<string, unknown>) | null | undefined): boolean; export function gapCueWanted(render: Render, entry: Entry): boolean; export function gapCueLength(seconds: number): string; -export function gapCueText(seconds: number, label?: string): string; +export function gapWhyWord(gap: { why?: unknown; reason?: unknown } | null | undefined): string; +export function gapOwnSays(own: Array<{ why?: unknown; reason?: unknown; corner?: unknown }>): { why?: string; corner?: string }; +export function gapCueText(seconds: number, label?: string, why?: string): string; export function gapCues(joins: GapJoin[], opts?: { min?: number; seconds?: number; life?: number }): GapCueMark[]; export function gapCueAlpha(t: number, cue: { at: number; until: number }): number; export function patchGapCue(current: unknown, patch: unknown): Record<string, unknown> | null; diff --git a/common/lib/report/gapCue.mjs b/common/lib/report/gapCue.mjs @@ -18,11 +18,20 @@ // mark draw the mark at a join (default false: OFF, so a cut that says nothing renders as it always did) // min a gap shorter than this draws nothing (seconds, default 2: a breath taken out is not worth a mark) // corner auto | tl | tr | bl | br (default auto: the layout's own free corner) -// label the text, `{s}` the length skipped (default "» {s}": "» 27 s", from a minute "» 1:12") +// 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") // -// A gap may also carry `why` ("dead-air" | "other"): what it was cut for. It -// draws nothing in slice 1; a fast-forward default (slice 3) will reach only -// the gaps marked dead air, so a gap cut to HIDE what is in it never plays. +// 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 +// says the reason (operator, 20 Nov: "add the reason to the mark"): `reason` +// when it is set, else why's word (GAP_WHY_WORDS: "dead air", "idle"; "other" +// says nothing). A fast-forward default (slice 3) will reach only the gaps +// marked dead air, so a gap cut to HIDE what is in it never plays. A gap's +// `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 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 @@ -37,7 +46,7 @@ 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}" }); +export const GAP_CUE_DEFAULTS = Object.freeze({ mark: false, min: 2, corner: "auto", label: "» {s}[ · {why}]" }); /** The keys `render.gapCue` and a clip's `gapCue` take. */ export const GAP_CUE_KEYS = Object.freeze(["mark", "min", "corner", "label"]); /** Where the mark may stand: the layout's choice, or a corner of its box. */ @@ -47,7 +56,23 @@ export const GAP_CUE_MIN = Object.freeze({ min: 0.5, max: 60 }); /** A label's longest, in characters. */ export const GAP_CUE_LABEL_MAX = 40; /** What a gap was cut for (`why`). */ -export const GAP_WHY = Object.freeze(["dead-air", "other"]); +export const GAP_WHY = Object.freeze(["dead-air", "idle", "other"]); +/** What the mark says for each `why` ("other" says nothing: a gap's `reason` says it). */ +export const GAP_WHY_WORDS = Object.freeze({ "dead-air": "dead air", idle: "idle", other: "" }); +/** A gap's own `reason`'s longest, in characters (one line). */ +export const GAP_REASON_MAX = 24; +/** The corners a gap's own `corner` may name (its mark stands there, over its clip's). */ +export const GAP_OWN_CORNERS = Object.freeze(["tl", "tr", "bl", "br"]); +/** + * THE LOOK, once (operator, 20 Nov: "more visible and readable with a border"): sizes as fractions of the + * frame's short side -- `font` the text (0.03: 32 px at 1080), `inset` from the box it stands in, `stroke` the + * border's width (at least `strokeMin` px) -- `pad` the box round the text in ems; the text `fg` on `box` at + * `boxAlpha`, inside a `strokeColor` border at `strokeAlpha`. The whole mark fades together (GAP_CUE_MOTION). + */ +export const GAP_CUE_LOOK = Object.freeze({ + font: 0.03, pad: 0.38, inset: 0.026, stroke: 0.0019, strokeMin: 2, + fg: "#ffffff", box: "#101010", boxAlpha: 0.86, strokeColor: "#ffffff", strokeAlpha: 0.9, +}); /** The mark's motion (seconds) and its opacity at full. */ export const GAP_CUE_MOTION = Object.freeze({ in: 0.15, hold: 0.6, out: 0.35, peak: 0.9 }); /** How long one mark is up: in, hold and out. */ @@ -75,6 +100,7 @@ export function gapCueErrors(v, where = "render.gapCue") { 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 (v.label.length > GAP_CUE_LABEL_MAX || /[\n\r]/.test(v.label)) errors.push(`${where}.label is one line of at most ${GAP_CUE_LABEL_MAX} characters`); + else if (!labelPartsOk(v.label)) errors.push(`${where}.label: a part in [ ] holds {why} and is drawn only when the gap has a reason, e.g. "» {s}[ · {why}]" (no [ ] inside another)`); } return errors; } @@ -99,6 +125,21 @@ export function validateGapCue(manifest) { return errors; } +/** Are a label's [ ] parts well formed: not nested, each closed, each holding {why}. */ +function labelPartsOk(label) { + let open = -1; + for (let i = 0; i < label.length; i += 1) { + if (label[i] === "[") { + if (open >= 0) return false; + open = i; + } else if (label[i] === "]") { + if (open < 0 || !label.slice(open, i).includes("{why}")) return false; + open = -1; + } + } + return open < 0; +} + /** The well-formed keys of a `gapCue` block (anything else dropped). */ function own(v) { if (!isObj(v)) return {}; @@ -106,7 +147,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 (typeof v.label === "string" && v.label.includes("{s}") && v.label.length <= GAP_CUE_LABEL_MAX) out.label = v.label; + if (typeof v.label === "string" && v.label.includes("{s}") && v.label.length <= GAP_CUE_LABEL_MAX && labelPartsOk(v.label)) out.label = v.label; return out; } @@ -158,27 +199,66 @@ export function gapCueLength(seconds) { } /** - * The mark's text: `label` with `{s}` the length skipped. + * What a gap's mark says it was cut for: its own `reason` when set, else its + * `why`'s word (GAP_WHY_WORDS), else "". + * + * @param {{ why?: unknown, reason?: unknown } | null | undefined} gap + */ +export function gapWhyWord(gap) { + const r = typeof gap?.reason === "string" ? gap.reason.trim() : ""; + if (r) return r; + return typeof gap?.why === "string" ? (GAP_WHY_WORDS[/** @type {keyof typeof GAP_WHY_WORDS} */ (gap.why)] ?? "") : ""; +} + +/** + * What a join's own gaps (`own`: the clip's gaps it is -- one, or two the + * frame grid joined) say beyond their seconds: their reason when they all + * give the same (gapWhyWord), and the first corner one names. Only the keys + * they have. + * + * @param {Array<{ why?: unknown, reason?: unknown, corner?: unknown }>} own + * @returns {{ why?: string, corner?: string }} + */ +export function gapOwnSays(own) { + const words = (own ?? []).map((c) => gapWhyWord(c)); + const why = words.length && words.every((w) => w && w === words[0]) ? words[0] : ""; + const corner = (own ?? []).map((c) => c?.corner).find((c) => typeof c === "string" && GAP_OWN_CORNERS.includes(/** @type {any} */ (c))); + return { ...(why ? { why } : {}), ...(typeof corner === "string" ? { corner } : {}) }; +} + +/** + * The mark's text: `label` with `{s}` the length skipped and `{why}` the + * reason (gapWhyWord); a part in [ ] only when there is a reason. * * @param {number} seconds * @param {string} [label] + * @param {string} [why] */ -export const gapCueText = (seconds, label = GAP_CUE_DEFAULTS.label) => String(label).split("{s}").join(gapCueLength(seconds)); +export function gapCueText(seconds, label = GAP_CUE_DEFAULTS.label, why = "") { + const w = String(why ?? "").trim(); + return String(label) + .replace(/\[([^\]]*)\]/g, (_, part) => (w ? part : "")) + .split("{why}").join(w) + .split("{s}").join(gapCueLength(seconds)); +} /** * The marks a segment draws, from its joins. * - * `joins`: each `{ at, seconds, mark, play? }` -- `at` the join on the - * segment's clock, `seconds` the source seconds the gap left out, `mark` - * whether this gap is marked (gapMarkOn), `play` the seconds the gap itself - * plays (0, a skip; slice 3's fast-forward). A gap unmarked, or under `min`, - * draws nothing and joins no mark. Marked joins less than `life` apart are - * one mark, the seconds of each in it. A mark never outlives the segment - * (`seconds`), and one with under a fifth of a second left is not drawn. + * `joins`: each `{ at, seconds, mark, play?, why?, corner? }` -- `at` the + * join on the segment's clock, `seconds` the source seconds the gap left + * out, `mark` whether this gap is marked (gapMarkOn), `play` the seconds the + * gap itself plays (0, a skip; slice 3's fast-forward), `why` what its mark + * says it was cut for (gapWhyWord), `corner` its own corner. A gap unmarked, + * or under `min`, draws nothing and joins no mark. Marked joins less than + * `life` apart are one mark, the seconds of each in it -- its reason only + * when they all say the same, its corner the first's. A mark never outlives + * the segment (`seconds`), and one with under a fifth of a second left is + * not drawn. `why` and `corner` are on a mark only when it has them. * - * @param {Array<{ at: number, seconds: number, mark: boolean, play?: number }>} joins + * @param {Array<{ at: number, seconds: number, mark: boolean, play?: number, why?: string, corner?: string | null }>} joins * @param {{ min?: number, seconds?: number, life?: number }} [opts] - * @returns {Array<{ at: number, until: number, seconds: number, count: number }>} + * @returns {Array<{ at: number, until: number, seconds: number, count: number, why?: string, corner?: string }>} */ export function gapCues(joins, { min = GAP_CUE_DEFAULTS.min, seconds = Infinity, life = GAP_CUE_LIFE } = {}) { const marked = (joins ?? []) @@ -188,18 +268,23 @@ export function gapCues(joins, { min = GAP_CUE_DEFAULTS.min, seconds = Infinity, let open = null; for (const j of marked) { const end = j.at + (fin(j.play) && j.play > 0 ? j.play : 0) + life; + const why = typeof j.why === "string" ? j.why : ""; if (open && j.at < open.until - EPS) { open.until = Math.max(open.until, end); open.seconds += j.seconds; open.count += 1; + if (open.why !== why) open.why = ""; continue; } - open = { at: j.at, until: end, seconds: j.seconds, count: 1 }; + open = { at: j.at, until: end, seconds: j.seconds, count: 1, why, corner: typeof j.corner === "string" ? j.corner : "" }; out.push(open); } const r4 = (v) => Math.round(v * 10000) / 10000; return out - .map((c) => ({ at: r4(Math.max(0, c.at)), until: r4(Math.min(seconds, c.until)), seconds: r4(c.seconds), count: c.count })) + .map((c) => ({ + at: r4(Math.max(0, c.at)), until: r4(Math.min(seconds, c.until)), seconds: r4(c.seconds), count: c.count, + ...(c.why ? { why: c.why } : {}), ...(c.corner ? { corner: c.corner } : {}), + })) .filter((c) => c.until - c.at >= 0.2 - EPS); } diff --git a/common/lib/report/gapCue.test.ts b/common/lib/report/gapCue.test.ts @@ -14,12 +14,13 @@ import { gapCueWanted, gapCues, gapMarkOn, + gapWhyWord, validateGapCue, } from "./gapCue.mjs"; import { applyLookPatch, lookErrors } from "./look.mjs"; -test("the defaults: the mark OFF, 2 s, the layout's corner, '» {s}'", () => { - assert.deepEqual(gapCueOf(undefined), { mark: false, min: 2, corner: "auto", label: "» {s}" }); +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({}), GAP_CUE_DEFAULTS); assert.equal(gapCueWanted({}, { type: "clip", gaps: [{ from: 1, to: 9 }] }), false, "a cut that says nothing marks nothing"); }); @@ -28,7 +29,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}" }); + assert.deepEqual(cue, { mark: false, min: 3, corner: "tr", label: "» {s}[ · {why}]" }); 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); @@ -45,6 +46,29 @@ test("the label: whole seconds, then m:ss, then h:mm:ss; {s} is the length", () assert.equal(gapCueText(72, "{s} later"), "1:12 later"); }); +test("the reason in the mark (operator, 20 Nov): why's word, or the gap's own reason; none, the length alone as before", () => { + assert.equal(gapWhyWord({ why: "dead-air" }), "dead air"); + assert.equal(gapWhyWord({ why: "idle" }), "idle"); + assert.equal(gapWhyWord({ why: "other" }), "", "other says nothing"); + assert.equal(gapWhyWord({ why: "other", reason: " ad break " }), "ad break", "a reason of its own says it"); + assert.equal(gapWhyWord({}), ""); + assert.equal(gapCueText(26, undefined, "dead air"), "» 26 s · dead air"); + assert.equal(gapCueText(26, undefined, ""), "» 26 s", "no reason: exactly the slice 1 text"); + assert.equal(gapCueText(72, "{s} skipped[ ({why})]", "idle"), "1:12 skipped (idle)"); + assert.equal(gapCueText(72, "{s} skipped[ ({why})]"), "1:12 skipped"); + // A merged mark says a reason only when every join in it says the same. + const same = gapCues([{ at: 2, seconds: 5, mark: true, why: "dead air" }, { at: 2.5, seconds: 6, mark: true, why: "dead air" }]); + assert.equal(same[0]!.why, "dead air"); + const mixed = gapCues([{ at: 2, seconds: 5, mark: true, why: "dead air" }, { at: 2.5, seconds: 6, mark: true }]); + assert.equal("why" in mixed[0]!, false); + // Its corner is the first join's own. + assert.equal(gapCues([{ at: 2, seconds: 5, mark: true, corner: "tr" }])[0]!.corner, "tr"); + // The label's [ ] parts: closed, not nested, each holding {why}. + assert.deepEqual(validateGapCue({ render: { gapCue: { label: "» {s}[ · {why}]" } } }), []); + assert.match(validateGapCue({ render: { gapCue: { label: "» {s}[ · why]" } } }).join("\n"), /a part in \[ \] holds \{why\}/); + assert.match(validateGapCue({ render: { gapCue: { label: "» {s}[ · {why}" } } }).join("\n"), /a part in \[ \]/); +}); + test("the marks: under min nothing, marked only, joins within a life are one mark summing their seconds", () => { assert.deepEqual(gapCues([{ at: 2, seconds: 1.5, mark: true }]), [], "a breath taken out draws nothing"); assert.deepEqual(gapCues([{ at: 2, seconds: 27, mark: false }]), [], "unmarked"); diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -1,6 +1,22 @@ # Changelog ## [Unreleased] +- **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 + corner, what its mark will say, and Remove. `G` still puts back the gap at the playhead. Beside it are the clip's + mark settings: on or off, the shortest gap marked, the corner and the label. + - Each control writes what its CLI twin writes (`umtool set … gap.*`, `gapCue.*`), and each write is an undo point. + The project's settings are in the Media tab's Modules panel (Gap mark). A field cleared there now clears. + - Play the cut and the bench draw the mark at the same seconds, with the same text and look as the render. +- **umtool: the gap mark says why, and reads on busy footage.** + - A gap with a reason shows it: `» 26 s · dead air`. `why` is `dead-air`, `idle` or `other`, or the gap can have + its own words (`gap.reason=<s>:walks off`, up to 24 characters). A gap with no reason reads `» 27 s`, as before. + The label's `{why}` and its `[ ]` part (default `» {s}[ · {why}]`) control this. + - The mark is larger (3 % of the frame's short side), on a near-opaque dark box inside a 2 px light border. One set + of numbers draws both the render's mark and the pages' mark. + - A gap can stand its mark in its own corner (`gap.corner=<s>:tr`), over the clip's. The automatic corner does not + know where a stream's own chat or banners are, so on that kind of footage, set the corner. - **umtool: a small mark where a clip skips time.** - With `render.gapCue.mark` on, each join a clip's gap leaves shows `» 27 s` (from a minute `» 1:12`) near a corner of the footage for about a second, fading in and out. There is no sound, flash or wipe. Gaps under 2 s diff --git a/umtool/components/projects/ClipBench.tsx b/umtool/components/projects/ClipBench.tsx @@ -1476,7 +1476,8 @@ export default function ClipBench({ [clipCue, clip.gaps, gapsSpan.from, gapsSpan.to], ); const benchMark = benchMarks.length ? gapMarkAt(benchMarks, clipPlayClock({ gaps: clip.gaps ?? [], from: gapsSpan.from, to: gapsSpan.to }, playhead)) : null; - const benchMarkCorner = gapMarkCorner(clipCue.corner, { deck: data.deckOn }); + // 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 }); const writeGapCue = useCallback( async (patch: Record<string, unknown>) => { const ok = await save({ gapCue: patch }); 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, gapMarkOn, type GapCue } from "yt-dlp-transcript-common/lib/report/gapCue.mjs"; +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 type { GapEditor } from "./useGapEditor"; // --------------------------------------------------------------------------- @@ -11,7 +11,10 @@ import type { GapEditor } from "./useGapEditor"; // // the picked gap (a click on its band) its seconds, how it shows (a skip: // fast-forward is not built yet), its own mark (as the -// clip's, on, off), what it was cut for, Remove +// clip's, on, off), what it was cut for (its mark says it: +// "» 26 s · dead air"), a few words of its own instead, its +// own corner (a stream's layout can change inside a clip), +// what its mark will say, Remove // the clip's the mark at its joins (as the project's, on, off), the // shortest gap marked, the corner, the label // @@ -53,8 +56,10 @@ export default function GapCueTools({ // The two typed fields: drafted, written on Enter or leaving them. const [min, setMin] = useState(own?.min === undefined ? "" : String(own.min)); const [label, setLabel] = useState(own?.label ?? ""); + const [reason, setReason] = useState(g?.reason ?? ""); useEffect(() => setMin(own?.min === undefined ? "" : String(own.min)), [own?.min]); useEffect(() => setLabel(own?.label ?? ""), [own?.label]); + useEffect(() => setReason(g?.reason ?? ""), [g?.from, g?.to, g?.reason]); if (!hasGaps) return null; const commitMin = () => { @@ -67,7 +72,12 @@ export default function GapCueTools({ if (label === (own?.label ?? "")) return; void writeCue({ label: label === "" ? null : label }); }; + const commitReason = () => { + if (!g || reason.trim() === (g.reason ?? "")) return; + void gap.editPicked({ reason: reason.trim() === "" ? null : reason.trim() }); + }; const len = g ? g.to - g.from : 0; + const at = g ? ((g.from + g.to) / 2).toFixed(2) : ""; return ( <div data-gap-settings="" className="flex flex-wrap items-center gap-x-3 gap-y-1 text-[12px]"> {g && ( @@ -85,7 +95,7 @@ export default function GapCueTools({ className={sel} disabled={busy} value={typeof g.mark === "boolean" ? onOff(g.mark) : ""} - title={`umtool set <p> <clip> gap.mark=${((g.from + g.to) / 2).toFixed(2)}:on|off|default`} + title={`umtool set <p> <clip> gap.mark=${at}:on|off|default`} onChange={(e) => void gap.editPicked({ mark: e.target.value === "" ? null : e.target.value === "on" })} > <option value="">as the clip&rsquo;s ({onOff(cue.mark)})</option> @@ -100,14 +110,52 @@ export default function GapCueTools({ className={sel} disabled={busy} value={g.why ?? ""} - title={`umtool set <p> <clip> gap.why=${((g.from + g.to) / 2).toFixed(2)}:dead-air|other|default`} - onChange={(e) => void gap.editPicked({ why: e.target.value === "" ? null : (e.target.value as "dead-air" | "other") })} + title={`what it was cut for, said in its mark (umtool set <p> <clip> gap.why=${at}:dead-air|idle|other|default)`} + onChange={(e) => void gap.editPicked({ why: e.target.value === "" ? null : (e.target.value as "dead-air" | "idle" | "other") })} > <option value="">not said</option> <option value="dead-air">dead air</option> + <option value="idle">idle</option> <option value="other">other</option> </select> </label> + <input + data-gap-reason="" + className={`${sel} w-28`} + disabled={busy} + maxLength={GAP_REASON_MAX} + value={reason} + placeholder="own words" + title={`a few words the mark says instead (at most ${GAP_REASON_MAX}; umtool set <p> <clip> gap.reason=${at}:<words>, gap.reason=${at}: drops them)`} + onChange={(e) => setReason(e.target.value)} + onBlur={commitReason} + onKeyDown={(e) => { + if (e.key === "Enter") commitReason(); + }} + /> + <label className="flex items-center gap-1"> + <span className="micro">corner</span> + <select + data-gap-corner-select="" + className={sel} + disabled={busy} + value={g.corner ?? ""} + title={`where this gap's mark stands, over the clip's (umtool set <p> <clip> gap.corner=${at}:tl|tr|bl|br|default)`} + onChange={(e) => void gap.editPicked({ corner: e.target.value === "" ? null : (e.target.value as "tl" | "tr" | "bl" | "br") })} + > + <option value="">as the clip&rsquo;s ({CORNER_WORDS[cue.corner] ?? cue.corner})</option> + {GAP_OWN_CORNERS.map((c) => ( + <option key={c} value={c}> + {CORNER_WORDS[c] ?? c} + </option> + ))} + </select> + </label> + {gapMarkOn(cue, g) && len >= cue.min && ( + <span data-gap-says={gapCueText(len, cue.label, gapWhyWord(g))} className="font-mono text-[11px] text-[var(--color-dim)]" title="what its mark says"> + {gapCueText(len, cue.label, gapWhyWord(g))} + </span> + )} {gapMarkOn(cue, g) && len < cue.min && ( <span data-gap-under-min="" className="text-[var(--color-dim)]"> under {cue.min} s: no mark @@ -118,7 +166,7 @@ export default function GapCueTools({ data-gap-remove="" className={buttonVariants({ variant: "outline", size: "sm" })} disabled={busy} - title={`put these seconds back in the clip (G at the playhead; umtool set <p> <clip> gap.remove=${((g.from + g.to) / 2).toFixed(2)})`} + title={`put these seconds back in the clip (G at the playhead; umtool set <p> <clip> gap.remove=${at})`} onClick={() => gap.remove(g)} > Remove @@ -186,7 +234,7 @@ export default function GapCueTools({ disabled={busy} value={label} placeholder={project.label} - title="{s} is the time skipped (umtool set <p> <clip> gapCue.label='» {s}')" + title="{s} is the time skipped, {why} the gap's reason, [ ] drawn only with a reason (umtool set <p> <clip> gapCue.label='» {s}[ · {why}]')" onChange={(e) => setLabel(e.target.value)} onBlur={commitLabel} onKeyDown={(e) => { diff --git a/umtool/components/projects/bench/useGapEditor.ts b/umtool/components/projects/bench/useGapEditor.ts @@ -19,11 +19,17 @@ import type { Span } from "./benchMedia"; // --------------------------------------------------------------------------- /** A gap's own settings (common gapCue.mjs): its mark over the clip's, what it was cut for. */ -export type GapOwn = { mark?: boolean; why?: "dead-air" | "other" }; +export type GapOwn = { mark?: boolean; why?: "dead-air" | "idle" | "other"; reason?: string; corner?: "tl" | "tr" | "bl" | "br" }; /** A gap as saved: its seconds and its own settings. */ export type SavedGap = Span & GapOwn; /** One gap's own settings changed, its seconds as they are (the window writer's `gapEdit`; null drops a key). */ -export type GapEdit = { at: number; mark?: boolean | null; why?: "dead-air" | "other" | null }; +export type GapEdit = { + at: number; + mark?: boolean | null; + why?: "dead-air" | "idle" | "other" | null; + reason?: string | null; + corner?: "tl" | "tr" | "bl" | "br" | null; +}; export type GapOp = { add: Span } | { remove: Span } | { set: Span[] } | { edit: GapEdit }; @@ -179,6 +185,8 @@ export function useGapEditor({ const said = [ "mark" in change ? `its mark ${change.mark === true ? "on" : change.mark === false ? "off" : "as the clip's"}` : null, "why" in change ? `cut for ${change.why === "dead-air" ? "dead air" : change.why ?? "no reason given"}` : null, + "reason" in change ? (change.reason ? `its mark says “${change.reason}”` : "its own words dropped") : null, + "corner" in change ? `its mark at ${change.corner ?? "the clip's corner"}` : null, ].filter(Boolean).join(", "); return run({ edit }, next, `the gap ${fmt(g.from)}–${fmt(g.to)}: ${said}`); }, diff --git a/umtool/components/projects/review/GapMarkChip.tsx b/umtool/components/projects/review/GapMarkChip.tsx @@ -1,12 +1,14 @@ "use client"; import { useEffect, useRef, useState } from "react"; +import { GAP_CUE_LOOK } 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 gap-mark.mjs's, in -// the frame's proportions: Plex Mono Bold at 2.4 % of the frame's short side, the box's border 0.35 of that, the -// inset 2.6 %, light text on a dark box at 55 %, the text and its box faded together. Nothing to press. +// 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. // // box where the mark stands inside the frame (Play's deck: the footage's rect, in % of the frame); the whole // frame when absent @@ -15,6 +17,12 @@ import { useEffect, useRef, useState } from "react"; 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, @@ -44,7 +52,8 @@ export default function GapMarkChip({ const k = Math.min(size.w / aspect, size.h); frame = { left: (size.w - k * aspect) / 2, top: (size.h - k) / 2, width: k * aspect, height: k }; } - const inset = "2.6cqmin"; + const L = GAP_CUE_LOOK; + const inset = `${L.inset * 100}cqmin`; const at: React.CSSProperties = { [corner.startsWith("t") ? "top" : "bottom"]: inset, [corner.endsWith("l") ? "left" : "right"]: inset, @@ -57,12 +66,16 @@ 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] text-white" + className="absolute whitespace-nowrap font-mono font-bold leading-[1.2]" style={{ ...at, - fontSize: "max(9px, 2.4cqmin)", - padding: "max(3px, 0.84cqmin)", - background: "rgba(0, 0, 0, 0.55)", + 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", opacity: mark.alpha, }} > diff --git a/umtool/components/projects/review/playCore.tsx b/umtool/components/projects/review/playCore.tsx @@ -385,7 +385,7 @@ export function PlayStage({ core, basic = false, plainClassName }: { core: PlayC [item, cueEntry], ); const gapMark = gapMarks.length ? gapMarkAt(gapMarks, t) : null; - const gapCorner = gapMarkCorner(cueEntry?.gapCue?.corner, { deck: !!doc }); + const gapCorner = gapMarkCorner(gapMark?.corner ?? cueEntry?.gapCue?.corner, { deck: !!doc }); 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 ? ( diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md @@ -53,7 +53,7 @@ Inbox cannot disagree about what is wrong with one. | `reads <project> replace <from> <to> [--case] [--word] [--say-only] [--only <id>,…] [--dry-run] [--json]` · `reads <project> undo [--dry-run]` | **Replace**, two scopes, neither synthesizing and neither touching what is shown (operator ruling 3; `lib/report/readsReplace.mjs`): **these reads** rewrites the matched reads' spoken text in ONE undo point (`auto-before-reads-replace`) — a post's script (marked for reading), a screen line's said-as (made when it has none), a card's narration; a parent, the quoted or a linked post is said as shown (only `--say-only` changes it); a recorded read is never replaced; the preview names what a changed post loses (its approval, as a new script takes it), a card's review verdict given on the old words, and what the build would refuse (refused whole). **`--say-only`: everywhere, from now on** — a pronunciation entry (`posts say add`'s writer): every read of a post says it that way; whole words; never a card. `undo` takes back the newest replace -- These reads only while the draft is still exactly what it left (a re-read landing or any edit since: refused, said why), an Everywhere back to the entry it changed (its spoken form and note) or the entry it added removed; `--dry-run` says which, or why not. A flag a subcommand does not take is refused; `--` ends the flags. | | `reads <project> reread [--stale] [--only <id>,…] [--wait [--timeout <s>]] [--dry-run] [--json]` · `reads <project> queue [--stop] [--retry <id>] [--json]` · `reads <project> pick --new|--old [--only <id>,…] [--dry-run] [--json]` | **the re-read queue** (`lib/report/readsQueue.mjs`): the stale reads (or `--only` those) queued on the app's durable queue (`umtool queue ls`), ONE step per item in cut order, none waiting on another — `reads <p> reread --one <item> --only <ids>`, which judges the item again and runs the item's bench command (`readAgainArgv.mjs`: a post's take as the bench asks it, `--bench-slurs`; a thread piece's `--for`/`--tuned … reading:next`; a card's own reading), the tuning a plain press asks (only what the line owned). The editor's `tts-file` jobs, one at a time; render mode holds them. A re-read joins its list UNPICKED. `queue` says each row's state and, in one sentence, why they wait; `--stop` cancels what has not started; `--retry` puts one back. `pick --new` makes every unpicked re-read play, `--old` goes back to what played before (a card: its old words and reading) — one undo point. | | `present <project> [--take <take> \| --cut] [--json] [--public] [--open] [--url <origin>]` | **present mode**: the cut as slides, navigated like a deck (`/projects/<p>/present`) — prints the address and every slide (its kind, id — a post's `<channel>/<id>`, a clip's id, `section-<n>`, `day-<YYYY-MM-DD>` — date, words and censor counts); `--json` the payload (each post's card as Play draws it and its censor data by kind, each clip's spans, the dividers); `--public` the payload a public page would carry (censored, no reveal data); `--open` opens it; `<address>#<slide id>` opens a slide ([knobs.md](knobs.md#present-mode-the-cut-as-slides-navigated-like-a-deck)) | -| `set <project> <clip> key=value …` | a clip's **knobs**: `claim.at` `claim.hold` `claim.stamp` `claim.count` `claim.label` (the first mark's, or `--mark <id>`'s), its **marks** `mark.add=<verdict>[@<sec>]` `mark.remove=<id>` `mark.verdict=<verdict>` `marks=<json>`, `audio.offset` `audio.gain` `audio.fadeIn` `audio.fadeOut`, its picture's **blur** `blur.on=true` `blur.caption=…` `blur.strength` `blur.from` `blur.to` (`blur.on=` clears it; [knobs.md](knobs.md#a-clips-picture-blurred)), its **effects** `fx.zoom=<json>` `fx.receipts=<json>` `fx.punch=…` `fx.quote` `fx.punchIn=<json>` `fx.speakers=<json>` (`fx=<json>` all of them, `fx=` clears them; a shot is a file in the project; [knobs.md](knobs.md#effects)), its **gaps** `gap.add=12.3-15.1` `gap.remove=<sec>` `gaps=…` and a gap's own `gap.mark=<sec>:on|off|default` `gap.why=<sec>:dead-air|other|default`, the **mark at its gaps' joins** `gapCue.mark=true` `gapCue.min` `gapCue.corner` `gapCue.label` over the project's `render.gapCue` (`gapCue=` clears it; [knobs.md](knobs.md#gaps-inside-a-clip)); on ANY entry (a post item, a still, a clip) `hideModules=diet,streak`, `shelfNote='…'` and `chapter='…'` (its name in the chapter list, one line of at most 100 characters; `chapter=` none); `--take <t>` writes the entry knobs into that take's patch; `key=` clears one ([knobs.md](knobs.md#marks)) | +| `set <project> <clip> key=value …` | a clip's **knobs**: `claim.at` `claim.hold` `claim.stamp` `claim.count` `claim.label` (the first mark's, or `--mark <id>`'s), its **marks** `mark.add=<verdict>[@<sec>]` `mark.remove=<id>` `mark.verdict=<verdict>` `marks=<json>`, `audio.offset` `audio.gain` `audio.fadeIn` `audio.fadeOut`, its picture's **blur** `blur.on=true` `blur.caption=…` `blur.strength` `blur.from` `blur.to` (`blur.on=` clears it; [knobs.md](knobs.md#a-clips-picture-blurred)), its **effects** `fx.zoom=<json>` `fx.receipts=<json>` `fx.punch=…` `fx.quote` `fx.punchIn=<json>` `fx.speakers=<json>` (`fx=<json>` all of them, `fx=` clears them; a shot is a file in the project; [knobs.md](knobs.md#effects)), its **gaps** `gap.add=12.3-15.1` `gap.remove=<sec>` `gaps=…` and a gap's own `gap.mark=<sec>:on|off|default` `gap.why=<sec>:dead-air|idle|other|default` `gap.reason=<sec>:<words>` (its mark says them) `gap.corner=<sec>:tl|tr|bl|br|default`, the **mark at its gaps' joins** `gapCue.mark=true` `gapCue.min` `gapCue.corner` `gapCue.label` over the project's `render.gapCue` (`gapCue=` clears it; [knobs.md](knobs.md#gaps-inside-a-clip)); on ANY entry (a post item, a still, a clip) `hideModules=diet,streak`, `shelfNote='…'` and `chapter='…'` (its name in the chapter list, one line of at most 100 characters; `chapter=` none); `--take <t>` writes the entry knobs into that take's patch; `key=` clears one ([knobs.md](knobs.md#marks)) | | `intro <project> [key=value …] [--off] [--json]` · `intro <project> --take <take> --off\|--on` | **the intro** the cut opens on (`render.intro`): with no key, prints it as written, what the cut opens with (a `title-card`'s words resolved) and each version's on/off; `key=value` writes it through the look writer (`style` `seconds` 3.5–8 `mark` `ground` `sound` (`false` silent) `site` `title` `lines` (`a\|b`, ≤ 3) and the brand's keys; `key=` clears one; a new intro starts as `boot-dark`); `--off` takes it off the cut; `--take <t> --off` that version opens on no intro (its patch's `render.intro: null`), `--on` on the cut's again. **Exit 1** on a value the build refuses ([knobs.md](knobs.md#the-intro-played-and-edited)) | | `look <project> key=value … [--unset render.<key>]… [--take <t>]` | the cut's **knobs** (`--take <t>`: the `deck.*` keys given are set on that take -- its patch, an undo point of its own, the project's manifest untouched; the other knobs are the project's): `factcheck.stamp.*`, `factcheck.verdicts.<V>.stampLabel\|label\|color`, `deck.markers=<json>`, `deck.markerLayout`, `variants=<json>`, and the look's keys — `mode=basic\|deck` (the footage alone, [knobs.md](knobs.md#basic-output-the-footage-alone)) and `basic=<json>` (its fades), `gapCue=<json>` (the mark at the joins clips' gaps leave, `{"mark":true}`; [knobs.md](knobs.md#gaps-inside-a-clip)) among them ([knobs.md](knobs.md)) **The deck on, legacy keys off** (`updateRenderKeys`, one write, an undo point `revisions/…auto-render-keys…` first): `chrome.layout=deck` turns the deck on (render.chrome created when the cut has none: engine hyperframes, an empty deck), `--unset render.<key>` (repeatable) drops a legacy render key -- only `rail` `chromeEngine` `railEngine` `chromeRegions` `claimSchedule` `wordmark` `title` `finale` `cut`; the deck beside the old rail is refused in the build's words unless the same command drops it; deck.* keys in the same command land after the chrome exists. Another key named: **exit 2** | | `variants <project> [--take <t>] [--list] [--json]` | **Make variants**: the encode ladder of the build (or of a take's); `--list` what was made and the build's sync report, each clip's lag (past a frame flagged) ([knobs.md](knobs.md)) | diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -40,8 +40,8 @@ that generates it ([notes.md](notes.md)). | `chapter` — the entry's name in the chapter list (`out/…chapters`, `youtube.txt`, `umtool export --format chapters`): one line of at most 100 characters. An authored `chapter` wins over the entry's on-screen title (under the deck) and the line derived from its record; without one the list is as before. Any entry, a post item too | — | `umtool set <p> <entry> chapter='The weigh-in'` (`chapter=` clears it; `--take <t>` writes the take's patch, the project's manifest untouched) | — | | `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 puts it back (`G`: 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` (`…:default` drops it) | `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)) | — | `umtool set <p> <clip> gapCue.mark=true gapCue.corner=tr` (`gapCue=` clears it) | `PUT /api/report/window {project, clip, token, gapCue}` | +| `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}` | `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 @@ -213,24 +213,41 @@ seconds (`report-to-video/gaps.mjs` is the rule and both clocks). phrase: gaps are not applied there (noted). Absent or `[]`, the render is byte for byte what it was. - **The bench** draws each gap as a hatched band on the waveform (and on the cue rail); every playback there skips them as the cut will. Gap writes go through the one window writer at once (not drafted like the edges), each an undo - point (`auto-before-gaps`: `umtool timeline <p> undo`), and **Undo** beside them writes the list back. + point (`auto-before-gaps`: `umtool timeline <p> undo`), and **Undo** beside them writes the list back. A click on a + band picks the gap (outlined): the row under the waveform shows its seconds, how it shows (skip; fast-forward is not + built yet), its **mark** (as the clip's, on, off), **why** (dead air, idle, other), its own words, its **corner**, + what its mark will say, and **Remove**. Beside it, the clip's **mark at joins** (as the project's, on, off), **from** + (its `min`), **corner** and **label**. Every control writes what its CLI twin writes (each one's tooltip names it): + a gap's through `gapEdit`, the clip's through `gapCue`, each an undo point. A reel beat's band keeps its old click + (it puts the gap back): a beat's gap has no settings. - **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 - shows a small `» 27 s` (`label`, `{s}` the time skipped, from a minute `1:12`) near a corner of the footage for - 1.1 s -- up over 0.15 s, held, down over 0.35 s; IBM Plex Mono Bold, 2.4 % of the frame's short side (26 px at 1080), - the palette's fg on its bg at 55 %; no sound. Joins less than 1.1 s apart are ONE mark saying their seconds - together. It is drawn into the clip's segment after its hidden regions and its blur (chrome over the footage, + 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. + 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 picture top left (framed, quote), its foot (split) or the safe area's top right (full bleed, desktop); a hidden - region up while the mark is, or a code, under that corner moves it to the next free one. Precedence: a gap's own - `mark` 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`). A gap may - say `why` (`dead-air` | `other`): nothing draws it yet. Turning it on re-renders only the segments of clips with a + region up while the mark is, or a code, under that corner moves it to the next free one. **The automatic corner + knows only our own hidden regions and codes, not what a stream burned into its picture** (a chat bottom left, a + banner, a camera box): on such footage set the corner -- the clip's `gapCue.corner`, or one gap's own `corner` + (`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), Play the cut (not yet); a trailer beat cut across a marked join plays the master's - mark. The record says where each was drawn (`gapMarks` in `segments/<id>.cut.json`). + 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. The pages do not move it off a hidden region or a code as the build does, and a vertical cut's page + uses the deck's or the plain cut's corner. The record says where each was drawn (`gapMarks` in `segments/<id>.cut.json`). - **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. @@ -3090,9 +3107,9 @@ The full reference is [Gaps inside a clip](#gaps-inside-a-clip) (the mark at the | `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`), at most 40 characters · default `» {s}` | `umtool look <p> gapCue='{"label":"{s} later"}'` | +| `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` | `mark` `true` · `false` (over the clip's and the project's); `why` `dead-air` · `other` (draws nothing yet) | `umtool set <p> <clip> gap.mark=12.3:off gap.why=12.3:dead-air` (`…:default` drops it) | +| 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 diff --git a/umtool/lib/cli/groups.mjs b/umtool/lib/cli/groups.mjs @@ -347,7 +347,7 @@ export const GROUPS = [ ], docs: [ ["`set <project> <clip> key=value …`", - "a clip's **knobs**: `claim.at` `claim.hold` `claim.stamp` `claim.count` `claim.label` (the first mark's, or `--mark <id>`'s), its **marks** `mark.add=<verdict>[@<sec>]` `mark.remove=<id>` `mark.verdict=<verdict>` `marks=<json>`, `audio.offset` `audio.gain` `audio.fadeIn` `audio.fadeOut`, its picture's **blur** `blur.on=true` `blur.caption=…` `blur.strength` `blur.from` `blur.to` (`blur.on=` clears it; [knobs.md](knobs.md#a-clips-picture-blurred)), its **effects** `fx.zoom=<json>` `fx.receipts=<json>` `fx.punch=…` `fx.quote` `fx.punchIn=<json>` `fx.speakers=<json>` (`fx=<json>` all of them, `fx=` clears them; a shot is a file in the project; [knobs.md](knobs.md#effects)), its **gaps** `gap.add=12.3-15.1` `gap.remove=<sec>` `gaps=…` and a gap's own `gap.mark=<sec>:on|off|default` `gap.why=<sec>:dead-air|other|default`, the **mark at its gaps' joins** `gapCue.mark=true` `gapCue.min` `gapCue.corner` `gapCue.label` over the project's `render.gapCue` (`gapCue=` clears it; [knobs.md](knobs.md#gaps-inside-a-clip)); on ANY entry (a post item, a still, a clip) `hideModules=diet,streak`, `shelfNote='…'` and `chapter='…'` (its name in the chapter list, one line of at most 100 characters; `chapter=` none); `--take <t>` writes the entry knobs into that take's patch; `key=` clears one ([knobs.md](knobs.md#marks))"], + "a clip's **knobs**: `claim.at` `claim.hold` `claim.stamp` `claim.count` `claim.label` (the first mark's, or `--mark <id>`'s), its **marks** `mark.add=<verdict>[@<sec>]` `mark.remove=<id>` `mark.verdict=<verdict>` `marks=<json>`, `audio.offset` `audio.gain` `audio.fadeIn` `audio.fadeOut`, its picture's **blur** `blur.on=true` `blur.caption=…` `blur.strength` `blur.from` `blur.to` (`blur.on=` clears it; [knobs.md](knobs.md#a-clips-picture-blurred)), its **effects** `fx.zoom=<json>` `fx.receipts=<json>` `fx.punch=…` `fx.quote` `fx.punchIn=<json>` `fx.speakers=<json>` (`fx=<json>` all of them, `fx=` clears them; a shot is a file in the project; [knobs.md](knobs.md#effects)), its **gaps** `gap.add=12.3-15.1` `gap.remove=<sec>` `gaps=…` and a gap's own `gap.mark=<sec>:on|off|default` `gap.why=<sec>:dead-air|idle|other|default` `gap.reason=<sec>:<words>` (its mark says them) `gap.corner=<sec>:tl|tr|bl|br|default`, the **mark at its gaps' joins** `gapCue.mark=true` `gapCue.min` `gapCue.corner` `gapCue.label` over the project's `render.gapCue` (`gapCue=` clears it; [knobs.md](knobs.md#gaps-inside-a-clip)); on ANY entry (a post item, a still, a clip) `hideModules=diet,streak`, `shelfNote='…'` and `chapter='…'` (its name in the chapter list, one line of at most 100 characters; `chapter=` none); `--take <t>` writes the entry knobs into that take's patch; `key=` clears one ([knobs.md](knobs.md#marks))"], ], }, { diff --git a/umtool/lib/report/gapCueView.mjs b/umtool/lib/report/gapCueView.mjs @@ -7,7 +7,7 @@ // the clock the page plays, and which mark is up at a second of it. // // PURE and dependency-free beyond those two: the client bundle takes it. -import { GAP_CUE_MOTION, gapCueAlpha, gapCueText, gapCues, gapMarkOn } from "yt-dlp-transcript-common/lib/report/gapCue.mjs"; +import { GAP_CUE_MOTION, gapCueAlpha, gapCueText, gapCues, gapMarkOn, gapOwnSays } from "yt-dlp-transcript-common/lib/report/gapCue.mjs"; import { gappedLength, gapsWithin, offsetIn } from "umtool-report-to-video/gaps"; const fin = (v) => typeof v === "number" && Number.isFinite(v); @@ -51,9 +51,9 @@ export function clipGapMarks({ cue, gaps, from, to }) { const inside = gapsWithin(gaps ?? [], from, to).sort((a, b) => a.from - b.from); const joins = inside.map((g) => { const own = ownOf(gaps, g.from, g.to); - return { at: offsetIn(g.from, from, inside), seconds: g.to - g.from, mark: own.length ? own.some((c) => gapMarkOn(cue, c)) : cue.mark }; + return { at: offsetIn(g.from, from, inside), seconds: g.to - g.from, mark: own.length ? own.some((c) => gapMarkOn(cue, c)) : cue.mark, ...gapOwnSays(own) }; }); - return gapCues(joins, { min: cue.min, seconds: gappedLength(from, to, inside) }).map((c) => ({ ...c, text: gapCueText(c.seconds, cue.label) })); + return gapCues(joins, { min: cue.min, seconds: gappedLength(from, to, inside) }).map((c) => ({ ...c, text: gapCueText(c.seconds, cue.label, c.why) })); } /** @@ -83,9 +83,9 @@ export function clipPlayClock({ gaps, from, to }, src) { export function playGapMarks(joins, { cue, entryGaps = [], playEnd }) { const marked = (joins ?? []).map((j) => { const own = ownOf(entryGaps, j.from, j.to); - return { at: j.at, seconds: j.to - j.from, mark: own.length ? own.some((c) => gapMarkOn(cue, c)) : cue.mark }; + return { at: j.at, seconds: j.to - j.from, mark: own.length ? own.some((c) => gapMarkOn(cue, c)) : cue.mark, ...gapOwnSays(own) }; }); - return gapCues(marked, { min: cue.min, seconds: fin(playEnd) ? playEnd : Infinity }).map((c) => ({ ...c, text: gapCueText(c.seconds, cue.label) })); + return gapCues(marked, { min: cue.min, seconds: fin(playEnd) ? playEnd : Infinity }).map((c) => ({ ...c, text: gapCueText(c.seconds, cue.label, c.why) })); } /** @@ -93,15 +93,17 @@ export function playGapMarks(joins, { cue, entryGaps = [], playEnd }) { * null when none is. `peak` is its opacity at full, for a page that fades the * text and its box together, as drawtext's alpha does. * - * @param {Array<{ at: number, until: number, text: string }>} marks + * `corner` is the mark's own (its gap's), when it has one. + * + * @param {Array<{ at: number, until: number, text: string, corner?: string }>} marks * @param {number | null | undefined} t - * @returns {{ text: string, alpha: number, at: number, until: number } | null} + * @returns {{ text: string, alpha: number, at: number, until: number, corner?: string } | null} */ export function gapMarkAt(marks, t) { if (!fin(t)) return null; for (const m of marks ?? []) { const alpha = gapCueAlpha(/** @type {number} */ (t), m); - if (alpha > 0) return { text: m.text, alpha, at: m.at, until: m.until }; + if (alpha > 0) return { text: m.text, alpha, at: m.at, until: m.until, ...(m.corner ? { corner: m.corner } : {}) }; } return null; } diff --git a/umtool/lib/report/gapCueView.test.mjs b/umtool/lib/report/gapCueView.test.mjs @@ -80,3 +80,17 @@ test("gapMarkCorner: a clip's corner as it says; auto the layout's (the deck's f assert.equal(gapMarkCorner("auto", { deck: false }), "tl"); assert.equal(gapMarkCorner(undefined, { deck: false }), "tl"); }); + +test("the reason and the gap's own corner reach the page's mark as the build's (operator rulings, 20 Nov)", () => { + const gaps = [{ from: 3.5, to: 5.5, why: "dead-air", corner: "tr" }, { from: 7, to: 7.6 }]; + const cue = clipGapCueOf({ gapCue: { mark: true, min: 0.5 } }, { gaps }); + const page = clipGapMarks({ cue, gaps, from: 0.5, to: 12 }); + assert.deepEqual(page.map((m) => [m.text, m.corner ?? null]), [["» 2 s · dead air", "tr"], ["» 1 s", null]]); + const segGaps = gaps.map((g) => ({ from: g.from - 0.5, to: g.to - 0.5 })); + const build = segmentGapMarks({ render: { gapCue: { mark: true, min: 0.5 } }, entry: { type: "clip", gaps }, seconds: 11.5 - 2.6, joins: segmentGapJoins({ segGaps, clipGaps: gaps, segStart: 0.5, cue }) }); + assert.deepEqual(page, build); + assert.equal(gapMarkAt(page, 3.5).corner, "tr"); + // Play: the gap's own words over its why. + const play = playGapMarks([{ at: 13, from: 3.5, to: 5.5 }], { cue, entryGaps: [{ from: 3.5, to: 5.5, why: "other", reason: "ad break" }], playEnd: 20 }); + assert.equal(play[0].text, "» 2 s · ad break"); +}); diff --git a/umtool/lib/report/gaps-writer.test.mjs b/umtool/lib/report/gaps-writer.test.mjs @@ -160,6 +160,15 @@ test("the mark at the joins: a gap's own mark and why (gap.mark=, gap.why=, gapE assert.deepEqual((await clip(dir, "c01")).gaps, [{ from: 15, to: 17 }, { from: 20, to: 21, why: "dead-air" }, { from: 24, to: 25 }]); assert.equal(await run(name, "c01", "gap.mark=19:on"), 1, "no gap at 19"); assert.equal(await run(name, "c01", "gap.why=20.5:boring"), 2); + // Its reason (the mark says it) and its own corner (lane gap-cue rulings, 20 Nov); `<sec>:` drops the words. + assert.equal(await run(name, "c01", "gap.why=16:idle", "gap.reason=16:walks off", "gap.corner=16:tr"), 0); + assert.deepEqual((await clip(dir, "c01")).gaps[0], { from: 15, to: 17, why: "idle", reason: "walks off", corner: "tr" }); + assert.match(lines.at(-1), /15–17 \(idle, "walks off", at tr\)/); + assert.equal(await run(name, "c01", "gap.reason=16:", "gap.corner=16:default", "gap.why=16:dead-air"), 0); + assert.deepEqual((await clip(dir, "c01")).gaps[0], { from: 15, to: 17, why: "dead-air" }); + assert.equal(await run(name, "c01", "gap.corner=16:middle"), 2); + assert.equal(await run(name, "c01", "gap.reason=16:a reason far too long for one small mark"), 1); + await assert.rejects(updateClip(dir, "c01", { gaps: [{ from: 15, to: 17, corner: "middle" }] }), /corner is one of tl, tr, bl, br/); // The clip's own settings, merged; one cleared; all cleared. assert.equal(await run(name, "c01", "gapCue.mark=true", "gapCue.corner=tr", "gapCue.label={s} later"), 0); assert.deepEqual((await clip(dir, "c01")).gapCue, { mark: true, corner: "tr", label: "{s} later" }); diff --git a/umtool/lib/report/knobsCli.mjs b/umtool/lib/report/knobsCli.mjs @@ -54,7 +54,9 @@ const REVIEW_KEYS = ["verdict", "reason", "rejectNote", "correction"]; /** The clip's effects (report-to-video fx.mjs): `fx=<json>` whole (`fx=` clears it), `fx.<field>=<json>` one field. */ const FX_KEYS = ["fx", ...FX_ENTRY_FIELDS.map((k) => `fx.${k}`)]; /** Seconds taken out of the clip's middle (gaps.mjs): the whole list, one added, one removed. */ -const GAP_KEYS = ["gaps", "gap.add", "gap.remove", "gap.mark", "gap.why"]; +const GAP_KEYS = ["gaps", "gap.add", "gap.remove", "gap.mark", "gap.why", "gap.reason", "gap.corner"]; +/** 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 VERTICAL_SET_KEYS = Object.freeze(["vertical", "vertical.crop", "vertical.layout", "vertical.aspect", "vertical.crops"]); @@ -137,7 +139,9 @@ export const SET_USAGE = [ " the cut, ≥ 0.2 s, 0.5 s kept between); gap.remove=<sec> the gap holding it; gaps=12.3-15.1,20-20.6 (or", " a JSON list of {from,to}) the whole list, `gaps=` none. The same as `umtool window --gap/--gap-remove/--gaps`.", " gap.mark=<sec>:on|off|default marks (or not) the join of the gap holding <sec>, over the clip's and the", - " project's; gap.why=<sec>:dead-air|other|default says what it was cut for (its seconds never move).", + " project's; gap.why=<sec>:dead-air|idle|other|default says what it was cut for (its mark says \"dead air\",", + " \"idle\"); gap.reason=<sec>:<a few words> says them instead (`<sec>:` drops them); gap.corner=<sec>:tl|tr|bl|br|default", + " 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.", ].join("\n"); @@ -302,7 +306,7 @@ export async function setCommand(args, { root = REPORTS_ROOT, out = (s) => conso } if (GAP_KEYS.includes(key)) { if (key === "gap.add") (entryPatch.gapAdd ??= []).push(String(value ?? "")); - else if (key === "gap.mark" || key === "gap.why") (entryPatch.gapEdit ??= []).push(gapEditOf(key, value)); + else if (GAP_OWN_SET_KEYS.includes(key)) (entryPatch.gapEdit ??= []).push(gapEditOf(key, value)); else if (key === "gap.remove") entryPatch.gapRemove = Number(value); else if (value === null || (Array.isArray(value) && !value.length)) entryPatch.gaps = []; else if (Array.isArray(value)) entryPatch.gaps = value; @@ -439,7 +443,7 @@ export async function setCommand(args, { root = REPORTS_ROOT, out = (s) => conso if ("promo" in results) out(`${clipId}: promo ${results.promo === false ? "none (it ends without the card)" : results.promo ? JSON.stringify(results.promo) : "the cut's"}`); if ("name" in results) out(`${clipId}: name ${results.name ? JSON.stringify(results.name) : "its title's slug"}`); if ("gaps" in results) { - const own = (g) => [typeof g.mark === "boolean" ? `mark ${g.mark ? "on" : "off"}` : "", g.why ?? ""].filter(Boolean).join(", "); + const own = (g) => [typeof g.mark === "boolean" ? `mark ${g.mark ? "on" : "off"}` : "", g.why ?? "", g.reason ? `"${g.reason}"` : "", g.corner ? `at ${g.corner}` : ""].filter(Boolean).join(", "); out(`${clipId}: ${results.gaps.length ? `gaps ${results.gaps.map((g) => `${g.from}–${g.to}${own(g) ? ` (${own(g)})` : ""}`).join(", ")}` : "no gaps (the cut plays whole)"}`); } if ("gapCue" in results) out(`${clipId}: gapCue ${results.gapCue ? JSON.stringify(results.gapCue) : "the project's (render.gapCue)"}`); @@ -462,23 +466,29 @@ export async function setCommand(args, { root = REPORTS_ROOT, out = (s) => conso const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v); /** - * `gap.mark=<sec>:on|off|default` / `gap.why=<sec>:dead-air|other|default` as a window writer's `gapEdit`. + * `gap.mark=<sec>:on|off|default`, `gap.why=<sec>:dead-air|idle|other|default`, + * `gap.reason=<sec>:<words>` (`<sec>:` drops it) and `gap.corner=<sec>:tl|tr|bl|br|default` + * as a window writer's `gapEdit`. * * @param {string} key * @param {unknown} value */ export function gapEditOf(key, value) { - const m = String(value ?? "").trim().match(/^(\d+(?:\.\d+)?)\s*:\s*([a-z-]+)$/i); - const field = key === "gap.mark" ? "mark" : "why"; - const choices = field === "mark" ? "on|off|default" : "dead-air|other|default"; + const field = key.slice("gap.".length); + const choices = { mark: "on|off|default", why: "dead-air|idle|other|default", reason: "<a few words>", corner: "tl|tr|bl|br|default" }[field] ?? ""; + const m = String(value ?? "").match(/^\s*(\d+(?:\.\d+)?)\s*:(.*)$/); if (!m) throw new CliError(`${key}=${value ?? ""}: <a source second inside the gap>:${choices}`); - const word = m[2].toLowerCase(); + const at = Number(m[1]); + // The reason is words, whatever they are: the writer checks them (gaps.mjs). + if (field === "reason") return { at, reason: m[2].trim() ? m[2].trim() : null }; + const word = m[2].trim().toLowerCase(); let v; if (word === "default") v = null; else if (field === "mark" && (word === "on" || word === "off")) v = word === "on"; - else if (field === "why" && (word === "dead-air" || word === "other")) v = word; - else throw new CliError(`${key}=${value}: ${word} is not one of ${choices}`); - return { at: Number(m[1]), [field]: v }; + else if (field === "why" && ["dead-air", "idle", "other"].includes(word)) v = word; + else if (field === "corner" && ["tl", "tr", "bl", "br"].includes(word)) v = word; + else throw new CliError(`${key}=${value}: ${word || "nothing"} is not one of ${choices}`); + return { at, [field]: v }; } /** diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs @@ -717,6 +717,12 @@ export function patchClipEntry(manifest, clipId, patch, { edit = "trim", now = n // A gap's own mark and why (common gapCue.mjs) ride along, checked as they are. if (g.mark !== undefined && g.mark !== null && typeof g.mark !== "boolean") throw new Error(`gaps[${k}].mark is true or false`); if (g.why !== undefined && g.why !== null && !GAP_WHY_VALUES.includes(g.why)) throw new Error(`gaps[${k}].why is one of ${GAP_WHY_VALUES.join(", ")}`); + // Its reason and corner (lane gap-cue): kept only when well formed, so one that is not is refused here. + for (const key of ["reason", "corner"]) { + if (g[key] !== undefined && g[key] !== null && gapOwnKeys({ [key]: g[key] })[key] === undefined) { + throw new Error(validateGaps({ type: "clip", id: "gap", start: from, end: to, gaps: [{ from, to, [key]: g[key] }] }, `gaps[${k}]`).find((e) => e.includes(`.${key} `)) ?? `gaps[${k}].${key} is not one`); + } + } return { from, to, ...gapOwnKeys(g) }; }), }); diff --git a/umtool/report-to-video/build-video.mjs b/umtool/report-to-video/build-video.mjs @@ -1857,7 +1857,7 @@ async function buildClipSegment(entry, meta, render, dirs, opts, chrome, nodes, files.push(file); } cutRecord.gapMarks = gapMarks.map((m, k) => ({ at: m.at, until: m.until, seconds: m.seconds, ...(m.count > 1 ? { count: m.count } : {}), text: m.text, corner: places[k].corner })); - return gapMarkFilters({ marks: gapMarks, places, files, size, palette: render.palette }); + return gapMarkFilters({ marks: gapMarks, places, files, size }); }; /** The picture's hidden regions as rects to keep the mark off: the source `sw` × `sh` (its `region`) shown in `dest`. */ const censorAvoid = (sw, sh, dest, region = null) => diff --git a/umtool/report-to-video/gap-mark.mjs b/umtool/report-to-video/gap-mark.mjs @@ -15,18 +15,20 @@ // 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. // -// THE LOOK. IBM Plex Mono Bold (the vendored face: the same mark whatever the -// brand), 2.4 % of the frame's short side (26 px at 1080), the palette's fg on -// its bg at 55 %, faded in and out by `alpha` (GAP_CUE_MOTION), which fades -// the box with the text. No sound. +// THE LOOK is common gapCue.mjs's GAP_CUE_LOOK (umtool's pages draw it from the +// same numbers): IBM Plex Mono Bold (the vendored face: the same mark whatever +// the brand), 3 % of the frame's short side (32 px at 1080), light text on a +// near-opaque dark box inside a light 2 px border (operator, 20 Nov: "more +// visible and readable with a border"), faded in and out by `alpha` +// (GAP_CUE_MOTION), which fades the box and its border with the text. The +// border is a second drawtext under the first: the same text, unseen, its box +// 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_MOTION, clipGapCueOf, gapCueText, gapCues, gapMarkOn } from "yt-dlp-transcript-common/lib/report/gapCue.mjs"; +import { GAP_CUE_LOOK, GAP_CUE_MOTION, clipGapCueOf, gapCueText, gapCues, gapMarkOn, gapOwnSays } from "yt-dlp-transcript-common/lib/report/gapCue.mjs"; import { MONO_BOLD_FONT_FILE } from "./brand.mjs"; import { offsetIn } from "./gaps.mjs"; -/** The box behind the text, at full: the palette's bg at this opacity. */ -export const GAP_MARK_BOX_ALPHA = 0.55; /** Plex Mono's advance, in ems: every glyph the same width. */ const ADVANCE = 0.6; @@ -34,18 +36,27 @@ const EPS = 1e-6; const f3 = (n) => Number(n.toFixed(3)).toString(); /** - * The mark's sizes for a `W` × `H` frame: its font size, the box's border - * round the text, and the inset from the box it stands in. + * 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) { +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 * 0.024)); - return { fontSize, border: Math.round(fontSize * 0.35), inset: Math.max(8, Math.round(s * 0.026)) }; + 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, at `size` (gapMarkSize). */ +/** The rect a text of `chars` characters takes with its box and border, at `size` (gapMarkSize). */ export function gapMarkRect(chars, size) { - return { w: Math.ceil(chars * ADVANCE * size.fontSize) + 2 * size.border, h: Math.ceil(size.fontSize * 1.2) + 2 * size.border }; + 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 }; } /** @@ -58,7 +69,11 @@ export function gapMarkRect(chars, size) { * * @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 - * @returns {Array<{ at: number, seconds: number, mark: boolean }>} + * 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; @@ -67,7 +82,7 @@ export function segmentGapJoins({ segGaps, clipGaps, segStart, cue, toReal = (t) 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 }; + 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; }); @@ -83,7 +98,7 @@ export function segmentGapJoins({ segGaps, clipGaps, segStart, cue, toReal = (t) */ 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) })); + return gapCues(joins, { min: cue.min, seconds }).map((c) => ({ ...c, text: gapCueText(c.seconds, cue.label, c.why) })); } const CORNERS = ["tl", "tr", "bl", "br"]; @@ -111,15 +126,17 @@ const overlaps = (a, b) => a.x < b.x + b.w && b.x < a.x + a.w && a.y < b.y + b.h * 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 }>, box: { x: number, y: number, w: number, h: number }, + * @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 * @returns {Array<{ corner: string, rect: { x: number, y: number, w: number, h: number } }>} */ export function gapMarkPlaces({ marks, box, want, prefer, size, avoid = [], busy = [] }) { - const first = want === "auto" || !CORNERS.includes(want) ? prefer : want; - const order = [first, ...CORNERS.filter((c) => c !== first)]; 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)]; const r = gapMarkRect([...m.text].length, size); const up = avoid.filter((a) => (a.from ?? -Infinity) < m.until - EPS && (a.to ?? Infinity) > m.at + EPS); for (const c of order) { @@ -163,30 +180,28 @@ export const centredIn = (box, fitted) => ({ x: box.x + Math.floor((box.w - fitt * filter escaping) -- one comma-joined chain, or "" for none. * * @param {{ marks: Array<{ at: number, until: number }>, places: Array<{ rect: { x: number, y: number } }>, - * files: string[], size: ReturnType<typeof gapMarkSize>, palette?: { fg?: string, bg?: string }, font?: string }} o + * files: string[], size: ReturnType<typeof gapMarkSize>, look?: Partial<typeof GAP_CUE_LOOK>, font?: string }} o */ -export function gapMarkFilters({ marks, places, files, size, palette = {}, font = MONO_BOLD_FONT_FILE }) { +export function gapMarkFilters({ marks, places, files, size, look = GAP_CUE_LOOK, font = MONO_BOLD_FONT_FILE }) { const M = GAP_CUE_MOTION; + const L = { ...GAP_CUE_LOOK, ...look }; + const hex = (c) => String(c).replace(/^#/, "0x"); + const stroke = size.stroke ?? 0; return marks - .map((m, k) => { + .flatMap((m, k) => { const a = f3(m.at); const b = f3(m.until); // gapCueAlpha (common gapCue.mjs), for ffmpeg: up over `in`, down over `out`, `peak` between. const alpha = `${M.peak}*clip(min((t-${a})/${M.in},(${b}-t)/${M.out}),0,1)`; const { x, y } = places[k].rect; + const at = [`x=${x + stroke + size.border}`, `y=${y + stroke + size.border}`, `alpha='${alpha}'`, `enable='between(t,${a},${b})'`]; + const text = (fontcolor, boxcolor, boxborderw) => + [`drawtext=textfile='${files[k]}'`, `fontfile='${font}'`, `fontsize=${size.fontSize}`, `fontcolor=${fontcolor}`, "box=1", `boxcolor=${boxcolor}`, `boxborderw=${boxborderw}`, ...at].join(":"); return [ - `drawtext=textfile='${files[k]}'`, - `fontfile='${font}'`, - `fontsize=${size.fontSize}`, - `fontcolor=${palette.fg ?? "white"}`, - "box=1", - `boxcolor=${palette.bg ?? "black"}@${GAP_MARK_BOX_ALPHA}`, - `boxborderw=${size.border}`, - `x=${x + size.border}`, - `y=${y + size.border}`, - `alpha='${alpha}'`, - `enable='between(t,${a},${b})'`, - ].join(":"); + // The border: the same text, unseen, its box the stroke's colour and wider by the stroke. + ...(stroke > 0 ? [text(`${hex(L.fg)}@0`, `${hex(L.strokeColor)}@${L.strokeAlpha}`, size.border + stroke)] : []), + text(hex(L.fg), `${hex(L.box)}@${L.boxAlpha}`, size.border), + ]; }) .join(","); } diff --git a/umtool/report-to-video/gap-mark.test.mjs b/umtool/report-to-video/gap-mark.test.mjs @@ -33,11 +33,12 @@ test("the marks: the clip's settings over the project's; under min none; the lab test("the place: the layout's corner, inset; off a hidden region while it is up; never a busy corner", () => { const size = gapMarkSize(1920, 1080); - assert.deepEqual(size, { fontSize: 26, border: 9, inset: 28 }); + // GAP_CUE_LOOK (operator, 20 Nov: bigger, a border): 3 % of 1080, the box 0.38 em round it, a 2 px stroke. + assert.deepEqual(size, { fontSize: 32, border: 12, stroke: 2, inset: 28 }); const box = { x: 100, y: 50, w: 1600, h: 900 }; const marks = [{ at: 2, until: 3.1, text: "» 27 s" }, { at: 9, until: 10.1, text: "» 27 s" }]; const r = gapMarkRect(6, size); - assert.deepEqual(r, { w: 94 + 18, h: 32 + 18 }, "six Plex Mono glyphs at 26 px and the border round them"); + assert.deepEqual(r, { w: 116 + 28, h: 39 + 28 }, "six Plex Mono glyphs at 32 px, the box and the stroke round them"); const bl = gapMarkPlaces({ marks, box, want: "auto", prefer: "bl", size }); assert.deepEqual(bl.map((p) => p.corner), ["bl", "bl"]); assert.deepEqual(bl[0].rect, { x: 128, y: 50 + 900 - 28 - r.h, w: r.w, h: r.h }); @@ -47,6 +48,20 @@ test("the place: the layout's corner, inset; off a hidden region while it is up; // An asked corner wins unless something is under it; a busy corner is skipped. assert.deepEqual(gapMarkPlaces({ marks, box, want: "br", prefer: "bl", size }).map((p) => p.corner), ["br", "br"]); assert.deepEqual(gapMarkPlaces({ marks, box, want: "auto", prefer: "tl", size, busy: ["tl"] }).map((p) => p.corner), ["tr", "tr"]); + // A mark's own corner (its gap's, operator 20 Nov: a stream's layout can change inside one clip) over the clip's. + assert.deepEqual(gapMarkPlaces({ marks: [{ ...marks[0], corner: "tr" }, marks[1]], box, want: "br", prefer: "bl", size }).map((p) => p.corner), ["tr", "br"]); +}); + +test("the reason and the corner a join's own gaps give: the reason when they all say the same, the first corner", () => { + const joins = segmentGapJoins({ + segGaps: [{ from: 10, to: 37 }, { from: 50, to: 53 }], + clipGaps: [{ from: 110, to: 137, why: "dead-air", corner: "tr" }, { from: 150, to: 153, why: "other" }], + segStart: 100, + cue: { mark: true }, + }); + assert.deepEqual(joins, [{ at: 10, seconds: 27, mark: true, why: "dead air", corner: "tr" }, { at: 23, seconds: 3, mark: true }]); + const marks = segmentGapMarks({ render: { gapCue: { mark: true } }, entry: { type: "clip" }, joins, seconds: 40 }); + assert.deepEqual(marks.map((m) => [m.text, m.corner ?? null]), [["» 27 s · dead air", "tr"], ["» 3 s", null]]); }); test("a hidden region in the frame: its source fractions through the fit, its seconds on the segment's clock", () => { @@ -59,18 +74,19 @@ test("a hidden region in the frame: its source fractions through the fit, its se assert.deepEqual([b.x, b.w, b.from, b.to], [0, 853, null, null]); }); -test("the filters: one drawtext per mark, its text from its file, faded by alpha over its seconds", () => { +test("the filters: per mark its border (the text unseen, a wider box) then its text on its box, faded by alpha over its seconds", () => { const size = gapMarkSize(1920, 1080); const f = gapMarkFilters({ marks: [{ at: 2, until: 3.1 }], places: [{ rect: { x: 128, y: 970 } }], files: ["/out/segments/c1.gapmark-0.txt"], - size, palette: { fg: "#ffffff", bg: "#12100c" }, font: "/fonts/Mono.ttf", + size, font: "/fonts/Mono.ttf", }); + const at = "x=142:y=984:alpha='0.9*clip(min((t-2)/0.15,(3.1-t)/0.35),0,1)':enable='between(t,2,3.1)'"; assert.equal( f, - "drawtext=textfile='/out/segments/c1.gapmark-0.txt':fontfile='/fonts/Mono.ttf':fontsize=26:fontcolor=#ffffff:box=1:boxcolor=#12100c@0.55:boxborderw=9:" + - "x=137:y=979:alpha='0.9*clip(min((t-2)/0.15,(3.1-t)/0.35),0,1)':enable='between(t,2,3.1)'", + `drawtext=textfile='/out/segments/c1.gapmark-0.txt':fontfile='/fonts/Mono.ttf':fontsize=32:fontcolor=0xffffff@0:box=1:boxcolor=0xffffff@0.9:boxborderw=14:${at},` + + `drawtext=textfile='/out/segments/c1.gapmark-0.txt':fontfile='/fonts/Mono.ttf':fontsize=32:fontcolor=0xffffff:box=1:boxcolor=0x101010@0.86:boxborderw=12:${at}`, ); assert.equal(gapMarkFilters({ marks: [], places: [], files: [], size }), ""); }); diff --git a/umtool/report-to-video/gaps-render.test.mjs b/umtool/report-to-video/gaps-render.test.mjs @@ -210,9 +210,10 @@ test("the gap mark ON draws '» 1 s' at the join over its life, in the record; o // The join: 2 s into c1 (1–3 plays, 3–4 is out). Up 1.1 s, at the plain cut's top left. assert.deepEqual(rec.gapMarks, [{ at: 2, until: 3.1, seconds: 1, text: "» 1 s", corner: "tl" }]); near(await probeDuration(p.seg("c1"), FPS), 4, 1 / FPS + 1e-6, "the mark adds no time"); - // Its box at 320×180: inset 8, a 12 px face with a 4 px border -- darker than the grey while it is up. - const y = cropLumas(p.seg("c1"), 8, 8, 40, 22); - const yPlain = cropLumas(plain.seg("c1"), 8, 8, 40, 22); + // Its box at 320×180 (GAP_CUE_LOOK): inset 8, a 2 px light border, then the dark box (5 px above a 12 px face): + // the box's top inside the border is darker than the grey while it is up. + const y = cropLumas(p.seg("c1"), 11, 10, 30, 4); + const yPlain = cropLumas(plain.seg("c1"), 11, 10, 30, 4); const at = (arr, t) => arr[Math.floor(t * FPS)]; near(at(y, 1.5), at(yPlain, 1.5), 1, "before the join: as plain"); assert.ok(at(yPlain, 2.5) - at(y, 2.5) > 20, `up at 2.5 s (${at(y, 2.5)} vs ${at(yPlain, 2.5)})`); diff --git a/umtool/report-to-video/gaps.mjs b/umtool/report-to-video/gaps.mjs @@ -43,12 +43,25 @@ export const GAP_FADE = 0.025; const fin = (v) => typeof v === "number" && Number.isFinite(v); /** What a gap was cut for (common gapCue.mjs GAP_WHY: kept here too, this module imports nothing). */ -export const GAP_WHY_VALUES = Object.freeze(["dead-air", "other"]); -/** A gap's own keys beyond its seconds, kept as they are: `mark` (a boolean) and `why` (GAP_WHY_VALUES). */ +export const GAP_WHY_VALUES = Object.freeze(["dead-air", "idle", "other"]); +/** A gap's own reason, its longest (common gapCue.mjs GAP_REASON_MAX). */ +export const GAP_REASON_MAX = 24; +/** The corners a gap's own mark may stand at (common gapCue.mjs GAP_OWN_CORNERS). */ +export const GAP_CORNER_VALUES = Object.freeze(["tl", "tr", "bl", "br"]); +/** Is `v` a gap's reason: one line of words, 1 to GAP_REASON_MAX characters once trimmed. */ +const reasonOk = (v) => typeof v === "string" && v.trim().length > 0 && v.trim().length <= GAP_REASON_MAX && !/[\n\r[\]{}]/.test(v); +/** + * A gap's own keys beyond its seconds, kept as they are: `mark` (a boolean), `why` (GAP_WHY_VALUES), `reason` + * (a few words its mark says, reasonOk) and `corner` (GAP_CORNER_VALUES: where its mark stands). + */ export const gapOwnKeys = (x) => ({ ...(typeof x?.mark === "boolean" ? { mark: x.mark } : {}), ...(GAP_WHY_VALUES.includes(x?.why) ? { why: x.why } : {}), + ...(reasonOk(x?.reason) ? { reason: x.reason.trim() } : {}), + ...(GAP_CORNER_VALUES.includes(x?.corner) ? { corner: x.corner } : {}), }); +/** The sentence for a reason that is not one. */ +const REASON_RULE = `a few words, at most ${GAP_REASON_MAX} characters on one line (no [ ] { })`; const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v); const EPS = 1e-6; /** The writer's tolerance for a stored 2 dp edge (manifest.mjs WIN_EPS). */ @@ -142,6 +155,8 @@ export function validateGaps(entry, where = `timeline entry ${entry?.id ?? "?"}` } if (g.mark !== undefined && typeof g.mark !== "boolean") errors.push(`${where}.gaps[${k}].mark is true (mark its join) or false, not ${JSON.stringify(g.mark)}`); if (g.why !== undefined && !GAP_WHY_VALUES.includes(g.why)) errors.push(`${where}.gaps[${k}].why is one of ${GAP_WHY_VALUES.join(", ")}, not ${JSON.stringify(g.why)}`); + if (g.reason !== undefined && !reasonOk(g.reason)) errors.push(`${where}.gaps[${k}].reason is ${REASON_RULE}, not ${JSON.stringify(g.reason)}`); + if (g.corner !== undefined && !GAP_CORNER_VALUES.includes(g.corner)) errors.push(`${where}.gaps[${k}].corner is one of ${GAP_CORNER_VALUES.join(", ")}, not ${JSON.stringify(g.corner)}`); ok.push({ ...g, k }); }); if (errors.length) return errors; @@ -523,13 +538,13 @@ export function recordGaps(record) { * (merged with any gap it touches or overlaps), `remove` the gap holding a * source second (or starting nearest it, within `tolerance`), or `set` the * whole list (`[]` clears it), or `edit` the gap holding a source second - * (`{ at, mark?, why? }`: each set, or null to drop it -- its seconds never + * (`{ at, mark?, why?, reason?, corner? }`: each set, or null to drop it -- its seconds never * move). Returns the new list, normalized; the caller validates it on the * entry. * * @param {Array<{ from: number, to: number }>} gaps the clip's now * @param {{ add?: { from: number, to: number }, remove?: number, set?: Array<{ from: number, to: number }>, - * edit?: { at: number, mark?: boolean | null, why?: string | null } }} op + * edit?: { at: number, mark?: boolean | null, why?: string | null, reason?: string | null, corner?: string | null } }} op * @param {{ tolerance?: number }} [opts] */ export function editGaps(gaps, op, { tolerance = 0.05 } = {}) { @@ -561,13 +576,15 @@ export function editGaps(gaps, op, { tolerance = 0.05 } = {}) { const k = list.findIndex((g) => t >= g.from - tolerance && t <= g.to + tolerance); if (k < 0) throw new Error(`no gap at ${t}${list.length ? ` (gaps: ${list.map((g) => `${g.from}–${g.to}`).join(", ")})` : " — the clip has none"}`); const next = { ...list[k] }; - for (const key of ["mark", "why"]) { + for (const key of ["mark", "why", "reason", "corner"]) { if (!(key in op.edit)) continue; const v = op.edit[key]; - if (v === null || v === undefined) delete next[key]; + if (v === null || v === undefined || (key === "reason" && typeof v === "string" && !v.trim())) delete next[key]; else if (key === "mark" && typeof v !== "boolean") throw new Error(`a gap's mark is on, off or default (got ${JSON.stringify(v)})`); else if (key === "why" && !GAP_WHY_VALUES.includes(v)) throw new Error(`a gap's why is ${GAP_WHY_VALUES.join(", ")} or default (got ${JSON.stringify(v)})`); - else next[key] = v; + else if (key === "reason" && !reasonOk(v)) throw new Error(`a gap's reason is ${REASON_RULE} (got ${JSON.stringify(v)})`); + else if (key === "corner" && !GAP_CORNER_VALUES.includes(v)) throw new Error(`a gap's corner is ${GAP_CORNER_VALUES.join(", ")} or default (got ${JSON.stringify(v)})`); + else next[key] = key === "reason" ? v.trim() : v; } list = list.map((g, i) => (i === k ? next : g)); } diff --git a/umtool/report-to-video/gaps.test.mjs b/umtool/report-to-video/gaps.test.mjs @@ -149,12 +149,18 @@ test("a gap's own mark and why (common gapCue.mjs) ride along: kept, checked, ed assert.deepEqual(normalizeGaps([{ from: 105.004, to: 107, why: "other" }]), [{ from: 105, to: 107, why: "other" }]); assert.deepEqual(validateGaps({ ...CLIP, gaps: own }), []); const errs = validateGaps({ ...CLIP, gaps: [{ from: 105, to: 107, mark: "no" }, { from: 110, to: 110.5, why: "boring" }] }, "c1"); - assert.deepEqual(errs, ['c1.gaps[0].mark is true (mark its join) or false, not "no"', 'c1.gaps[1].why is one of dead-air, other, not "boring"']); + assert.deepEqual(errs, ['c1.gaps[0].mark is true (mark its join) or false, not "no"', 'c1.gaps[1].why is one of dead-air, idle, other, not "boring"']); assert.deepEqual(editGaps(own, { edit: { at: 106, mark: true } }), [{ from: 105, to: 107, mark: true, why: "dead-air" }, { from: 110, to: 110.5 }]); assert.deepEqual(editGaps(own, { edit: { at: 106, mark: null, why: null } }), [{ from: 105, to: 107 }, { from: 110, to: 110.5 }]); assert.deepEqual(editGaps(own, { edit: { at: 110.2, why: "other" } })[1], { from: 110, to: 110.5, why: "other" }); assert.throws(() => editGaps(own, { edit: { at: 108, mark: true } }), /no gap at 108/); - assert.throws(() => editGaps(own, { edit: { at: 106, why: "boring" } }), /why is dead-air, other or default/); + assert.throws(() => editGaps(own, { edit: { at: 106, why: "boring" } }), /why is dead-air, idle, other or default/); + // Its reason (a few words its mark says) and its corner (where its mark stands), lane gap-cue rulings 20 Nov. + assert.deepEqual(editGaps(own, { edit: { at: 106, reason: " ad break ", corner: "tr" } })[0], { from: 105, to: 107, mark: false, why: "dead-air", reason: "ad break", corner: "tr" }); + assert.deepEqual(editGaps([{ from: 105, to: 107, reason: "x" }], { edit: { at: 106, reason: "" } })[0], { from: 105, to: 107 }, "empty words drop it"); + assert.throws(() => editGaps(own, { edit: { at: 106, reason: "a reason far too long for one small mark" } }), /at most 24 characters/); + assert.throws(() => editGaps(own, { edit: { at: 106, corner: "middle" } }), /corner is tl, tr, bl, br or default/); + assert.match(validateGaps({ ...CLIP, gaps: [{ from: 105, to: 107, reason: "[x]" }] }, "c1").join(), /reason is a few words/); // Adding a gap elsewhere keeps the others' own keys. assert.deepEqual(editGaps(own, { add: { from: 114, to: 115 } })[0], own[0]); }); diff --git a/umtool/report-to-video/modules/gap-cue.mjs b/umtool/report-to-video/modules/gap-cue.mjs @@ -3,7 +3,7 @@ // 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, validateGapCue } from "yt-dlp-transcript-common/lib/report/gapCue.mjs"; +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"; export default defineModule({ @@ -23,7 +23,7 @@ export default defineModule({ { 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: "label", type: "text", label: "Label ({s} is the time skipped)", default: GAP_CUE_DEFAULTS.label }, + { 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", @@ -32,9 +32,9 @@ export default defineModule({ ["`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.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\`), at most ${GAP_CUE_LABEL_MAX} characters · default \`${GAP_CUE_DEFAULTS.label}\``, "`umtool look <p> gapCue='{\"label\":\"{s} later\"}'`"], + ["`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 gap's `mark`, `why`", "`mark` `true` · `false` (over the clip's and the project's); `why` `dead-air` · `other` (draws nothing yet)", "`umtool set <p> <clip> gap.mark=12.3:off gap.why=12.3:dead-air` (`…:default` drops it)"], + ["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"], ], }, });