// BEAT REELS (lane/beat-reels): a project with a take that HAS a rendered // master, so a reel plays, walks and cuts from it (reel-play.spec.ts). // // reel-fixture six clips c01–c06 on vid1 (1.5 s each, 1+2i – 2.5+2i) // and takes/draft-1, built: its master // out/reel-fixture.mp4 is SYNTHESIZED (testsrc 320×180, // 30 fps, a 440 Hz tone, 10.5 s = 315 frames), with the // build records `umtool trailer` maps through -- // out/sourced/schedule.json (each clip a 2.0 s segment, // 0.3 s dissolves: c0k starts at 1.7·(k−1)) and // segments/.cut.json (each cut from 0.25 s before its // clip). Two reels: promo/trailer-beats.json (c01 1–2.5, // c03 5–6.5, c05 9–10.4: 3.8 s with the 0.3 s crossfades, // every edge clear of the master's own dissolves) // and promo/teaser-beats.json (c02 alone, titled). // WRITES promo/ and takes/draft-1/out/ (a cut): the spec // puts both back before each test. // reel-none-fixture the same cut, its one take a DRAFT with no master: a // reel says so and offers the render. // // Synthetic, like every fixture. import { spawnSync } from "node:child_process"; import { mkdirSync, writeFileSync } from "node:fs"; import path from "node:path"; const json = (doc, indent = 2) => JSON.stringify(doc, null, indent) + "\n"; const write = (dir, name, text) => { mkdirSync(path.dirname(path.join(dir, name)), { recursive: true }); writeFileSync(path.join(dir, name), text); }; export const REEL_SEG = 2.0; export const REEL_XFADE = 0.3; export const REEL_TOTAL = 5 * (REEL_SEG - REEL_XFADE) + REEL_SEG; // 10.5 const clips = () => ["c01", "c02", "c03", "c04", "c05", "c06"].map((id, i) => ({ type: "clip", id, video: "vid1", start: 1 + i * 2, end: 2.5 + i * 2, cite: 1 + i * 2, citeUrl: `https://archive.example/?v=testchan%2Fvid1&t=${1 + i * 2}`, lock: true, title: "The Fixture Stream", date: "2026-10-27", quote: `the words of ${id}`, })); const take = (id, { draft = false } = {}) => ({ id, group: "takes", order: 1, label: `${id}: the reel fixture's take`, kind: "reference", summary: "", changes: [], preview: "preview.mp4", seconds: draft ? null : REEL_TOTAL, builtAt: draft ? null : "2026-11-02T12:00:00.000Z", style: null, patch: null, window: "full", ...(draft ? { draft: true } : {}), }); /** * @param {{ reports: string, deckManifest: Function }} o */ export function makeReelFixture({ reports, deckManifest }) { const dir = path.join(reports, "reel-fixture"); const m = deckManifest("reel-fixture", "The Reel Fixture", clips()); write(dir, "video.manifest.json", json(m)); const takeDir = path.join(dir, "takes", "draft-1"); // The take's own manifest: a small, fast encode for the trailer's one pass. const tm = { ...m, render: { ...m.render, width: 320, height: 180, fps: 30, crf: 32, preset: "ultrafast", audioBitrate: "64k" } }; write(takeDir, "video.manifest.json", json(tm)); write(takeDir, "take.json", json(take("draft-1"))); const out = path.join(takeDir, "out"); mkdirSync(path.join(out, "sourced", "segments"), { recursive: true }); const r = spawnSync("ffmpeg", [ "-nostdin", "-v", "error", "-y", "-f", "lavfi", "-i", `testsrc=size=320x180:rate=30:duration=${REEL_TOTAL}`, "-f", "lavfi", "-i", `sine=frequency=440:duration=${REEL_TOTAL}`, "-map", "0:v", "-map", "1:a", "-t", String(REEL_TOTAL), "-c:v", "libx264", "-preset", "ultrafast", "-g", "15", "-pix_fmt", "yuv420p", "-c:a", "aac", "-ar", "48000", "-ac", "2", "-movflags", "+faststart", path.join(out, "reel-fixture.mp4"), ], { encoding: "utf8" }); if (r.status !== 0) throw new Error(`ffmpeg failed: ${r.stderr || r.status}`); const segments = clips().map((c, i) => ({ id: c.id, type: "clip", start: Number((i * (REEL_SEG - REEL_XFADE)).toFixed(3)), duration: REEL_SEG })); write(out, path.join("sourced", "schedule.json"), json({ version: 1, kind: "deck", fps: 30, transition: REEL_XFADE, total: REEL_TOTAL, segments })); for (const c of clips()) write(out, path.join("sourced", "segments", `${c.id}.cut.json`), json({ version: 1, id: c.id, start: c.start - 0.25, end: c.start - 0.25 + REEL_SEG })); write(dir, path.join("promo", "trailer-beats.json"), json([ { id: "c01", start: 1, end: 2.5 }, { id: "c03", start: 5, end: 6.5 }, { id: "c05", start: 9, end: 10.4 }, ], 1)); write(dir, path.join("promo", "teaser-beats.json"), json({ title: "The teaser", beats: [{ id: "c02", start: 3, end: 4.5 }] })); const none = path.join(reports, "reel-none-fixture"); write(none, "video.manifest.json", json(deckManifest("reel-none-fixture", "The Reel None Fixture", clips()))); write(path.join(none, "takes", "draft-1"), "take.json", json(take("draft-1", { draft: true }))); write(none, path.join("promo", "trailer-beats.json"), json([{ id: "c01", start: 1, end: 2.5 }])); return { dir, none }; }