Bound separation input WAV duration to the probed length

The unbounded apad filter made ffmpeg pad the 3-second test clip
endlessly (a 22.9GB WAV) until the disk filled, which was the real
cause of the voice separation failures. Trim to the probed duration
and drop apad.
This commit is contained in:
134 2026-09-19 14:33:06 +08:00
parent 8b2955eb0b
commit 1141ecc43a

View File

@ -58,14 +58,15 @@ export async function POST(request: Request) {
const info = await probeMedia(input, 600);
if (!info.hasAudio) throw new Error("当前视频没有音轨");
const inputAudio = path.join(dir, "separation-input.wav");
const durationSeconds = Math.round(info.duration / 1e6);
await ffmpeg(
[
...mediaSafety,
"-i",
input,
"-vn",
"-af",
"apad",
"-t",
String(durationSeconds),
"-ac",
"2",
"-ar",