// THE GAP MARK (module `gap-cue`, region `gap-cue`): "» 27 s" at the join a // clip's gap leaves. Wherever a deck is drawn it is THIS page -- one short page // per mark, laid at its own second over the frame (chrome-gap-cue.mjs; the // marks, their seconds and their place: the schedule's `gapCue` slice, // gap-cue-slice.mjs) -- so turning the mark on, moving it, restyling it or // changing its words re-renders chrome only, never a clip segment. Where no // chrome is laid over the picture (the plain cut, --no-chrome, a bare vertical // cut, --desktop, --short) the build draws it into the clip's segment instead // (gap-mark.mjs, gapMarkByChrome says which); never both on one frame. The // settings, the label and the timing: common lib/report/gapCue.mjs. import path from "node:path"; import { GAP_CUE_BORDER_FALLBACK, GAP_CUE_CORNERS, GAP_CUE_DEFAULTS, GAP_CUE_LABEL_MAX, GAP_CUE_MIN, GAP_CUE_PLACES, GAP_REASON_MAX, validateGapCue, } from "yt-dlp-transcript-common/lib/report/gapCue.mjs"; import { snapWindow } from "../deck.mjs"; import { GAP_CUE_ID_RE, gapCueHtml, gapCueWindows } from "../chrome-gap-cue.mjs"; import { assertRegion, defineModule } from "./contract.mjs"; export default defineModule({ id: "gap-cue", version: 2, // Over the popup posts (30), under the stamps (40). z: 35, kind: "overlay-window", slot: "footage", // Its form in the stacked vertical deck (vertical-deck.mjs): over the picture. vertical: { slot: "picture" }, title: "Gap mark", summary: "A small mark at each join a clip's gap leaves, saying how much was skipped: a page per mark, at its own seconds.", configKey: "render.gapCue", defaults: { ...GAP_CUE_DEFAULTS }, validate: (_value, { manifest }) => validateGapCue(manifest), ui: [ { key: "mark", type: "boolean", label: "Mark the gaps' joins", default: GAP_CUE_DEFAULTS.mark }, { key: "min", type: "number", min: GAP_CUE_MIN.min, max: GAP_CUE_MIN.max, step: 0.5, label: "Shortest gap marked (s)", default: GAP_CUE_DEFAULTS.min }, { key: "place", type: "enum", options: [...GAP_CUE_PLACES], label: "Where (over the footage, or in the deck)", default: GAP_CUE_DEFAULTS.place }, { key: "corner", type: "enum", options: [...GAP_CUE_CORNERS], label: "Corner (over the footage)", default: GAP_CUE_DEFAULTS.corner }, { key: "label", type: "text", label: "Label ({s} the time skipped, {why} the reason, [ ] only with one)", default: GAP_CUE_DEFAULTS.label }, { key: "border", type: "text", label: "Border (accent: the deck's accent colour, or #rrggbb)", default: GAP_CUE_DEFAULTS.border }, ], docs: { heading: "Gap mark", intro: "The full reference is [Gaps inside a clip](#gaps-inside-a-clip) (the mark at the join). Under a deck the mark is this module's page, one per mark; with no chrome over the picture it is drawn into the clip's segment.", rows: [ ["`render.gapCue.mark`", "`true` · `false` · default `false` (off: every cut renders as it did)", "`umtool look

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

gapCue='{\"min\":4}'`"], ["`render.gapCue.place`", "`footage` (over the footage, at its corner) · `deck` (in the deck's band, at the end of the source line, left of the QR -- over the footage where the row has no room, in the stacked vertical deck and in a cut with no deck; the page measures the line in its own faces and never stands the mark on it) · default `footage`", "`umtool look

gapCue='{\"place\":\"deck\"}'`"], ["`render.gapCue.corner`", "`auto` (the layout's free corner) · `tl` · `tr` · `bl` · `br` · default `auto`", "`umtool look

gapCue='{\"corner\":\"br\"}'`"], ["`render.gapCue.label`", `text holding \`{s}\` (the time skipped: \`27 s\`, from a minute \`1:12\`) and maybe \`{why}\` (the gap's reason); a part in \`[ ]\` is drawn only when the gap has one; at most ${GAP_CUE_LABEL_MAX} characters · default \`${GAP_CUE_DEFAULTS.label}\` (\`» 27 s\`, \`» 26 s · dead air\`)`, "`umtool look

gapCue='{\"label\":\"{s} later\"}'`"], ["`render.gapCue.border`", `\`accent\` (the deck's accent colour, \`render.palette.accent\`: its rule and dots; a render with none ${GAP_CUE_BORDER_FALLBACK}) · a \`#rrggbb\` colour · default \`accent\` (the border at full opacity, the box near-black at 90 %, the text white)`, "`umtool look

gapCue='{\"border\":\"#3aa0ff\"}'`"], ["a clip's `gapCue`", "the same keys, over the project's", "`umtool set

gapCue.mark=false gapCue.corner=tr gapCue.place=deck gapCue.border='#3aa0ff'` (`gapCue=` clears them)"], ["a gap's `mark`, `why`, `reason`, `corner`", `\`mark\` \`true\` · \`false\` (over the clip's and the project's); \`why\` \`dead-air\` · \`idle\` · \`other\` (the mark says "dead air", "idle", nothing); \`reason\` its own words, 1-${GAP_REASON_MAX} characters, said instead; \`corner\` \`tl\` · \`tr\` · \`bl\` · \`br\` (its mark there, over the clip's)`, "`umtool set

gap.mark=12.3:off gap.why=12.3:dead-air gap.reason=12.3:walks off gap.corner=12.3:tr` (`…:default`, `gap.reason=12.3:` drop one) · the bench: click the gap's band"], ], }, region: "gap-cue", workers: "narrow", noun: "the gap mark's", on: (schedule) => gapCueWindows(schedule).length > 0, check: (schedule) => (gapCueWindows(schedule).length ? null : "the gap mark needs a clip with a marked gap under a deck (render.gapCue.mark, or a clip's or a gap's own)"), window(schedule, { window = null, segment = null, fps, total }) { const want = window ?? gapCueWindows(schedule).find((w) => w.segment === segment); if (!want) throw new Error(segment ? `no gap mark ${segment} in this schedule` : "the gap mark needs a window (or a mark id)"); if (!GAP_CUE_ID_RE.test(String(want.segment))) throw new Error(`gap-cue: ${want.segment} is not a mark id`); return snapWindow({ segment: want.segment, from: want.from, to: want.to }, { fps, total }); }, names: ({ preview, window }) => ({ project: `gap-cue-${preview ? "preview-" : ""}${window.segment}`, stem: `gap-cue-${window.segment}` }), async page(ctx) { // The deck's own bold face: the mark is part of the deck's family. const fonts = await ctx.fonts({ regular: "DeckSans", bold: "DeckSansBold" }, { strict: true }); return gapCueHtml(ctx.schedule, ctx.render, ctx.window, { fonts }); }, /** * One window per mark, each over the whole frame (a mark stands over the footage or in the deck's band, and Play * lays a layer's windows at one geometry), snapped to the frame grid. `shift`/`clip` as popup-posts' regions. */ regions(schedule, { render, outDir, shift = 0, clip = null }) { const fps = Number(schedule.fps ?? render.fps); const W = render.width ?? 1920; const H = render.height ?? 1080; return gapCueWindows(schedule) .map((w) => ({ w, s: snapWindow({ segment: w.segment, from: w.from, to: w.to }, { fps, total: schedule.total }) })) .filter(({ s }) => !clip || (s.from < clip.at + clip.dur && s.to > clip.at)) .map(({ w, s }) => assertRegion({ name: "gap-cue", segment: s.segment, window: { segment: w.segment, from: w.from, to: w.to }, frames: path.join(outDir, "chrome", `gap-cue-${s.segment}-frames`), x: 0, y: 0, width: W, height: H, offset: s.from - shift, frameCount: s.frames, }, "window")); }, preview: (_slice, { render }) => ({ region: "gap-cue", geometry: { x: 0, y: 0, width: render.width ?? 1920, height: render.height ?? 1080 } }), // Its page is its live preview: Play the cut seeks it in the cut's seconds (contract.mjs, PLAY). play: { clock: "cut", ready: "gap-cue:ready" }, // A window of the cut: frame n is cut time `from` + n / fps; its frames are reused unless its text, rect, look or seconds change. frameKeys: { data: "gap-cue-data", omit: ["init", "cues", "from", "dur"], offset: "from" }, });