// A FAST BURST OF POST ITEMS (operator, 4 Nov: "The rapid sections on play the // cut don't load fast enough such that most of it is cut out"): Play's // prefetch and its gate (PlayCut.tsx, playEngine/postPreload.ts, engine.ts // `gate`), played by play-preload.spec.ts with every post-item request slowed. // // play-preload-fixture pp-1 … pp-10 ten narrated posts at `pace: "fast"`, the // clock on: each read by a take of // 0.6-1.3 s (a tone), so each item is // ~1.3-2 s, back to back; pp-3, pp-6 and // pp-9 carry a picture, pp-5 a 1.2 s video; // pp-10 a stinger an hour EARLIER (the // clock rewinds). The deck on. Read only. // // Synthetic, like every fixture. import { mkdirSync, writeFileSync } from "node:fs"; 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)}`); }; /** The burst: id, its take's seconds, its attachment. */ export const PLAY_PRELOAD_ITEMS = [ ["pp-1", 0.8, null], ["pp-2", 0.6, null], ["pp-3", 1.0, "image"], ["pp-4", 0.7, null], ["pp-5", 1.1, "video"], ["pp-6", 0.9, "image"], ["pp-7", 0.6, null], ["pp-8", 1.3, null], ["pp-9", 0.8, "image"], ["pp-10", 0.9, null], ]; /** @param {{ reports: string, deckManifest: Function }} o */ export function makePlayPreloadFixture({ reports, deckManifest }) { const name = "play-preload-fixture"; const dir = path.join(reports, name); const chan = "burstchan-x"; const colours = ["red", "green", "blue", "yellow", "purple", "orange", "cyan", "white", "pink", "gray"]; const timeline = PLAY_PRELOAD_ITEMS.map(([id, secs, kind], k) => { const n = id.slice(3); const media = path.join(dir, "posts-media", chan, n); mkdirSync(media, { recursive: true }); const takes = path.join(dir, "narration", "posts", n); mkdirSync(takes, { recursive: true }); ff(["-f", "lavfi", "-i", `sine=frequency=${300 + 40 * k}:sample_rate=48000:duration=${secs}`, "-ac", "1", "-c:a", "pcm_s16le", path.join(takes, "take-1.orpheus-zac.wav")]); const att = []; if (kind === "image") { ff(["-f", "lavfi", "-i", `color=c=${colours[k]}:size=320x180`, "-frames:v", "1", path.join(media, `${n}_1.png`)]); att.push({ src: `posts-media/${chan}/${n}/${n}_1.png`, kind: "image", width: 320, height: 180 }); } else if (kind === "video") { ff([ "-f", "lavfi", "-i", "testsrc=size=320x180:rate=30:duration=1.2", "-f", "lavfi", "-i", "sine=frequency=880:duration=1.2", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-c:a", "aac", "-ar", "48000", "-ac", "2", "-shortest", path.join(media, `${n}_1.mp4`), ]); att.push({ src: `posts-media/${chan}/${n}/${n}_1.mp4`, kind: "video", seconds: 1.2, width: 320, height: 180, audio: true }); } const text = `Burst post ${n}: you want to die? ${"again ".repeat(k % 3)}`.trim(); // A minute apart, the stinger an hour back (the clock rewinds). const date = new Date(Date.UTC(2026, 10, 4, 9, id === "pp-10" ? 0 : 10 + k)).toISOString(); return { type: "post", id, post: `${chan}/${n}`, platform: "x", author: "Burst Subject", handle: "burstsubject", date, text, url: `https://x.com/burstsubject/status/${n}`, engagement: { likes: k }, subjects: ["burstsubject"], ...(att.length ? { media: att } : {}), narration: { script: text, pace: "fast", takes: [{ file: `narration/posts/${n}/take-1.orpheus-zac.wav`, engine: "orpheus", voice: "zac", seconds: secs, script: text, at: "2026-11-04T00:00:00.000Z" }], pick: 0, }, }; }); const m = deckManifest(name, "The Play Preload Fixture", timeline); m.provenance = { ...m.provenance, channelSlug: chan }; m.render = { ...m.render, posts: { ...(m.render.posts ?? {}), clock: { on: true } } }; writeFileSync(path.join(dir, "video.manifest.json"), JSON.stringify(m, null, 2) + "\n"); return { dir }; }