// A synthetic poker stream for the frame scan's tests (release 30, lane P). // No real stream, no real poker client: ffmpeg's `color` source and // `drawtext` paint a fake client — a lobby, a table whose numbers change on a // schedule, a break screen, a bust — into a short H.264 file with a keyframe // every two seconds, so the scan's keyframe-only sampling has something to // find. `pokerTruthAt(t)` is what each moment shows, for the fake models' // answers, and `SPOKEN_CUES` the transcript the streamer "said". // // const { file, duration } = await makeSyntheticPokerStream(dir); // pokerTruthAt(95) → { phase: "table", tournament: {...}, hero: {...} } import { execFile } from "node:child_process"; import { promisify } from "node:util"; import path from "node:path"; const run = promisify(execFile); export const SYNTH_TOURNAMENT = "Synthetic Cup"; export const SYNTH_DURATION = 210; // What the fake client shows, by time. Each span is one still picture. Players // left is a stats header's "position N of M" (both numbers). export const SYNTH_SPANS = [ { from: 0, to: 30, phase: "lobby", tournament: { name: SYNTH_TOURNAMENT, totalPlayers: 120, playersLeft: 120, position: 60 } }, { from: 30, to: 90, phase: "table", tournament: { name: SYNTH_TOURNAMENT, level: 3, smallBlind: 100, bigBlind: 200, playersLeft: 85, position: 40, totalPlayers: 120 }, hero: { stack: 20000 } }, { from: 90, to: 120, phase: "table", tournament: { name: SYNTH_TOURNAMENT, level: 4, smallBlind: 150, bigBlind: 300, playersLeft: 60, position: 22, totalPlayers: 120 }, hero: { stack: 41000 } }, { from: 120, to: 150, phase: "table", tournament: { name: SYNTH_TOURNAMENT, level: 5, smallBlind: 200, bigBlind: 400, playersLeft: 9, position: 8, totalPlayers: 120 }, hero: { stack: 9000 } }, { from: 150, to: 180, phase: "break" }, { from: 180, to: 200, phase: "table", tournament: { name: SYNTH_TOURNAMENT, level: 6, smallBlind: 300, bigBlind: 600, playersLeft: 7, position: 7, totalPlayers: 120 }, hero: { stack: 0 }, event: "eliminated" }, { from: 200, to: 210, phase: "lobby", tournament: { name: SYNTH_TOURNAMENT, totalPlayers: 120, playersLeft: 6, position: 7 } }, ]; /** The reading a perfect model gives at `t` (the answer schema's shape, `frame` left to the caller). */ export function pokerTruthAt(t) { const s = SYNTH_SPANS.find((x) => t >= x.from && t < x.to) ?? SYNTH_SPANS[SYNTH_SPANS.length - 1]; return { phase: s.phase, tournament: s.tournament ? { ...s.tournament } : {}, hero: s.hero ? { ...s.hero } : {}, hand: {}, event: s.event ?? null, }; } // The line a span paints. function spanText(s) { if (s.phase === "break") return "BREAK back in 5 minutes"; const t = s.tournament ?? {}; if (s.phase === "lobby") return `LOBBY ${t.name} Players ${t.playersLeft} of ${t.totalPlayers}`; return `${t.name} Level ${t.level} Blinds ${t.smallBlind} ${t.bigBlind} Left ${t.playersLeft} of ${t.totalPlayers} Stack ${s.hero?.stack ?? ""}${s.event ? " ELIMINATED" : ""}`; } const COLORS = { lobby: "0x123456", table: "0x0b5d1e", break: "0x333333", other: "0x000000" }; /** Write the stream into `dir`; answers its path and length. */ export async function makeSyntheticPokerStream(dir, o = {}) { const file = path.join(dir, o.name ?? "synthetic-poker.mp4"); const w = o.width ?? 1280; const h = o.height ?? 720; // One color source per span, concatenated, each with its own text. const inputs = []; const chains = []; SYNTH_SPANS.forEach((s, i) => { inputs.push("-f", "lavfi", "-i", `color=c=${COLORS[s.phase]}:s=${w}x${h}:r=2:d=${s.to - s.from}`); chains.push(`[${i}:v]drawtext=text='${spanText(s)}':fontsize=36:fontcolor=white:x=40:y=${h / 2}[v${i}]`); }); const concat = `${SYNTH_SPANS.map((_, i) => `[v${i}]`).join("")}concat=n=${SYNTH_SPANS.length}:v=1:a=0[out]`; await run(o.ffmpeg ?? "ffmpeg", [ "-hide_banner", "-loglevel", "error", "-y", ...inputs, "-filter_complex", `${chains.join(";")};${concat}`, "-map", "[out]", "-c:v", "libx264", "-preset", "ultrafast", "-g", "4", "-pix_fmt", "yuv420p", file, ]); return { file, duration: SYNTH_DURATION }; } // What the streamer says over the synthetic stream: numbers in words, as an // ASR transcript writes them. Two agree with the client; the last does not // (the frames read 9 left there): a flag. export const SPOKEN_CUES = [ { start: 5, end: 9, text: "welcome back we're in the synthetic cup" }, { start: 31, end: 35, text: "eighty five players left and" }, { start: 35, end: 38, text: "the buy in is two hundred bucks" }, { start: 92, end: 96, text: "I have forty one thousand now" }, { start: 125, end: 130, text: "we're at the final table, there are four players left" }, ];