// POST ITEMS (report-to-video/post-item.mjs): a cut that mixes clips and posts // played as items of their own (post-items.spec.ts). // // post-items-fixture c01 a clip (playvid, the fixture's synthetic window, // cached in out/clips-raw), then three post items from a // SYNTHESIZED posts archive, channels/postchan-x: // p-txt text only (a self-reply: its parent drawn // above it, the subject's, plain) // p-img a picture (posts-media/…/2_1.png, 320×180) // p-vid a video with sound (posts-media/…/3_1.mp4, // 4 s testsrc 320×180, a 440 Hz tone), a // reply to a PRIVATE account (blurred) // the deck on, one section after c01. The archive also // holds a fourth post (4, text) the reel spec adds. // WRITES its manifest (the bench's trim): the spec puts // it back before each test. // // Synthetic, like every fixture. import { copyFileSync, 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)}`); }; export const POST_CHANNEL = "postchan-x"; const row = (id, o) => ({ id, slug: `${POST_CHANNEL}/${id}`, channelSlug: POST_CHANNEL, author: "postsubject", authorName: "Post Subject", createdAt: "2026-10-30T10:00:00.000Z", uploadDate: "20261030", text: "", url: `https://x.com/postsubject/status/${id}`, platform: "twitter", isReply: false, isRepost: false, links: [], threadId: id, lang: "en", engagement: { likes: 12, reposts: 3, replies: 1, quotes: 0 }, ...o, }); /** * @param {{ reports: string, channels: string, deckManifest: Function, cachedWindow: string }} o */ export function makePostItemsFixture({ reports, channels, deckManifest, cachedWindow }) { // The archive and its captures. const ch = path.join(channels, POST_CHANNEL); mkdirSync(path.join(ch, "posts"), { recursive: true }); writeFileSync(path.join(ch, "config.json"), JSON.stringify({ handling: "transcribe", sourceKind: "social", socialHandle: "postsubject", platform: "twitter", name: "Post Subject (X)" }, null, 2)); const rows = [ row("0", { createdAt: "2026-10-30T09:00:00.000Z", text: "The first thing I said about it." }), row("1", { createdAt: "2026-10-30T10:00:00.000Z", text: "And a plain post with nothing but words in it, to read.", isReply: true, replyTo: { id: "0", author: "postsubject" } }), row("2", { createdAt: "2026-10-30T11:00:00.000Z", text: "A picture of the thing.", mediaCount: 1 }), row("9", { author: "someone_private", authorName: "Private Person", createdAt: "2026-10-30T11:30:00.000Z", text: "is this really true?" }), row("3", { createdAt: "2026-10-30T12:00:00.000Z", text: "@someone_private Yes, and here is the video.", mediaCount: 1, isReply: true, replyTo: { id: "9", author: "someone_private" } }), row("4", { createdAt: "2026-10-31T12:00:00.000Z", text: "One more post, a day later." }), ]; writeFileSync(path.join(ch, "posts", "2026-10.jsonl"), rows.map((r) => JSON.stringify(r)).join("\n") + "\n"); const cap2 = path.join(ch, "posts-media", "2"); const cap3 = path.join(ch, "posts-media", "3"); mkdirSync(cap2, { recursive: true }); mkdirSync(cap3, { recursive: true }); ff(["-f", "lavfi", "-i", "testsrc=size=320x180:rate=1:duration=1", "-frames:v", "1", path.join(cap2, "2_1.png")]); ff([ "-f", "lavfi", "-i", "testsrc=size=320x180:rate=30:duration=4", "-f", "lavfi", "-i", "sine=frequency=440:duration=4", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-c:a", "aac", "-ar", "48000", "-ac", "2", "-shortest", path.join(cap3, "3_1.mp4"), ]); writeFileSync(path.join(cap2, "capture.json"), JSON.stringify({ version: 1, id: "2", media: [{ name: "2_1.png", url: "https://pbs.twimg.com/media/x" }] })); writeFileSync(path.join(cap3, "capture.json"), JSON.stringify({ version: 1, id: "3", media: [{ name: "3_1.mp4", url: "https://video.twimg.com/amplify_video/3/vid/x.mp4" }] })); // The project: one clip, then the three post items as `posts reel` writes them. const name = "post-items-fixture"; const dir = path.join(reports, name); mkdirSync(path.join(dir, "out", "clips-raw"), { recursive: true }); copyFileSync(cachedWindow, path.join(dir, "out", "clips-raw", "playvid_0.00-9.00.mp4")); const media = path.join(dir, "posts-media", POST_CHANNEL); mkdirSync(path.join(media, "2"), { recursive: true }); mkdirSync(path.join(media, "3"), { recursive: true }); copyFileSync(path.join(cap2, "2_1.png"), path.join(media, "2", "2_1.png")); copyFileSync(path.join(cap3, "3_1.mp4"), path.join(media, "3", "3_1.mp4")); const base = (r) => ({ type: "post", post: `${POST_CHANNEL}/${r.id}`, platform: "x", author: r.authorName, handle: r.author, date: r.createdAt, text: r.text, url: r.url, engagement: r.engagement, subjects: ["postsubject"], }); const timeline = [ { type: "clip", id: "c01", video: "playvid", start: 1.0, end: 3.0, cite: 1, section: 0, lock: true, quote: "This is a complete sentence.", onscreen: { title: "24 Oct 2020" } }, { ...base(rows[1]), id: "p-txt", parents: [{ id: "0", author: "Post Subject", handle: "postsubject", date: rows[0].createdAt, text: rows[0].text, url: rows[0].url }] }, { ...base(rows[2]), id: "p-img", media: [{ src: `posts-media/${POST_CHANNEL}/2/2_1.png`, kind: "image", width: 320, height: 180 }] }, { ...base(rows[4]), id: "p-vid", parents: [{ id: "9", author: "Private Person", handle: "someone_private", date: rows[3].createdAt, text: rows[3].text, url: rows[3].url }], media: [{ src: `posts-media/${POST_CHANNEL}/3/3_1.mp4`, kind: "video", seconds: 4, width: 320, height: 180, audio: true }], }, ]; const m = deckManifest(name, "The Post Items Fixture", timeline); m.provenance = { ...m.provenance, channelSlug: POST_CHANNEL }; m.render.fetchPad = 0; m.render.lockedEdges = false; m.render.chrome = { ...m.render.chrome, deck: { ...(m.render.chrome?.deck ?? {}), markers: [{ after: "c01", label: "The posts" }] } }; writeFileSync(path.join(dir, "video.manifest.json"), JSON.stringify(m, null, 2) + "\n"); return { dir }; }