Archilyzer · Source

archilyzer

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

commit 3bab265f906eb1e28f44905ca83e0814dea9423f
parent 8c427629033859ab6169c6f17bbc5a2db0af3eb8
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed, 21 Oct 2026 10:55:24 -0400

report-video: the blur slide's push is closed-form (no st()/ld() race) and smears with dblur, not stepped taps

xfade evaluates a custom expression on slice threads that share one
expression's registers, so pushExpr's stored offsets were another row's by
the time they were read: black speckle across white areas on the seam's
frames (white into white: 288,779 dark pixels before, 0 after). The nine
in-expression taps sat many pixels apart at any real travel and drew stepped
copies of text; the smear is now dblur trailing the motion in four bands
sized from the push's speed, and the edge a push uncovers is mirrored, not
clamped into a streaked strip.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mplans/FACTS.md | 11+++++++----
Mumtool/docs/report-video.md | 12+++++++-----
Mumtool/report-to-video/transition.mjs | 117++++++++++++++++++++++++++++++++++++++++++++++---------------------------------
Mumtool/report-to-video/transition.test.mjs | 50+++++++++++++++++++++++++++++++++++++++-----------
4 files changed, 121 insertions(+), 69 deletions(-)

diff --git a/plans/FACTS.md b/plans/FACTS.md @@ -11026,10 +11026,13 @@ parsed to 0 cues, indexing the video textless) is CLOSED by `200a3105` (transcri `roomShade` (the rule on the unsnapped cut; no words → nominal D + 0.1 tail); toggle `[data-clip-room]`. Look panel: `[data-look-room-tail]`, `[data-look-room-head]`. - **The blur slide** (`transitionStyle: "blurslide"`; the operator's "way quicker, tactile, subtle" revision replaced - a012e9ff's full-width slideright + gblur): xfade `transition=custom:expr='…'` from `pushExpr(render, D)` — P 1→0; - ease-out cubic e; A sampled at X − travel·W·e, B at X + travel·W·(1−e); 9 taps (1..5..1)/25 at half of - blur·3·travel/(D·fps)/2·W·(1−t)² ; smoothstep crossfade over t∈[0.1,0.7]; per plane via `PLANE` (a0/a1/a2, b0/b1/b2 — - a0 alone is luma). `render.slide {travel 0–0.5 (0.08), blur 0–2 (0.5), grain 0–20 (2)}` (`SLIDE_DEFAULTS`, + a012e9ff's full-width slideright + gblur): xfade `transition=custom:expr='…'` from `pushExpr(render)` — P 1→0; + closed form, NO `st()`/`ld()` (xfade's slice threads share one expression's registers: white→white drew black + speckle on 2 of 5 seam frames, fixed 2026-10-21); A sampled at |X − travel·W·(1−P³)|, B at W−1−|W−1−X−travel·W·P³| + (mirrored, not clamped); smoothstep crossfade over p∈[0.1,0.7]; per plane via `PLANE` (a0/a1/a2, b0/b1/b2 — a0 + alone is luma). Smear: `dblur=angle=180` (one-sided, tail ≈ 2·radius) in 4 bands over the join on each plain-join + edge, radius = blur·3·travel·W·(1−p)²/(D·fps)/2 at the band's middle, < 0.5 px dropped (the old 9 in-expression + taps drew stepped copies). `render.slide {travel 0–0.5 (0.08), blur 0–2 (0.5), grain 0–20 (2)}` (`SLIDE_DEFAULTS`, `validateSlide` inside `validateTransitionStyle`; `slide` is a LOOK_KEY). Grain: `noise=alls=<grain>:allf=t+u` on the D/2 nearest the seam of each plain-join edge (`blurSlideEdges`, the segment's own `t`). diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md @@ -1350,11 +1350,13 @@ again. The Look panel's **Room at the clips' edges** sets `render.room`. "blur slide"): a quick, eased push — the outgoing clip nudges right by `render.slide.travel` of the width while the next settles in from the left (cubic ease-out: fast, then a soft landing), the two crossfading under a -smoothstep; the picture is smeared along the motion by nine taps spaced by the -moment's speed (most at the start, none as it lands), and the frames nearest -the seam take a light temporal grain. One xfade custom expression -(`transition.mjs` `pushExpr`) plus the grain on each clip's edge, in the clip's -own time. `render.slide` = `{travel: 0.08, blur: 0.5, grain: 2}` by default +smoothstep; the edge a push uncovers is mirrored, the picture is smeared +behind the motion (ffmpeg's `dblur`, in four bands sized from the push's speed: +most at the start, none as it lands), and the frames nearest the seam take a +light temporal grain. One closed-form xfade custom expression (`transition.mjs` +`pushExpr` — no `st()`/`ld()`: xfade's slice threads share them, which drew +black speckle on white) plus the smear and grain on each clip's edge, in the +clip's own time. `render.slide` = `{travel: 0.08, blur: 0.5, grain: 2}` by default (travel 0–0.5 of the width, blur 0–2, grain 0–20; 0 turns either off); the length is `render.transition` (the seed's 0.22 s). A dip, a THEN/NOW wipe and a whip keep their own look. With room at both edges the slide runs over muted picture. diff --git a/umtool/report-to-video/transition.mjs b/umtool/report-to-video/transition.mjs @@ -8,10 +8,19 @@ // "blurslide" is not an xfade name: a quick, eased push. The outgoing clip // nudges right by `render.slide.travel` of the width while the next settles in // from the left (cubic ease-out: it moves fast and lands softly), the two -// crossfading under a smoothstep; the picture is smeared along the motion by -// five taps spaced by the moment's speed (most at the start, none as it lands), -// and the frames nearest the seam take a light temporal grain. One xfade -// custom expression (`pushExpr`) plus the grain on each clip's edge. +// crossfading under a smoothstep; the frame edge a push uncovers is MIRRORED, +// not clamped (a clamped read repeats the edge column into a streaked strip). +// The smear along the motion is ffmpeg's directional blur (`dblur`) on each +// clip's seam frames, in bands whose radius follows the push's speed (most at +// the start, none as it lands), and those frames take a light temporal grain. +// +// The expression is closed-form -- no st()/ld(). xfade evaluates a custom +// expression on slice threads that share ONE expression's registers, so a +// stored value is another row's by the time it is read: measured, white into +// white came out with tens of thousands of black pixels on two of five seam +// frames (2026-10-21, ffmpeg 9.0.2). The smear used to be nine taps spaced +// by the push's speed in the same expression; at any real travel the taps +// sat many pixels apart and drew stepped copies of text instead of a blur. // // The style list, the slide's knobs and their checks are the look's rules // (common lib/report/look.mjs, release 38): re-exported here, so the writer, @@ -29,60 +38,70 @@ export { } from "yt-dlp-transcript-common/lib/report/look.mjs"; /** - * The push as an xfade custom expression, for a join `D` seconds long at `fps`. - * P runs 1 -> 0 over the join; a0/a1/a2 and b0/b1/b2 read the two inputs' - * planes (each plane's own W), so it works on any planar format. + * The push as an xfade custom expression. P runs 1 -> 0 over the join, so the + * ease-out's progress 1-(1-p)^3 is 1-P^3: the outgoing picture is read + * travel*W*(1-P^3) to the left, the incoming travel*W*P^3 to the right, each + * mirrored at the frame edge, mixed by a smoothstep over p in [0.1, 0.7]. + * a0/a1/a2 and b0/b1/b2 read the two inputs' planes (each plane's own W), so + * it works on any planar format. `D` is unused (the smear is `blurSlideEdges`) + * and kept for the callers' signature. */ -export function pushExpr(render, D) { - const { travel, blur } = slideOf(render); - const frames = Math.max(1, D * (render?.fps ?? 30)); - // Tap spacing at peak speed (fraction of W): ease-out cubic's speed at the - // start is 3x the mean, a frame's mean travel is travel / frames. - const k = (blur * 3 * travel) / frames / 2; +export function pushExpr(render, _D) { + const { travel } = slideOf(render); const pl = (c, x) => `if(eq(PLANE,0),${c}0(${x},Y),if(eq(PLANE,1),${c}1(${x},Y),${c}2(${x},Y)))`; - const A = (o) => pl("a", `X-ld(2)${o}`); - const B = (o) => pl("b", `X+ld(3)${o}`); - // Nine taps, triangle-weighted (1..5..1)/25, half the spacing of five: the - // same smear without stepped copies on sharp edges (text, UI). - const taps = (f) => { - if (!(k > 0)) return f(""); - const t = []; - for (let j = -4; j <= 4; j += 1) { - const w = 5 - Math.abs(j); - const o = j === 0 ? "" : `${j < 0 ? "-" : "+"}${Math.abs(j) / 2}*ld(4)`; - t.push(w === 1 ? f(o) : `${w}*${f(o)}`); - } - return `(${t.join("+")})/25`; - }; - return [ - "st(0,1-P)", - "st(1,1-pow(1-ld(0),3))", - `st(2,${travel}*W*ld(1))`, - `st(3,${travel}*W*(1-ld(1)))`, - `st(4,${k.toFixed(5)}*W*pow(1-ld(0),2))`, - "st(5,clip((ld(0)-0.1)/0.6,0,1))", - "st(5,ld(5)*ld(5)*(3-2*ld(5)))", - `${taps(A)}*(1-ld(5))+${taps(B)}*ld(5)`, - ].join(";"); + const A = pl("a", `abs(X-${travel}*W*(1-P*P*P))`); + const B = pl("b", `W-1-abs(W-1-X-${travel}*W*P*P*P)`); + const m = "clip((0.9-P)/0.6,0,1)"; + return `${A}+(${B}-${A})*${m}*${m}*(3-2*${m})`; } /** The xfade transition for a plain join `D` seconds long. */ export const xfadeTransitionOf = (render, D = render?.transition ?? 0.5) => transitionStyleOf(render) === "blurslide" ? `custom:expr='${pushExpr(render, D)}'` : transitionStyleOf(render); +/** The smear's bands across a join: each a quarter of it, blurred at its middle's speed. */ +const SMEAR_BANDS = 4; + /** - * The grain a blur slide puts on one input `d` seconds long, joined over `D` - * seconds: the half-join nearest the seam on its tail when a plain join follows - * it, on its head when one precedes it. "" when the style is not "blurslide", - * `D` is 0, the grain is 0, or neither edge is a plain join (a dip, a wipe and - * a whip keep their own look). + * The seam filters a blur slide puts on one input `d` seconds long, joined + * over `D` seconds: the smear (`dblur` trailing the motion, in SMEAR_BANDS + * bands sized from the push's speed at each band's middle, a band under half + * a pixel left out) over the join's whole length, + * and the grain on the half-join nearest the seam -- on its tail when a plain + * join follows it, on its head when one precedes it. "" when the style is not + * "blurslide", `D` is 0, smear and grain are both 0, or neither edge is a + * plain join (a dip, a wipe and a whip keep their own look). */ export function blurSlideEdges(d, D, render, { tail = false, head = false } = {}) { - const { grain } = slideOf(render); - if (transitionStyleOf(render) !== "blurslide" || !(D > 0) || !(grain > 0) || (!tail && !head)) return ""; - const w = D / 2; - const parts = []; - if (tail) parts.push(`gte(t,${(d - w).toFixed(3)})`); - if (head) parts.push(`lt(t,${w.toFixed(3)})`); - return `noise=alls=${Math.round(grain)}:allf=t+u:enable='${parts.join("+")}'`; + const { grain, blur, travel } = slideOf(render); + if (transitionStyleOf(render) !== "blurslide" || !(D > 0) || (!tail && !head)) return ""; + const out = []; + const frames = Math.max(1, D * (render?.fps ?? 30)); + const W = render?.width ?? 1920; + const f3 = (n) => n.toFixed(3); + if (blur > 0 && travel > 0) { + for (let k = 0; k < SMEAR_BANDS; k += 1) { + const p = (k + 0.5) / SMEAR_BANDS; + // Both pictures move right at 3*travel*W*(1-p)^2/frames px per frame + // (1-P^3 and P^3 alike). dblur is one-sided -- an exponential tail on + // the `angle` side about 2*radius long (measured on a 1-px line) -- so + // angle 180 trails each picture's motion, and blur 1 (a frame's travel) + // is a radius of half the speed. + const r = (blur * 3 * travel * W * (1 - p) ** 2) / frames / 2; + if (r < 0.5) continue; + const [p0, p1] = [k / SMEAR_BANDS, (k + 1) / SMEAR_BANDS]; + const win = []; + if (tail) win.push(`between(t,${f3(d - D + p0 * D)},${f3(d - D + p1 * D)})`); + if (head) win.push(`between(t,${f3(p0 * D)},${f3(p1 * D)})`); + out.push(`dblur=angle=180:radius=${r.toFixed(1)}:enable='${win.join("+")}'`); + } + } + if (grain > 0) { + const w = D / 2; + const parts = []; + if (tail) parts.push(`gte(t,${f3(d - w)})`); + if (head) parts.push(`lt(t,${f3(w)})`); + out.push(`noise=alls=${Math.round(grain)}:allf=t+u:enable='${parts.join("+")}'`); + } + return out.join(","); } diff --git a/umtool/report-to-video/transition.test.mjs b/umtool/report-to-video/transition.test.mjs @@ -42,29 +42,57 @@ test("validateTransitionStyle: xfade's names only", () => { assert.equal(validateTransitionStyle({ render: { transitionStyle: 3 } }).length, 1); }); -test("transitionStyle: blurslide is a quick eased push (one custom xfade) with grain on the seam's frames", () => { +test("transitionStyle: blurslide is a quick eased push (one closed-form custom xfade) with smear and grain on the seam's frames", () => { const R = { ...RENDER, transition: 0.22, transitionStyle: "blurslide" }; const g = xfadeGraph([10, 12, 4], 0.22, null, R); const x = xfades(g); assert.equal(x.length, 2); - assert.ok(x[0].startsWith("[p0e][p1e]xfade=transition=custom:expr='st(0,1-P);")); + assert.ok(x[0].startsWith("[p0e][p1e]xfade=transition=custom:expr='if(eq(PLANE,0),a0(abs(X-")); assert.ok(x[0].endsWith("':duration=0.22:offset=9.780[v1]")); - assert.ok(x[0].includes(`st(2,${SLIDE_DEFAULTS.travel}*W*ld(1))`)); - assert.match(x[0], /a1\(X-ld\(2\)/); // every plane read, not just luma - // Grain on the half-join nearest the seam, each clip in its own time. + assert.ok(x[0].includes(`abs(X-${SLIDE_DEFAULTS.travel}*W*(1-P*P*P))`)); + assert.match(x[0], /a1\(abs\(X-/); // every plane read, not just luma + // No registers: xfade's slice threads share them (see transition.mjs). + assert.doesNotMatch(x[0], /\b(st|ld)\(/); + // The smear in bands over the whole join, the grain on the half nearest the seam, each clip in its own time. const edge = (i) => g.parts.find((p) => p.endsWith(`[p${i}e]`)); - assert.equal(edge(0), "[0:v]setpts=PTS-STARTPTS,noise=alls=2:allf=t+u:enable='gte(t,9.890)'[p0e]"); + assert.equal( + edge(0), + "[0:v]setpts=PTS-STARTPTS," + + "dblur=angle=180:radius=13.4:enable='between(t,9.780,9.835)'," + + "dblur=angle=180:radius=6.8:enable='between(t,9.835,9.890)'," + + "dblur=angle=180:radius=2.5:enable='between(t,9.890,9.945)'," + + "noise=alls=2:allf=t+u:enable='gte(t,9.890)'[p0e]", + ); + assert.match(edge(1), /radius=13.4:enable='between\(t,11.780,11.835\)\+between\(t,0.000,0.055\)'/); assert.match(edge(1), /enable='gte\(t,11.890\)\+lt\(t,0.110\)'/); assert.match(edge(2), /enable='lt\(t,0.110\)'/); assert.ok(g.parts.includes("[p0a][p1a]acrossfade=d=0.22:c1=tri:c2=tri[a1]")); - // The knobs: no grain -> no edge filters; no blur -> one tap per side. + // The knobs: no grain and no smear -> no edge filters; either alone -> only it. const g0 = xfadeGraph([10, 12], 0.22, null, { ...R, slide: { grain: 0, blur: 0 } }); - assert.ok(!g0.parts.some((p) => p.includes("noise="))); - assert.equal((pushExpr({ ...R, slide: { blur: 0 } }, 0.22).match(/a0\(/g) ?? []).length, 1); + assert.ok(!g0.parts.some((p) => p.includes("noise=") || p.includes("dblur="))); + assert.doesNotMatch(blurSlideEdges(10, 0.22, { ...R, slide: { grain: 0 } }, { tail: true }), /noise=/); + assert.doesNotMatch(blurSlideEdges(10, 0.22, { ...R, slide: { blur: 0 } }, { tail: true }), /dblur=/); assert.deepEqual(slideOf({ slide: { travel: 0.2 } }), { ...SLIDE_DEFAULTS, travel: 0.2 }); assert.equal(xfadeTransitionOf({ transitionStyle: "fadeblack" }, 0.5), "fadeblack"); }); +test("transitionStyle: blurslide keeps a flat picture flat on ffmpeg's default threads (no register race)", () => { + // Measured before the fix: white into white had tens of thousands of black + // pixels on two seam frames -- slice threads sharing st()/ld() registers. + const R = { ...RENDER, width: 640, height: 360, transition: 0.3, transitionStyle: "blurslide", slide: { travel: 0.2, blur: 1, grain: 0 } }; + const g = xfadeGraph([1, 1], 0.3, null, R); + const src = ["-f", "lavfi", "-i", "color=white:s=640x360:r=30:d=1,format=yuv420p"]; + const tone = ["-f", "lavfi", "-i", "anullsrc=r=48000:cl=stereo:d=1"]; + const graph = g.parts.map((p) => p.replace("[0:a]", "[2:a]").replace("[1:a]", "[3:a]")).join(";"); + const raw = execFileSync("ffmpeg", ["-v", "error", ...src, ...src, ...tone, ...tone, "-filter_complex", `${graph};${g.vlab}format=gray[g]`, + "-map", "[g]", "-f", "rawvideo", "pipe:1", "-map", g.alab, "-f", "null", "-"], { maxBuffer: 64 << 20 }); + const n = 640 * 360; + assert.equal(raw.length, n * Math.round(1.7 * 30)); + let low = 0; + for (let i = 0; i < raw.length; i += 1) if (raw[i] < 250) low += 1; + assert.equal(low, 0); +}); + test("validateSlide: travel/blur/grain within bounds, nothing else", () => { assert.deepEqual(validateSlide({ render: {} }), []); assert.deepEqual(validateSlide({ render: { slide: { travel: 0.1, blur: 1, grain: 0 } } }), []); @@ -78,12 +106,12 @@ test("transitionStyle: blurslide leaves a dip, a wipe and a whip alone, and ever const R = { ...RENDER, transitionStyle: "blurslide" }; const g = xfadeGraph([10, 12, 4], 0.5, [{ wipe: true }, null, null], R); assert.match(xfades(g)[0], /transition=wipeleft/); - assert.doesNotMatch(g.parts.find((p) => p.endsWith("[p0e]")) ?? "", /gte/); + assert.doesNotMatch(g.parts.find((p) => p.endsWith("[p0e]")) ?? "", /gte|dblur/); assert.match(g.parts.find((p) => p.endsWith("[p1e]")), /enable='gte\(t,11.750\)'/); assert.equal(blurSlideEdges(10, 0.5, { transitionStyle: "fadeblack" }, { tail: true }), ""); assert.equal(blurSlideEdges(10, 0, { transitionStyle: "blurslide" }, { tail: true }), ""); for (const s of ["fade", "fadeblack", "fadewhite", "dissolve"]) { - assert.ok(!xfadeGraph([10, 12], 0.5, null, { ...RENDER, transitionStyle: s }).parts.some((p) => p.includes("noise=") || p.includes("custom"))); + assert.ok(!xfadeGraph([10, 12], 0.5, null, { ...RENDER, transitionStyle: s }).parts.some((p) => p.includes("noise=") || p.includes("dblur=") || p.includes("custom"))); } });