// THE COMBO COUNTER (report-to-video/post-combo.mjs): a posts cut where the // same reaction GIF answers three people (post-combo.spec.ts). // // post-combo-fixture p-c1 the GIF's first use (no badge) // p-txt words only, between them // p-c2 the same bytes, another X id (re-uploaded): ×2 // p-c3 again, its capture only in the corpus: ×3 // p-oth another GIF (no repeat) // the deck on. Each GIF is 2 s of testsrc, silent, as X // serves a GIF. WRITES its manifest (the bench's // toggle): 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 COMBO_CHANNEL = "combochan-x"; /** @param {{ reports: string, channels: string, deckManifest: Function }} o */ export function makePostComboFixture({ reports, channels, deckManifest }) { const name = "post-combo-fixture"; const dir = path.join(reports, name); const media = path.join(dir, "posts-media", COMBO_CHANNEL); for (const id of ["1", "3", "4", "5"]) mkdirSync(path.join(media, id), { recursive: true }); const gif = path.join(media, "1", "1_1.mp4"); ff(["-f", "lavfi", "-i", "testsrc=size=498x280:rate=25:duration=2", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-an", gif]); ff(["-f", "lavfi", "-i", "testsrc2=size=498x280:rate=25:duration=2", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-an", path.join(media, "5", "5_1.mp4")]); copyFileSync(gif, path.join(media, "3", "3_1.mp4")); copyFileSync(gif, path.join(media, "4", "4_1.mp4")); const bytes = readFileSync(gif); const sha = createHash("sha256").update(bytes).digest("hex"); // The captures' records: p-c1's and p-c2's copied into the project; p-c3's only in the corpus. writeFileSync(path.join(media, "1", "capture.json"), JSON.stringify({ version: 1, id: "1", media: [{ name: "1_1.mp4", bytes: bytes.length, sha256: sha, url: "https://video.twimg.com/tweet_video/AAAA.mp4" }] })); writeFileSync(path.join(media, "3", "capture.json"), JSON.stringify({ version: 1, id: "3", media: [{ name: "3_1.mp4", bytes: bytes.length, sha256: sha, url: "https://video.twimg.com/tweet_video/BBBB.mp4" }] })); const cap4 = path.join(channels, COMBO_CHANNEL, "posts-media", "4"); mkdirSync(cap4, { recursive: true }); writeFileSync(path.join(cap4, "capture.json"), JSON.stringify({ version: 1, id: "4", media: [{ name: "4_1.mp4", bytes: bytes.length, sha256: sha, url: "https://video.twimg.com/tweet_video/CCCC.mp4" }] })); const at = (d) => `2026-11-0${d}T10:00:00.000Z`; const base = (id, day, text, o = {}) => ({ type: "post", id, post: `${COMBO_CHANNEL}/${id.replace(/^p-c?/, "")}`, platform: "x", author: "Combo Subject", handle: "combosubject", date: at(day), text, url: `https://x.com/combosubject/status/${id}`, engagement: { likes: 3 }, subjects: ["combosubject"], ...o, }); const g = (id) => [{ src: `posts-media/${COMBO_CHANNEL}/${id}/${id}_1.mp4`, kind: "gif", seconds: 2, width: 498, height: 280 }]; const timeline = [ base("p-c1", 1, "Me, every time.", { post: `${COMBO_CHANNEL}/1`, media: g("1") }), base("p-txt", 1, "Words only, between the replies.", { post: `${COMBO_CHANNEL}/2` }), base("p-c2", 2, "Again.", { post: `${COMBO_CHANNEL}/3`, media: g("3") }), base("p-c3", 3, "And again.", { post: `${COMBO_CHANNEL}/4`, media: g("4") }), base("p-oth", 3, "Something else.", { post: `${COMBO_CHANNEL}/5`, media: g("5") }), ]; const m = deckManifest(name, "The Combo Fixture", timeline); m.provenance = { ...m.provenance, channelSlug: COMBO_CHANNEL, channelsDir: path.relative(dir, channels) }; writeFileSync(path.join(dir, "video.manifest.json"), JSON.stringify(m, null, 2) + "\n"); return { dir }; }