commit 21d5f923c480d7c773283fe9fff22e6beeaf03bc
parent 8d2fe92fdde3fc593e3ca6ae131a3c91c05a33e5
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Thu, 1 Oct 2026 16:15:34 -0400
umtool: the bench's audio decode runs the build's FFMPEG_BIN and is killed when its request is aborted
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/umtool/app/api/report/audio/route.ts b/umtool/app/api/report/audio/route.ts
@@ -2,6 +2,7 @@ import { spawn } from "node:child_process";
import { stat } from "node:fs/promises";
import { absOf, pickWindow, resolveClip, windowsFor } from "@/lib/report/serve.mjs";
import { MAX_DECODE_SPAN, wavHeader } from "@/lib/report/playback.mjs";
+import { FFMPEG_BIN } from "umtool-report-to-video/build-video";
export const dynamic = "force-dynamic";
@@ -59,11 +60,13 @@ export async function GET(request: Request) {
}
// Input seeking with a decode is sample-accurate in ffmpeg: it seeks to the
- // keyframe before and discards up to the requested time.
+ // keyframe before and discards up to the requested time. The build's ffmpeg
+ // (FFMPEG_BIN), so an override reaches this decode too; killed when the
+ // request is aborted (the bench moved on to another window or left).
const chunks: Buffer[] = [];
let err = "";
const code = await new Promise<number>((resolve) => {
- const ff = spawn("ffmpeg", [
+ const ff = spawn(FFMPEG_BIN, [
"-nostdin", "-v", "error",
"-ss", (from - win.from).toFixed(6),
"-i", abs,
@@ -71,7 +74,7 @@ export async function GET(request: Request) {
"-map", "a:0",
"-ac", String(CHANNELS), "-ar", String(RATE),
"-f", "s16le", "-acodec", "pcm_s16le", "-",
- ]);
+ ], { signal: request.signal });
ff.stdout.on("data", (b: Buffer) => chunks.push(b));
ff.stderr.on("data", (b: Buffer) => {
err += b.toString();
@@ -82,6 +85,8 @@ export async function GET(request: Request) {
});
ff.on("close", (c) => resolve(c ?? -1));
});
+ // Nobody is waiting for it: the decode was killed, say so and stop.
+ if (request.signal.aborted) return new Response(null, { status: 499 });
const pcm = Buffer.concat(chunks);
const frameBytes = CHANNELS * 2;
const dataBytes = pcm.length - (pcm.length % frameBytes);