// What video-entry.spec.ts plays and writes (report-to-video/video-entry.mjs; umtool/docs/report-video.md, // "A video entry"): a short deck cut that ENDS on a video entry -- a file of the project played full frame, // its chrome off -- and a take with its own timeline that the CLI's `timeline --take add-video` writes into. // // c01 playvid 1.0-3.0 k01 card 1.5 s fin video media/fin.mp4 1.0-3.0 (bass 6, the default entrance) // // media/fin.mp4 is synthetic (testsrc2 1080x1200, a 60 Hz tone under a 1 kHz one, 3 s), made here with ffmpeg. import { copyFileSync, mkdirSync, writeFileSync } from "node:fs"; import { spawnSync } from "node:child_process"; import path from "node:path"; /** * @param {{ reports: string, deckManifest: Function, cachedWindow: string }} o */ export function makeVideoEntryFixture({ reports, deckManifest, cachedWindow }) { const name = "video-entry-fixture"; const dir = path.join(reports, name); mkdirSync(path.join(dir, "media"), { recursive: true }); const r = spawnSync("ffmpeg", [ "-nostdin", "-v", "error", "-y", "-f", "lavfi", "-i", "testsrc2=size=1080x1200:rate=30:duration=3", "-f", "lavfi", "-i", "sine=frequency=60:duration=3", "-f", "lavfi", "-i", "sine=frequency=1000:duration=3", "-filter_complex", "[1:a]volume=0.3[l];[2:a]volume=0.1[h];[l][h]amix=inputs=2[a]", "-map", "0:v", "-map", "[a]", "-c:v", "libx264", "-preset", "ultrafast", "-pix_fmt", "yuv420p", "-c:a", "aac", "-t", "3", path.join(dir, "media", "fin.mp4"), ], { encoding: "utf8" }); if (r.status !== 0) throw new Error(`ffmpeg failed: ${r.stderr || r.status}`); 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" } }, { type: "card", id: "k01", style: "chapter", seconds: 1.5, heading: "Before the finale" }, { type: "video", id: "fin", src: "media/fin.mp4", from: 1, fileSeconds: 3, fit: "contain", audio: { bass: 6 }, title: "The finale" }, ]; const m = deckManifest(name, "The Video Entry Fixture", timeline); m.render.fetchPad = 0; writeFileSync(path.join(dir, "video.manifest.json"), JSON.stringify({ ...m, render: { ...m.render, lockedEdges: false } }, null, 2) + "\n"); mkdirSync(path.join(dir, "out", "clips-raw"), { recursive: true }); copyFileSync(cachedWindow, path.join(dir, "out", "clips-raw", "playvid_0.00-9.00.mp4")); // A draft take with its own timeline (the clip and the card): the CLI adds the finale to it, and only to it. mkdirSync(path.join(dir, "takes", "walk"), { recursive: true }); writeFileSync( path.join(dir, "takes", "walk", "take.json"), JSON.stringify( { id: "walk", group: "takes", order: 1, label: "Walk", kind: "different", summary: "the clip and the card", preview: "preview.mp4", window: "full", style: null, draft: true, patch: { timeline: [timeline[0], timeline[1]] }, }, null, 2, ) + "\n", ); copyFileSync(cachedWindow, path.join(dir, "takes", "walk", "preview.mp4")); return { dir }; }