// MEDIA SCENES (report-to-video/post-media-scene.mjs) and the BAND CENSOR // (post-censor.mjs `band`): a posts cut where one picture is answered by // several messages in a row (media-scenes.spec.ts). // // media-scenes-fixture p-j words only, `scene: "join"`: it joins the scene after it // p-a the picture's first use (the anchor): censored below the middle // p-b the same bytes, another X id // p-c the same again // p-x another picture (no repeat) // the deck on, no narration: each item is its read (3 s and more), // the picture beside the card from the first frame. WRITES its manifest // (the bench's band, the scene knob): the spec puts it back before each test. // // Synthetic, like every fixture. import { copyFileSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"; import { createHash } from "node:crypto"; import { spawnSync } from "node:child_process"; import path from "node:path"; const ff = (args) => { const r = spawnSync("ffmpeg", ["-v", "error", "-y", ...args]); if (r.status !== 0) throw new Error(`ffmpeg ${args.join(" ")}: ${String(r.stderr)}`); }; export const SCENE_CHANNEL = "scenechan-x"; /** @param {{ reports: string, deckManifest: Function }} o */ export function makeMediaScenesFixture({ reports, deckManifest }) { const name = "media-scenes-fixture"; const dir = path.join(reports, name); const media = path.join(dir, "posts-media", SCENE_CHANNEL); for (const id of ["a", "b", "c", "x"]) mkdirSync(path.join(media, id), { recursive: true }); const pic = path.join(media, "a", "a_1.png"); ff(["-f", "lavfi", "-i", "testsrc=size=640x360:rate=1:duration=1", "-frames:v", "1", pic]); ff(["-f", "lavfi", "-i", "testsrc2=size=640x360:rate=1:duration=1", "-frames:v", "1", path.join(media, "x", "x_1.png")]); copyFileSync(pic, path.join(media, "b", "b_1.png")); copyFileSync(pic, path.join(media, "c", "c_1.png")); const bytes = readFileSync(pic); const sha = createHash("sha256").update(bytes).digest("hex"); // The captures' records: the same bytes under three X ids (re-uploaded each time). for (const [id, xid] of [["a", "AAAA"], ["b", "BBBB"], ["c", "CCCC"]]) { writeFileSync(path.join(media, id, "capture.json"), JSON.stringify({ version: 1, id, media: [{ name: `${id}_1.png`, bytes: bytes.length, sha256: sha, url: `https://pbs.twimg.com/media/${xid}?format=png` }] })); } const at = (h) => `2026-11-02T2${h}:00:00.000Z`; const base = (id, h, text, o = {}) => ({ type: "post", id, post: `${SCENE_CHANNEL}/${id.replace(/^p-/, "")}`, platform: "x", author: "Scene Subject", handle: "scenesubject", date: at(h), text, url: `https://x.com/scenesubject/status/${id}`, engagement: { likes: 2 }, subjects: ["scenesubject"], ...o, }); const img = (id, o = {}) => [{ src: `posts-media/${SCENE_CHANNEL}/${id}/${id}_1.png`, kind: "image", width: 640, height: 360, ...o }]; const timeline = [ base("p-j", 0, "Look at this picture, everyone.", { scene: "join" }), base("p-a", 1, "First message about the picture.", { media: img("a", { blur: { on: true, band: { below: 0.5 } } }) }), base("p-b", 2, "Second message, the same picture again.", { media: img("b") }), base("p-c", 3, "Third message, still the same picture.", { media: img("c") }), base("p-x", 3, "Something else entirely.", { media: img("x") }), ]; const m = deckManifest(name, "The Media Scenes Fixture", timeline); m.provenance = { ...m.provenance, channelSlug: SCENE_CHANNEL }; writeFileSync(path.join(dir, "video.manifest.json"), JSON.stringify(m, null, 2) + "\n"); return { dir }; }