commit cf6118665e71e1421dfcaa561f713f3b551fd080
parent cebb1d91b658759132160f670269360aaa2b43a3
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Tue, 3 Nov 2026 15:38:06 -0500
umtool: a CENSORED attachment -- media[i].blur {on, strength 1-10, boxes, label} blurs a post item's picture or video in the render, the file untouched (operator: "'it jiggle' will need to be censored but I do want to include it")
post-censor.mjs: the knob's check (validatePostItem), the encode's filters (a real gblur, sigma grown with the
strength and the picture's width: the whole frame, or each box split, cropped, blurred and laid back) and the
label ("Censored"; false: none) drawn at the attachment's corner while it is up. A channel's posts-markup.json
may censor a post's attachment for every project (`censor: [{media, blur?}]`); the item's own blur wins.
updatePostItem merges `blur` (a null key cleared); `posts set-item media.<i>.blur=on|off`, `.strength=`,
`.label=…|off`, `.boxes=x,y,w,h;…|off`. Play previews it (a CSS blur in container units, the boxes as
backdrop blurs, the label); the post bench toggles it, sets strength and label, and draws boxes on a still
frame of the attachment (BlurBoxPad). Unit: the knob, the graph, the markup, an ffmpeg run whose blurred frame
loses most of its edges; e2e: Play's preview and the bench's toggle.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
14 files changed, 516 insertions(+), 23 deletions(-)
diff --git a/umtool/components/projects/BlurBoxPad.tsx b/umtool/components/projects/BlurBoxPad.tsx
@@ -0,0 +1,110 @@
+"use client";
+
+import { useEffect, useRef, useState } from "react";
+
+// THE CENSOR BOXES, DRAWN (post-censor.mjs; knobs.md, "A post item"): the
+// attachment on a still frame -- a picture as it is, a video paused at the
+// bench's playhead (or its in point) -- shown as the cut shows it (its crop),
+// each box over it; drag to draw a new one, × to take one away. The boxes are
+// fractions of the picture as shown, which is what the render blurs.
+
+type Box = number[];
+type Props = {
+ project: string;
+ media: { src: string; kind: string; width?: number; height?: number; crop?: number[] };
+ /** The video's source second to hold still. */
+ at: number;
+ boxes: Box[];
+ onChange: (boxes: Box[]) => void;
+ index: number;
+};
+
+const r4 = (v: number) => Math.round(v * 10000) / 10000;
+const clamp = (v: number) => Math.min(1, Math.max(0, v));
+
+export default function BlurBoxPad({ project, media, at, boxes, onChange, index }: Props) {
+ const pad = useRef<HTMLDivElement | null>(null);
+ const video = useRef<HTMLVideoElement | null>(null);
+ const [drag, setDrag] = useState<{ x: number; y: number; x2: number; y2: number } | null>(null);
+ const crop = Array.isArray(media.crop) && media.crop.length === 4 ? media.crop : [0, 0, 1, 1];
+ const aspect = media.width && media.height ? (media.width * crop[2]) / (media.height * crop[3]) : 16 / 9;
+ const src = `/api/report/post-item?project=${encodeURIComponent(project)}&file=${encodeURIComponent(media.src)}`;
+ const inner: React.CSSProperties = {
+ position: "absolute", width: `${100 / crop[2]}%`, height: `${100 / crop[3]}%`, left: `${(-crop[0] / crop[2]) * 100}%`, top: `${(-crop[1] / crop[3]) * 100}%`, maxWidth: "none", objectFit: "fill",
+ };
+ useEffect(() => {
+ const v = video.current;
+ if (!v) return;
+ try {
+ v.currentTime = at;
+ } catch {
+ // not seekable yet
+ }
+ }, [at]);
+ const where = (ev: React.PointerEvent) => {
+ const r = pad.current!.getBoundingClientRect();
+ return { x: clamp((ev.clientX - r.left) / r.width), y: clamp((ev.clientY - r.top) / r.height) };
+ };
+ const box = (d: { x: number; y: number; x2: number; y2: number }): Box => {
+ const x = Math.min(d.x, d.x2);
+ const y = Math.min(d.y, d.y2);
+ return [r4(x), r4(y), r4(Math.abs(d.x2 - d.x)), r4(Math.abs(d.y2 - d.y))];
+ };
+ return (
+ <div className="space-y-1">
+ <div
+ ref={pad}
+ className="relative w-full cursor-crosshair touch-none select-none overflow-hidden rounded border border-seam bg-black"
+ style={{ aspectRatio: String(aspect) }}
+ data-post-bench-blur-pad={index}
+ onPointerDown={(ev) => {
+ if ((ev.target as HTMLElement).closest("button")) return;
+ (ev.currentTarget as HTMLDivElement).setPointerCapture(ev.pointerId);
+ const p = where(ev);
+ setDrag({ x: p.x, y: p.y, x2: p.x, y2: p.y });
+ }}
+ onPointerMove={(ev) => {
+ if (!drag) return;
+ const p = where(ev);
+ setDrag({ ...drag, x2: p.x, y2: p.y });
+ }}
+ onPointerUp={() => {
+ if (!drag) return;
+ const b = box(drag);
+ setDrag(null);
+ if (b[2] >= 0.01 && b[3] >= 0.01 && boxes.length < 8) onChange([...boxes, b]);
+ }}
+ >
+ {media.kind === "image" ? (
+ // eslint-disable-next-line @next/next/no-img-element
+ <img src={src} alt="" draggable={false} style={inner} />
+ ) : (
+ <video ref={video} src={src} muted playsInline preload="auto" style={inner} />
+ )}
+ {[...boxes, ...(drag ? [box(drag)] : [])].map((b, j) => (
+ <div
+ key={j}
+ data-post-bench-blur-box={j < boxes.length ? j : "new"}
+ className="absolute border-2 border-amber-400 bg-amber-400/15"
+ style={{ left: `${b[0] * 100}%`, top: `${b[1] * 100}%`, width: `${b[2] * 100}%`, height: `${b[3] * 100}%` }}
+ >
+ {j < boxes.length && (
+ <button
+ type="button"
+ className="absolute right-0 top-0 bg-black/70 px-1 text-[11px] leading-none text-white"
+ onClick={() => onChange(boxes.filter((_, k) => k !== j))}
+ aria-label={`remove box ${j + 1}`}
+ data-post-bench-blur-box-remove={j}
+ >
+ ×
+ </button>
+ )}
+ </div>
+ ))}
+ </div>
+ <p className="m-0 text-[11.5px] text-text-2">
+ drag on the frame to blur a region; no box blurs the whole frame{boxes.length ? ` · ${boxes.length} box${boxes.length === 1 ? "" : "es"}` : ""}
+ </p>
+ </div>
+ );
+}
diff --git a/umtool/components/projects/PostBench.tsx b/umtool/components/projects/PostBench.tsx
@@ -8,6 +8,7 @@ import { cn } from "@/lib/utils";
import { postBenchHref } from "@/lib/hrefs";
import { POST_HOLD, POST_MEDIA_MIN_SPAN, POST_PARAPHRASE_MAX, contextReadSeconds, postItemPlan, readingSeconds, ruleSeconds } from "umtool-report-to-video/post-item";
import PostItemPlayer, { type PostPlan } from "./review/PostItemPlayer";
+import BlurBoxPad from "./BlurBoxPad";
import PostNarrationPanel from "./PostNarrationPanel";
// ---------------------------------------------------------------------------
@@ -28,7 +29,8 @@ import PostNarrationPanel from "./PostNarrationPanel";
// "paraphrased" label (its own text kept, shown beside)
// ---------------------------------------------------------------------------
-type Media = Record<string, unknown> & { src: string; kind: string; seconds?: number; start?: number; end?: number; mute?: boolean; crop?: number[]; push?: boolean; words?: string; audio?: boolean; width?: number; height?: number };
+type Blur = { on: boolean; strength?: number; boxes?: number[][]; label?: string | false };
+type Media = Record<string, unknown> & { src: string; kind: string; seconds?: number; start?: number; end?: number; mute?: boolean; crop?: number[]; push?: boolean; words?: string; audio?: boolean; width?: number; height?: number; blur?: Blur };
type Ref = Record<string, unknown> & { author?: string; handle?: string; text?: string; paraphrase?: string };
type Entry = Record<string, unknown> & { id: string; media?: Media[]; hold?: number; mediaLayout?: string; redact?: boolean; quoted?: Ref; parents?: Ref[] };
@@ -137,6 +139,10 @@ export default function PostBench({
mute: m.mute === true ? true : null,
crop: Array.isArray(m.crop) ? m.crop : null,
push: m.push === true ? true : null,
+ // The censoring blur (post-censor.mjs), every key as it stands (null: cleared).
+ blur: m.blur
+ ? { on: m.blur.on === true, strength: m.blur.strength ?? null, boxes: m.blur.boxes?.length ? m.blur.boxes : null, label: m.blur.label === undefined ? null : m.blur.label }
+ : null,
},
]),
),
@@ -433,6 +439,61 @@ export default function PostBench({
</button>
))}
</div>
+ <div className="mt-2 space-y-1.5 text-[12px]" data-post-bench-censor={i}>
+ <label className="flex items-center gap-2">
+ <input
+ type="checkbox"
+ checked={m.blur?.on === true}
+ onChange={(e) => setMedia(i, { blur: { ...(m.blur ?? {}), on: e.target.checked } })}
+ data-post-bench-blur={i}
+ />
+ censor it (blurred in the video; the file is untouched)
+ </label>
+ {m.blur?.on === true && (
+ <>
+ <div className="flex flex-wrap items-center gap-2">
+ strength
+ <input
+ type="range"
+ min={1}
+ max={10}
+ step={1}
+ value={m.blur.strength ?? 7}
+ onChange={(e) => setMedia(i, { blur: { ...m.blur!, strength: Number(e.target.value) === 7 ? undefined : Number(e.target.value) } })}
+ data-post-bench-blur-strength={i}
+ />
+ <span className="font-mono">{m.blur.strength ?? 7}</span>
+ label
+ <input
+ type="text"
+ value={m.blur.label === false ? "" : (m.blur.label ?? "")}
+ placeholder={m.blur.label === false ? "(none)" : "Censored"}
+ disabled={m.blur.label === false}
+ onChange={(e) => setMedia(i, { blur: { ...m.blur!, label: e.target.value.trim() ? e.target.value : undefined } })}
+ className="w-28 rounded border border-seam bg-ground px-1.5 py-0.5"
+ data-post-bench-blur-label={i}
+ />
+ <label className="flex items-center gap-1">
+ <input type="checkbox" checked={m.blur.label === false} onChange={(e) => setMedia(i, { blur: { ...m.blur!, label: e.target.checked ? false : undefined } })} />
+ no label
+ </label>
+ {!!m.blur.boxes?.length && (
+ <button type="button" className={btn} onClick={() => setMedia(i, { blur: { ...m.blur!, boxes: undefined } })} data-post-bench-blur-whole={i}>
+ Whole frame
+ </button>
+ )}
+ </div>
+ <BlurBoxPad
+ project={project}
+ media={m}
+ index={i}
+ at={timed ? (srcNow ?? m.start ?? 0) : 0}
+ boxes={m.blur.boxes ?? []}
+ onChange={(boxes) => setMedia(i, { blur: { ...m.blur!, boxes: boxes.length ? boxes : undefined } })}
+ />
+ </>
+ )}
+ </div>
{m.kind === "video" && m.audio !== false && (
<div className="mt-2 text-[12px]">
{m.words ? (
diff --git a/umtool/components/projects/review/PostItemPlayer.tsx b/umtool/components/projects/review/PostItemPlayer.tsx
@@ -3,6 +3,7 @@
import { useEffect, useMemo, useRef, useState } from "react";
import { POST_PUSH, mediaTimeAt, postLayout, stepAt, stepBoxes } from "umtool-report-to-video/post-item";
import { dryGainAt, mixPhaseAt, pickedTake, wetGainAt } from "umtool-report-to-video/post-narration";
+import { blurCqw, blurOf } from "umtool-report-to-video/post-censor";
// ---------------------------------------------------------------------------
// A POST ITEM PLAYED (report-to-video/post-item.mjs; knobs.md, "Play the cut"):
@@ -161,12 +162,16 @@ function MediaEl({
if (!run && !v.paused) v.pause();
}, [target, run, speed]);
const progress = inStep ? Math.min(1, Math.max(0, (s - step.at) / Math.max(0.1, step.seconds))) : 0;
+ // CENSORED (post-censor.mjs): the whole frame blurred, or its boxes -- as the render blurs it.
+ const blur = blurOf(m) as { strength: number; boxes: number[][]; label: string | null } | null;
+ const blurCss = blur ? `blur(${blurCqw(blur.strength)}cqw)` : undefined;
return (
<div
data-post-media={m.i}
data-post-media-kind={m.kind}
+ data-post-blurred={blur ? (blur.boxes.length ? "boxes" : "frame") : undefined}
className="absolute overflow-hidden"
- style={{ left: pct(b.x, box.width), top: pct(b.y, box.height), width: pct(b.width, box.width), height: pct(b.height, box.height) }}
+ style={{ left: pct(b.x, box.width), top: pct(b.y, box.height), width: pct(b.width, box.width), height: pct(b.height, box.height), containerType: blur ? "size" : undefined }}
>
{timed ? (
<video
@@ -179,7 +184,7 @@ function MediaEl({
playsInline
loop={step.loop}
muted={!(step.sound && run)}
- style={{ ...inner, objectFit: "fill" }}
+ style={{ ...inner, objectFit: "fill", filter: blur && !blur.boxes.length ? blurCss : undefined }}
/>
) : (
// eslint-disable-next-line @next/next/no-img-element
@@ -187,9 +192,22 @@ function MediaEl({
src={postFileUrl(project, String(m.src))}
alt=""
data-post-image={m.i}
- style={{ ...inner, objectFit: "fill", transform: m.push ? `scale(${1 + POST_PUSH * progress})` : undefined, transformOrigin: "center" }}
+ style={{ ...inner, objectFit: "fill", transform: m.push ? `scale(${1 + POST_PUSH * progress})` : undefined, transformOrigin: "center", filter: blur && !blur.boxes.length ? blurCss : undefined }}
/>
)}
+ {blur?.boxes.map((bx, j) => (
+ <div
+ key={j}
+ data-post-blur-box={j}
+ className="pointer-events-none absolute"
+ style={{ left: `${bx[0] * 100}%`, top: `${bx[1] * 100}%`, width: `${bx[2] * 100}%`, height: `${bx[3] * 100}%`, backdropFilter: blurCss, WebkitBackdropFilter: blurCss }}
+ />
+ ))}
+ {blur?.label && (
+ <span data-post-blur-label="" className="pointer-events-none absolute left-[2%] top-[2%] rounded-[3px] bg-black/70 px-[1.2cqw] py-[0.4cqw] text-[2.4cqw] leading-none text-white">
+ {blur.label}
+ </span>
+ )}
</div>
);
}
diff --git a/umtool/e2e/post-items.spec.ts b/umtool/e2e/post-items.spec.ts
@@ -129,6 +129,24 @@ test("a redacted term: Play shows the words; As published draws a blank bar and
expect(JSON.stringify(timeline())).toContain("here is the video");
});
+test("a censored attachment: set-item blurs it, Play previews the blur and its label, the bench toggles it off and saves", async ({ page }) => {
+ umtool(["posts", "set-item", PROJECT, "p-vid", "media.0.blur=on"]);
+ await page.setViewportSize({ width: 1366, height: 1000 });
+ await page.goto(urls.playHref(PROJECT, { bare: true, clip: "p-vid" }));
+ await expect(page.locator('[data-post-media="0"]')).toHaveAttribute("data-post-blurred", "frame");
+ await expect(page.locator('[data-post-media="0"] [data-post-blur-label]')).toHaveText("Censored");
+ expect(await page.locator('[data-post-video="0"]').evaluate((v) => getComputedStyle(v).filter)).toMatch(/blur\(/);
+ await page.goto(urls.postBenchHref(PROJECT, "p-vid"));
+ await expect(page.locator('[data-post-bench-blur="0"]')).toBeChecked();
+ await expect(page.locator('[data-post-bench-blur-pad="0"]')).toBeVisible();
+ await page.locator('[data-post-bench-blur="0"]').uncheck();
+ await page.locator("[data-post-bench-save]").click();
+ await expect(page.locator("[data-post-bench-status]")).toBeVisible();
+ const vid = timeline().find((e) => e.id === "p-vid") as Entry & { media: Array<{ blur?: { on: boolean }; src: string }> };
+ expect(vid.media[0].blur?.on).toBe(false);
+ expect(vid.media[0].src).toMatch(/\.mp4$/);
+});
+
test("the post bench trims the video attachment and saves it; the cut's seconds follow", async ({ page }) => {
await page.setViewportSize({ width: 1366, height: 1000 });
await page.goto(urls.postBenchHref(PROJECT, "p-vid"));
diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs
@@ -2352,15 +2352,15 @@ export async function insertEntries(dir, afterId, specs, { token = null, op = "i
/** The knobs of a post item a write may set (post-item.mjs; knobs.md, "A post item"). */
export const POST_ITEM_KNOBS = Object.freeze(["hold", "mediaLayout", "redact"]);
-/** A post item attachment's knobs: its trim, its sound, its crop, the push-in, its transcript. */
-export const POST_MEDIA_KNOBS = Object.freeze(["start", "end", "mute", "crop", "push", "words"]);
+/** A post item attachment's knobs: its trim, its sound, its crop, the push-in, its transcript, its censoring blur. */
+export const POST_MEDIA_KNOBS = Object.freeze(["start", "end", "mute", "crop", "push", "words", "blur"]);
/** A context post's knobs (`quoted`, `parents[i]`): the operator's paraphrase of its words. */
export const POST_CONTEXT_KNOBS = Object.freeze(["paraphrase"]);
/**
* SET A POST ITEM's KNOBS (the post bench, `umtool posts set-item`): `patch`
* is `{ hold?, mediaLayout?, redact?, media?: { <i>: { start?, end?, mute?,
- * crop?, push?, words? } }, quoted?: { paraphrase? }, parents?: { <i>:
+ * crop?, push?, words?, blur? } }, quoted?: { paraphrase? }, parents?: { <i>:
* { paraphrase? } } }`; a null clears a knob (the default again), and so
* does an empty paraphrase (the context's own words again; its `text` is
* never touched). One structural write, refused in the build's words
@@ -2395,7 +2395,17 @@ export async function updatePostItem(dir, id, patch, { token = null } = {}) {
for (const k of POST_MEDIA_KNOBS) {
if (!(k in mp)) continue;
if (k === "crop" && Array.isArray(mp.crop)) media[n].crop = mp.crop.map((v) => Math.round(Number(v) * 10000) / 10000);
- else set(media[n], k, mp[k]);
+ else if (k === "blur" && isObj(mp.blur)) {
+ // The censoring blur (post-censor.mjs) MERGES: each key set, a null one cleared; nothing left, none.
+ const b = isObj(media[n].blur) ? { ...media[n].blur } : {};
+ for (const [bk, bv] of Object.entries(mp.blur)) {
+ if (bv === null || bv === undefined) delete b[bk];
+ else if (bk === "boxes" && Array.isArray(bv)) b.boxes = bv.map((box) => (Array.isArray(box) ? box.map((v) => Math.round(Number(v) * 10000) / 10000) : box));
+ else b[bk] = bv;
+ }
+ if (Object.keys(b).length) media[n].blur = b;
+ else delete media[n].blur;
+ } else set(media[n], k, mp[k]);
}
// A trim back to the whole file is no trim.
if (media[n].start === 0) delete media[n].start;
diff --git a/umtool/lib/report/postRedaction.test.mjs b/umtool/lib/report/postRedaction.test.mjs
@@ -91,3 +91,18 @@ test("a take's synthesized read leaves the term out; the script and the take's r
assert.equal(r.take.script, "Hello, I am Quentin Example. Welcome.");
assert.equal((await manifest(p)).timeline[0].narration.script, "Hello, I am Quentin Example. Welcome.");
});
+
+test("posts set-item media.<i>.blur: on, strength, label, boxes -- merged; off keeps the settings; the file's entry otherwise untouched", async () => {
+ const p = await project("b", [item("1", { media: [{ src: "posts-media/subj-x/1/1.mp4", kind: "video", seconds: 3, width: 320, height: 180 }] })]);
+ let r = await cli(["set-item", "b", "p-1", "media.0.blur=on", "media.0.blur.strength=4", "media.0.blur.boxes=0,0,0.5,0.5;0.5,0.5,0.25,0.25"]);
+ assert.equal(r.code, 0, r.err);
+ assert.deepEqual((await manifest(p)).timeline[0].media[0].blur, { on: true, strength: 4, boxes: [[0, 0, 0.5, 0.5], [0.5, 0.5, 0.25, 0.25]] });
+ r = await cli(["set-item", "b", "p-1", "media.0.blur.label=off", "media.0.blur.boxes=off"]);
+ assert.equal(r.code, 0, r.err);
+ assert.deepEqual((await manifest(p)).timeline[0].media[0].blur, { on: true, strength: 4, label: false });
+ r = await cli(["set-item", "b", "p-1", "media.0.blur=off"]);
+ assert.deepEqual((await manifest(p)).timeline[0].media[0].blur, { on: false, strength: 4, label: false });
+ r = await cli(["set-item", "b", "p-1", "media.0.blur.strength=40"]);
+ assert.equal(r.code, 1, "refused in the build's words");
+ assert.equal((await manifest(p)).timeline[0].media[0].src, "posts-media/subj-x/1/1.mp4");
+});
diff --git a/umtool/lib/report/postsCli.mjs b/umtool/lib/report/postsCli.mjs
@@ -59,12 +59,17 @@ export const POSTS_USAGE = [
" umtool posts set-item <project> <item> [hold=<s>|off] [layout=sequence|grid] [redact=on|off|auto]",
" [media.<i>.start=<s>] [media.<i>.end=<s>] [media.<i>.mute=on|off] [media.<i>.crop=x,y,w,h|off]",
" [media.<i>.push=on|off] [media.<i>.trim=off] [quoted.paraphrase=\"…\"|off]",
+ " [media.<i>.blur=on|off] [media.<i>.blur.strength=1–10] [media.<i>.blur.label=\"…\"|off]",
+ " [media.<i>.blur.boxes=x,y,w,h;…|off]",
" [parent.<i>.paraphrase=\"…\"|off] [narration.rate=0.8–1.5|narration.<mix knob>=…] [--json]",
" a post item's knobs (the post bench's writer, updatePostItem): its hold, its images' grid, the blur of other authors,",
" an attachment's trim, sound, crop (fractions of its picture) and push-in; fit=read[:linger] (a narrated post: its",
" video cut to its best part for the read, `posts fit`). quoted.paraphrase / parent.<i>.paraphrase (nearest first):",
" your retelling of a long context post (at most 600 characters), drawn in place of its words and labelled",
" \"paraphrased\"; its own text is kept; off (or empty) shows its words again.",
+ " media.<i>.blur=on: the attachment CENSORED in the render -- a real blur (strength 1-10, default 7) of the whole",
+ " frame, or of its boxes (fractions of the picture as shown: x,y,w,h;…), labelled \"Censored\" (label=… or off);",
+ " its file is never touched. Play and the bench preview it; the bench draws boxes on a paused frame.",
" umtool posts narrate <project> … a post item's narration: script, takes (the editor's tts), pick, approve, mix",
" (umtool posts narrate --help)",
" umtool posts fit <project> [--all|<item> …] [--linger s] [--dry-run] narrated posts' videos cut to their best part",
@@ -563,9 +568,18 @@ export function postItemPatchOf(pairs) {
else if (k === "redact") out.redact = v === "auto" || v === "" ? null : onOff(v, k);
else if (k === "quoted.paraphrase") out.quoted = { paraphrase: paraphraseOf(raw) };
else if (/^parents?\.\d+\.paraphrase$/.test(k)) (out.parents ??= {})[k.split(".")[1]] = { paraphrase: paraphraseOf(raw) };
- else {
+ else if (/^media\.\d+\.blur(\.(strength|label|boxes))?$/.test(k)) {
+ // The censoring blur (post-censor.mjs): on|off, its strength, its label (off: none), its boxes (x,y,w,h;…|off).
+ const [, i, , sub] = /^media\.(\d+)\.blur(\.(strength|label|boxes))?$/.exec(k) ?? [];
+ const blur = (((out.media ??= {})[i] ??= {}).blur ??= {});
+ if (!sub) blur.on = onOff(v, k);
+ else if (sub === "strength") blur.strength = OFF.has(v) || v === "" ? null : Number(raw);
+ else if (sub === "label") blur.label = v === "off" ? false : raw.trim() === "" ? null : raw;
+ else blur.boxes = OFF.has(v) || v === "" ? null : raw.split(";").map((b) => b.split(",").map(Number));
+ if (typeof blur.strength === "number" && !Number.isFinite(blur.strength)) throw new CliError(`${k}= takes a number (1-10)`);
+ } else {
const m = /^media\.(\d+)\.(start|end|mute|crop|push|trim)$/.exec(k);
- if (!m) throw new CliError(`${pair}: not a post item knob (hold=, layout=, redact=, media.<i>.start|end|mute|crop|push|trim=, quoted.paraphrase=, parent.<i>.paraphrase=)`);
+ if (!m) throw new CliError(`${pair}: not a post item knob (hold=, layout=, redact=, media.<i>.start|end|mute|crop|push|trim=, media.<i>.blur[.strength|.label|.boxes]=, quoted.paraphrase=, parent.<i>.paraphrase=)`);
const media = (out.media ??= {});
const one = (media[m[1]] ??= {});
if (m[2] === "start" || m[2] === "end") one[m[2]] = OFF.has(v) || v === "" ? null : Number(raw);
@@ -582,7 +596,6 @@ export function postItemPatchOf(pairs) {
return out;
}
-/** `posts context`: every post item's context from its capture (postContext.mjs postsContext). */
/** `umtool posts redact <p> ls | add "<term>" [--substring] [--note …] | remove <n>`: the project's redaction list. */
async function redactCommand(projectArg, rest, { root, json, out, flags, str }) {
const project = await projectOf(projectArg, root);
@@ -619,6 +632,7 @@ async function redactCommand(projectArg, rest, { root, json, out, flags, str })
return 0;
}
+/** `posts context`: every post item's context from its capture (postContext.mjs postsContext). */
async function contextCommand(projectArg, { root, json, dryRun, out }) {
const project = await projectOf(projectArg, root);
const { postsContext } = await import("./postContext.mjs");
diff --git a/umtool/report-to-video/package.json b/umtool/report-to-video/package.json
@@ -63,6 +63,7 @@
"./post-avatars": "./post-avatars.mjs",
"./post-item": "./post-item.mjs",
"./post-narration": "./post-narration.mjs",
+ "./post-censor": "./post-censor.mjs",
"./post-redact": "./post-redact.mjs",
"./post-redact-files": "./post-redact-files.mjs",
"./post-render": "./post-render.mjs",
diff --git a/umtool/report-to-video/post-censor.mjs b/umtool/report-to-video/post-censor.mjs
@@ -0,0 +1,144 @@
+// A CENSORED ATTACHMENT (operator, 3 Nov: "'it jiggle' will need to be
+// censored but I do want to include it"): a post item's picture or video
+// played BLURRED -- the whole frame, or only some regions of it -- with a
+// small label saying so. umtool/docs/knobs.md, "A post item".
+//
+// media[i].blur = { on: true, strength?: 1–10 (7), boxes?: [[x, y, w, h], …], label?: "…" | false }
+//
+// `boxes` are fractions of the picture AS SHOWN (after its crop), held still
+// over the clip; none blurs the whole frame. `label` is the caption drawn on
+// it ("Censored" by default; false: none). A post's channel markup may censor
+// one of its attachments for every project (posts-markup.json's `censor`,
+// post-redact.mjs); the item's own `blur` wins.
+//
+// NOTHING IS REWRITTEN: the attachment's file stays as it was captured. The
+// blur is a real one (ffmpeg gblur, sigma grown with the strength and the
+// picture's size), drawn where public output is made -- the render. Play and
+// the post bench preview it (a CSS blur, the boxes as backdrop blurs).
+//
+// PURE and dependency-free.
+
+export const POST_BLUR_DEFAULTS = Object.freeze({ strength: 7, label: "Censored" });
+export const POST_BLUR_BOXES_MAX = 8;
+const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
+const fin = (v) => typeof v === "number" && Number.isFinite(v);
+const r3 = (v) => Math.round(v * 1000) / 1000;
+
+/** Is attachment `m` blurred? */
+export const blurOn = (m) => isObj(m?.blur) && m.blur.on === true;
+
+/** Its blur with the defaults filled: `{ strength, boxes, label }` (label null: none), or null when it is not blurred. */
+export function blurOf(m) {
+ if (!blurOn(m)) return null;
+ const b = m.blur;
+ return {
+ strength: fin(b.strength) ? Math.min(10, Math.max(1, b.strength)) : POST_BLUR_DEFAULTS.strength,
+ boxes: Array.isArray(b.boxes) ? b.boxes.filter((x) => Array.isArray(x) && x.length === 4) : [],
+ label: b.label === false ? null : typeof b.label === "string" && b.label.trim() ? b.label.trim() : POST_BLUR_DEFAULTS.label,
+ };
+}
+
+/** The blur's sigma on a picture `width` px wide: 0.4% of the width per step of strength (at 7, ~2.8%). */
+export const blurSigma = (strength, width) => Math.max(2, Math.round(width * strength * 0.004 * 10) / 10);
+/** The same as a share of the width, for a preview (CSS `cqw`). */
+export const blurCqw = (strength) => r3(strength * 0.4);
+
+/** Is `b` a box of fractions inside the picture? */
+export const boxOk = (b) =>
+ Array.isArray(b) && b.length === 4 && b.every((v) => fin(v) && v >= 0 && v <= 1) && b[2] >= 0.01 && b[3] >= 0.01 && b[0] + b[2] <= 1.0001 && b[1] + b[3] <= 1.0001;
+
+/** Every reason `media[i].blur` is refused. */
+export function blurErrors(blur, where) {
+ if (blur === undefined) return [];
+ if (!isObj(blur)) return [`${where} must be {on, strength?, boxes?, label?}`];
+ const errors = [];
+ for (const k of Object.keys(blur)) if (!["on", "strength", "boxes", "label"].includes(k)) errors.push(`${where}.${k} is not a blur knob (on, strength, boxes, label)`);
+ if (typeof blur.on !== "boolean") errors.push(`${where}.on must be true or false`);
+ if (blur.strength !== undefined && !(fin(blur.strength) && blur.strength >= 1 && blur.strength <= 10)) errors.push(`${where}.strength must be 1–10`);
+ if (blur.boxes !== undefined) {
+ if (!Array.isArray(blur.boxes) || blur.boxes.length > POST_BLUR_BOXES_MAX) errors.push(`${where}.boxes must be a list of at most ${POST_BLUR_BOXES_MAX} [x, y, w, h]`);
+ else blur.boxes.forEach((b, j) => !boxOk(b) && errors.push(`${where}.boxes[${j}] must be [x, y, w, h] as fractions of the picture (each 0–1, inside it)`));
+ }
+ if (blur.label !== undefined && blur.label !== false && !(typeof blur.label === "string" && blur.label.length <= 40)) errors.push(`${where}.label must be words (at most 40 characters) or false`);
+ return errors;
+}
+
+/** A label's words as ffmpeg drawtext's `text=` takes them, inside single quotes. */
+const dtText = (s) => String(s).replace(/\\/g, "\\\\").replace(/'/g, "\u2019").replace(/:/g, "\\:").replace(/%/g, "\\%");
+
+/**
+ * The filters that blur attachment `m`, drawn `w` × `h` px: `[inLabel]` →
+ * `[outLabel]`. The whole frame, or each box: split, cropped, blurred and laid
+ * back over. A label is drawn by labelFilter, on the composed frame.
+ */
+export function blurFilters(inLabel, outLabel, m, { width, height }) {
+ const b = blurOf(m);
+ if (!b) return [`[${inLabel}]null[${outLabel}]`];
+ const sigma = blurSigma(b.strength, width);
+ if (!b.boxes.length) return [`[${inLabel}]gblur=sigma=${sigma}:steps=3[${outLabel}]`];
+ const out = [];
+ let cur = inLabel;
+ b.boxes.forEach((box, j) => {
+ const x = Math.round(box[0] * width);
+ const y = Math.round(box[1] * height);
+ const w = Math.max(2, Math.min(width - x, Math.round(box[2] * width)));
+ const h = Math.max(2, Math.min(height - y, Math.round(box[3] * height)));
+ const base = `${outLabel}_k${j}`;
+ out.push(`[${cur}]split[${base}a][${base}b]`);
+ out.push(`[${base}b]crop=${w}:${h}:${x}:${y},gblur=sigma=${sigma}:steps=3[${base}c]`);
+ const next = j === b.boxes.length - 1 ? outLabel : `${base}o`;
+ out.push(`[${base}a][${base}c]overlay=x=${x}:y=${y}[${next}]`);
+ cur = next;
+ });
+ return out;
+}
+
+/**
+ * The label's drawtext on the frame `[inLabel]` → `[outLabel]`: the words at
+ * the attachment's top-left corner (its box `b` on the frame) while it is up,
+ * or null when it has none (or there is no face to draw it in).
+ */
+export function labelFilter(inLabel, outLabel, m, b, { from, to, fontfile, scale = 1 }) {
+ const bl = blurOf(m);
+ if (!bl?.label || !fontfile) return null;
+ const size = Math.max(12, Math.round(26 * scale));
+ const pad = Math.round(size * 0.5);
+ return (
+ `[${inLabel}]drawtext=fontfile='${fontfile}':text='${dtText(bl.label)}':fontsize=${size}:fontcolor=white:box=1:boxcolor=black@0.7:boxborderw=${Math.round(size * 0.35)}:` +
+ `x=${b.x + pad}:y=${b.y + pad}:enable='between(t,${r3(from)},${r3(to)})'[${outLabel}]`
+ );
+}
+
+/** Every reason a markup's `censor` list is refused (posts-markup.json). */
+export function censorMarkupErrors(list, where) {
+ if (list === undefined) return [];
+ if (!Array.isArray(list)) return [`${where} must be a list of {media, blur}`];
+ const errors = [];
+ list.forEach((c, i) => {
+ if (!isObj(c) || !(Number.isInteger(c.media) && c.media >= 0 && c.media < 8)) errors.push(`${where}[${i}].media must be the attachment's index (0–7)`);
+ if (isObj(c) && c.blur !== undefined) errors.push(...blurErrors({ on: true, ...(isObj(c.blur) ? c.blur : { bad: c.blur }) }, `${where}[${i}].blur`));
+ });
+ return errors;
+}
+
+/**
+ * Post item `entry` with its channel markup's censoring laid on (`censor:
+ * [{media, blur?}]` in the post's markup; `blur` absent: the whole frame, the
+ * defaults): an attachment with a `blur` of its own keeps it. Returns the
+ * entry itself when nothing changes.
+ *
+ * @param {Record<string, any>} entry
+ * @param {{ markup?: Record<string, {censor?: Array<{media: number, blur?: Record<string, any>}>}> } | null | undefined} red
+ */
+export function censorEntry(entry, red) {
+ const list = red?.markup?.[String(entry?.post ?? "")]?.censor;
+ if (!Array.isArray(list) || !list.length || !Array.isArray(entry?.media)) return entry;
+ let changed = false;
+ const media = entry.media.map((m, i) => {
+ const c = list.find((x) => x?.media === i);
+ if (!c || !isObj(m) || m.blur !== undefined) return m;
+ changed = true;
+ return { ...m, blur: { on: true, ...(isObj(c.blur) ? c.blur : {}) } };
+ });
+ return changed ? { ...entry, media } : entry;
+}
diff --git a/umtool/report-to-video/post-censor.test.mjs b/umtool/report-to-video/post-censor.test.mjs
@@ -0,0 +1,83 @@
+// post-censor.mjs: a censored attachment -- the knob's check, the blur in the
+// encode (the whole frame, or its boxes), the label, a channel's markup.
+import assert from "node:assert/strict";
+import { execFileSync, spawnSync } from "node:child_process";
+import { mkdtempSync, rmSync } from "node:fs";
+import { tmpdir } from "node:os";
+import path from "node:path";
+import { after, test } from "node:test";
+import { blurErrors, blurFilters, blurOf, blurSigma, censorEntry } from "./post-censor.mjs";
+import { postItemPlan, postLayout, validatePostItem } from "./post-item.mjs";
+import { postSegmentArgs } from "./post-render.mjs";
+import { validatePostsMarkup } from "./post-redact.mjs";
+
+const box = { width: 1440, height: 810 };
+const entry = (blur) => ({
+ type: "post", id: "p1", post: "c-x/1", platform: "x", author: "A", handle: "a", date: "2026-10-30T04:00:00Z", text: "it does a thing",
+ media: [{ src: "m/v.mp4", kind: "video", seconds: 3, width: 320, height: 180, audio: false, ...(blur ? { blur } : {}) }],
+});
+const graphOf = (e, fontfile = null) => {
+ const argv = postSegmentArgs({ entry: e, box, plan: postItemPlan(e), layout: postLayout(e, box), cards: { read: "/c/read.png" }, files: ["/m/v.mp4"], render: { fps: 30 }, outPath: "/o.mp4", fontfile });
+ return argv[argv.indexOf("-filter_complex") + 1];
+};
+
+test("the knob: on, a strength 1-10, boxes of fractions, a label or false; validated with the item", () => {
+ assert.deepEqual(blurErrors({ on: true, strength: 4, boxes: [[0.1, 0.1, 0.5, 0.5]], label: false }, "b"), []);
+ const bad = blurErrors({ on: "yes", strength: 11, boxes: [[0.8, 0, 0.5, 0.5]], label: 3, extra: 1 }, "b");
+ assert.equal(bad.length, 5, bad.join("; "));
+ assert.ok(validatePostItem(entry({ on: true, strength: 0 })).some((e) => e.includes("media[0].blur.strength must be 1–10")));
+ assert.deepEqual(blurOf({ blur: { on: true } }), { strength: 7, boxes: [], label: "Censored" });
+ assert.equal(blurOf({ blur: { on: false, strength: 3 } }), null, "off keeps its settings and blurs nothing");
+});
+
+test("the encode: the whole frame gblurred, or each box split, cropped, blurred and laid back; the label drawn on the frame", () => {
+ const plain = graphOf(entry(null));
+ assert.doesNotMatch(plain, /gblur/);
+ const whole = graphOf(entry({ on: true }), "/f/bold.ttf");
+ assert.match(whole, /\[m0_0r\]gblur=sigma=[\d.]+:steps=3\[m0_0\]/);
+ assert.match(whole, /drawtext=fontfile='\/f\/bold.ttf':text='Censored'/);
+ const boxes = graphOf(entry({ on: true, strength: 5, boxes: [[0, 0, 0.5, 0.5], [0.5, 0.5, 0.5, 0.5]], label: "It: 100%" }), "/f/bold.ttf");
+ assert.equal((boxes.match(/gblur/g) ?? []).length, 2);
+ assert.match(boxes, /\[m0_0r\]split/);
+ assert.match(boxes, /text='It\\: 100\\%'/);
+ assert.doesNotMatch(graphOf(entry({ on: true, label: false }), "/f/bold.ttf"), /drawtext/);
+ assert.equal(blurSigma(7, 1000), 28);
+ assert.deepEqual(blurFilters("a", "b", { blur: { on: false } }, { width: 10, height: 10 }), ["[a]null[b]"]);
+});
+
+test("a channel's markup censors an attachment in every project; the item's own blur wins", () => {
+ const red = { terms: [], markup: { "c-x/1": { censor: [{ media: 0 }] } } };
+ const e = entry(null);
+ const out = censorEntry(e, red);
+ assert.deepEqual(out.media[0].blur, { on: true });
+ assert.equal(e.media[0].blur, undefined, "the entry is never rewritten");
+ const own = entry({ on: false });
+ assert.equal(censorEntry(own, red), own);
+ assert.equal(censorEntry(e, { terms: [] }), e);
+ assert.deepEqual(validatePostsMarkup({ "1": { censor: [{ media: 0, blur: { strength: 3 } }] } }), []);
+ assert.equal(validatePostsMarkup({ "1": { censor: [{ media: 9 }, { media: 0, blur: { strength: 30 } }] } }).length, 2);
+});
+
+const ROOT = mkdtempSync(path.join(tmpdir(), "post-censor-"));
+after(() => rmSync(ROOT, { recursive: true, force: true }));
+
+test("the encode runs: a blurred frame is smoother than the clean one (ffmpeg)", () => {
+ const src = path.join(ROOT, "v.mp4");
+ execFileSync("ffmpeg", ["-v", "error", "-y", "-f", "lavfi", "-i", "testsrc=s=320x180:d=3:r=30", "-c:v", "libx264", "-pix_fmt", "yuv420p", src]);
+ const png = path.join(ROOT, "card.png");
+ execFileSync("ffmpeg", ["-v", "error", "-y", "-f", "lavfi", "-i", "color=c=black:s=1440x810", "-frames:v", "1", png]);
+ const detail = (blur) => {
+ const e = entry(blur);
+ const out = path.join(ROOT, `o-${blur ? "b" : "c"}.mp4`);
+ const argv = postSegmentArgs({ entry: e, box, plan: postItemPlan(e), layout: postLayout(e, box), cards: { read: png }, files: [src], render: { fps: 30 }, outPath: out, encode: ["-c:v", "libx264", "-preset", "ultrafast"] });
+ execFileSync("ffmpeg", argv);
+ // The frame's edge energy: a blur takes most of it away.
+ const r = spawnSync("ffmpeg", ["-v", "info", "-ss", "1", "-i", out, "-frames:v", "1", "-vf", "edgedetect,signalstats,metadata=print:key=lavfi.signalstats.YAVG", "-f", "null", "-"], { encoding: "utf8" });
+ return `${r.stdout}${r.stderr}`;
+ };
+ const yavg = (s) => Number(/YAVG=([\d.]+)/.exec(s)?.[1] ?? NaN);
+ const clean = yavg(detail(null));
+ const blurred = yavg(detail({ on: true, label: false }));
+ assert.ok(Number.isFinite(clean) && Number.isFinite(blurred), `${clean} ${blurred}`);
+ assert.ok(blurred < clean * 0.6, `edges: clean ${clean}, blurred ${blurred}`);
+});
diff --git a/umtool/report-to-video/post-item.mjs b/umtool/report-to-video/post-item.mjs
@@ -9,7 +9,8 @@
// repostedBy?: { author, handle }, quoted?: <ref>, parents?: [<ref>, …],
// replyingTo?: "<handle>", parentShot?: "<file>",
// media?: [{ src, kind: "image"|"video"|"gif", seconds?, width?, height?, audio?,
-// start?, end?, mute?, crop?: [x, y, w, h], push?, words? }],
+// start?, end?, mute?, crop?: [x, y, w, h], push?, words?,
+// blur?: { on, strength?, boxes?, label? } }], (post-censor.mjs)
// mediaLayout?: "sequence"|"grid", hold?, redact?, onscreen? }
//
// where a <ref> (a post it quotes, the posts it answers, nearest first) is
@@ -29,6 +30,7 @@ import {
isNarrated, narrationSchedule, postNarrationFiles, postNarrationKnobs, validatePostNarration,
} from "./post-narration.mjs";
import { BAR_CSS, barsHtml, redactEntry, validatePostsRender } from "./post-redact.mjs";
+import { blurErrors } from "./post-censor.mjs";
/** The platforms a post item may come from (deck.mjs POST_PLATFORMS). */
export const POST_ITEM_PLATFORMS = Object.freeze(["x", "bluesky", "web"]);
@@ -488,6 +490,7 @@ function mediaErrors(m, where) {
const er2 = relFileError(m.words, `${where}.words`);
if (er2) errors.push(er2);
}
+ errors.push(...blurErrors(m.blur, `${where}.blur`));
return errors;
}
diff --git a/umtool/report-to-video/post-redact.mjs b/umtool/report-to-video/post-redact.mjs
@@ -13,9 +13,11 @@
// render.posts.redact [{ term, wholeWord?, note? }] the project's own list
// <transcripts>/redactions.json the same shape every project's (the corpus's)
// channels/<slug>/posts-markup.json one post's MARKUP:
-// { "<postId>": { redact: [{ term, wholeWord?, scope? } | { start, end, scope?, index? }] } }
+// { "<postId>": { redact?: [{ term, wholeWord?, scope? } | { start, end, scope?, index? }],
+// censor?: [{ media: <i>, blur?: {strength?, boxes?, label?} }] } }
// a term (in `scope` -- "text", "parent", "quoted" -- or the whole post), or a span of the
-// archived text, in code units (`index`: which parent, nearest first)
+// archived text, in code units (`index`: which parent, nearest first); `censor` blurs an
+// attachment of the post in every project (post-censor.mjs)
//
// NOTHING IS REWRITTEN: the archive's rows, the manifest's snapshot and a
// narration's script keep their words. Redaction happens only where PUBLIC
@@ -25,7 +27,8 @@
// line and an attachment's burnt-in captions. umtool's own views show the
// words; Play's "As published" shows the bars.
//
-// PURE and dependency-free (the build, the route, Play and the writers).
+// PURE (the build, the route, Play and the writers).
+import { censorMarkupErrors } from "./post-censor.mjs";
/** The mark a redacted code unit becomes (a private-use character: never typed, never drawn as a letter). */
export const REDACT_MARK = "";
@@ -184,16 +187,17 @@ export function validatePostsRender(render) {
/** Every reason a channel's posts-markup.json is refused. */
export function validatePostsMarkup(doc, where = "posts-markup.json") {
- if (!isObj(doc)) return [`${where} must be {"<postId>": {redact: […]}}`];
+ if (!isObj(doc)) return [`${where} must be {"<postId>": {redact?: […], censor?: […]}}`];
const errors = [];
for (const [id, m] of Object.entries(doc)) {
const w = `${where} ${id}`;
if (!/^[A-Za-z0-9_-]{1,128}$/.test(id)) errors.push(`${w}: not a post id`);
- if (!isObj(m) || !Array.isArray(m.redact)) {
- errors.push(`${w} must be {redact: […]}`);
+ if (!isObj(m) || (m.redact !== undefined && !Array.isArray(m.redact)) || Object.keys(m).some((k) => !["redact", "censor", "note"].includes(k))) {
+ errors.push(`${w} must be {redact?: […], censor?: […]}`);
continue;
}
- m.redact.forEach((r, i) => {
+ errors.push(...censorMarkupErrors(m.censor, `${w}.censor`));
+ (m.redact ?? []).forEach((r, i) => {
const wi = `${w}.redact[${i}]`;
if (!isObj(r)) return errors.push(`${wi} must be {term} or {start, end}`);
if (r.scope !== undefined && !POST_MARKUP_SCOPES.includes(r.scope)) errors.push(`${wi}.scope must be one of ${POST_MARKUP_SCOPES.join(", ")}`);
diff --git a/umtool/report-to-video/post-redact.test.mjs b/umtool/report-to-video/post-redact.test.mjs
@@ -80,7 +80,7 @@ test("a post's markup: a term in one scope, or a span of its archived text", ()
assert.deepEqual(termsFor(entry, red).map((t) => t.term), ["Zed"]);
assert.deepEqual(termsFor({ post: "other/1" }, red), []);
assert.deepEqual(validatePostsMarkup({ "7": { redact: [{ term: "Zed" }, { start: 1, end: 3, scope: "quoted" }] } }), []);
- const bad = validatePostsMarkup({ "7": { redact: [{ start: 3, end: 1 }, { term: "Zed", scope: "elsewhere" }] }, "a/b": {} });
+ const bad = validatePostsMarkup({ "7": { redact: [{ start: 3, end: 1 }, { term: "Zed", scope: "elsewhere" }] }, "a/b": {}, "8": { other: 1 } });
assert.equal(bad.length, 4, bad.join("; "));
});
diff --git a/umtool/report-to-video/post-render.mjs b/umtool/report-to-video/post-render.mjs
@@ -21,6 +21,7 @@ import { pathToFileURL } from "node:url";
import { POST_PICTURE_XFADE, POST_PUSH, postCardHtml, postItemPlan, postLayout, stepBoxes } from "./post-item.mjs";
import { isNarrated, narrationLevelDb, pickedTake, postNarrationFilters } from "./post-narration.mjs";
import { redactEntry, redactionOn, spokenWithout, termsFor } from "./post-redact.mjs";
+import { blurFilters, blurOn, censorEntry, labelFilter } from "./post-censor.mjs";
const r3 = (v) => Math.round(v * 1000) / 1000;
const num = (v) => String(r3(v));
@@ -103,6 +104,8 @@ export function postSegmentArgs({ entry, box, plan, layout, cards, files, render
const file = files[m.i];
const crop = Array.isArray(m.crop) ? `crop=iw*${num(m.crop[2])}:ih*${num(m.crop[3])}:iw*${num(m.crop[0])}:ih*${num(m.crop[1])},` : "";
const label = `m${si}_${j}`;
+ // A censored attachment (post-censor.mjs): its chain ends in a raw label, blurred into `label`.
+ const raw = blurOn(m) ? `${label}r` : label;
if (step.kind === "image" || step.kind === "grid") {
if (m.push === true) {
const frames = Math.max(1, Math.round((until - shownFrom) * fps));
@@ -110,11 +113,11 @@ export function postSegmentArgs({ entry, box, plan, layout, cards, files, render
parts.push(
`[${k}:v]${crop}scale=${b.width * 2}:${b.height * 2},setsar=1,` +
`zoompan=z='1+${POST_PUSH}*on/${frames}':x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)':d=${frames}:s=${b.width}x${b.height}:fps=${fps},` +
- `setpts=PTS-STARTPTS+${num(shownFrom)}/TB${fadeIn(shownFrom)}[${label}]`,
+ `setpts=PTS-STARTPTS+${num(shownFrom)}/TB${fadeIn(shownFrom)}[${raw}]`,
);
} else {
const k = add(["-loop", "1", "-framerate", String(fps), "-t", num(until), "-i", file]);
- parts.push(`[${k}:v]${crop}scale=${b.width}:${b.height},setsar=1,fps=${fps}${fadeIn(shownFrom)}[${label}]`);
+ parts.push(`[${k}:v]${crop}scale=${b.width}:${b.height},setsar=1,fps=${fps}${fadeIn(shownFrom)}[${raw}]`);
}
} else {
// A video or a GIF: its span from srcFrom, its first frame held from the item's start until it plays.
@@ -122,7 +125,7 @@ export function postSegmentArgs({ entry, box, plan, layout, cards, files, render
const k = add([...(step.loop ? ["-stream_loop", "-1"] : []), "-ss", num(step.srcFrom), "-t", num(len), "-i", file]);
parts.push(
`[${k}:v]${crop}scale=${b.width}:${b.height},setsar=1,fps=${fps},setpts=PTS-STARTPTS,` +
- `tpad=start_duration=${num(step.at)}:start_mode=clone:stop_mode=clone:stop_duration=${num(T)}[${label}]`,
+ `tpad=start_duration=${num(step.at)}:start_mode=clone:stop_mode=clone:stop_duration=${num(T)}[${raw}]`,
);
if (step.sound) {
const ms = Math.round(step.at * 1000);
@@ -130,7 +133,14 @@ export function postSegmentArgs({ entry, box, plan, layout, cards, files, render
audio.push({ label: `a${si}`, chain: `[${k}:a]aresample=${render.audioRate ?? 48000},aformat=channel_layouts=stereo,asetpts=PTS-STARTPTS,atrim=0:${num(dur)},afade=t=in:d=0.04,afade=t=out:st=${num(Math.max(0, dur - 0.06))}:d=0.06,adelay=${ms}|${ms}[a${si}]` });
}
}
+ if (raw !== label) parts.push(...blurFilters(raw, label, m, b));
lay(label, b.x, b.y, shownFrom, until);
+ // Its label ("Censored") on the frame, at the attachment's corner, while it is up.
+ const lf = blurOn(m) ? labelFilter(cur, `b${n + 1}`, m, b, { from: shownFrom, to: until, fontfile, scale: box.height / 1080 }) : null;
+ if (lf) {
+ parts.push(lf);
+ cur = `b${++n}`;
+ }
});
});
// A video attachment's words (its transcript), at the slot's foot.
@@ -232,6 +242,8 @@ export async function renderPostCards(entry, { box, render, dir, manifestDir, la
* drawn as bars, dropped from its captions). Returns the segment's path.
*/
export async function buildPostSegment(entry, { render, outDir, manifestDir, box, place = [], encode = [], exec, ffmpeg = "ffmpeg", emit = () => {}, avatars = {}, redaction = null }) {
+ // A channel's markup may censor an attachment for every project (post-censor.mjs); the item's own blur wins.
+ entry = censorEntry(entry, redaction);
const seg = path.join(outDir, "segments", `${entry.id}.mp4`);
const plan = postItemPlan(entry, render);
const layout = postLayout(entry, box);