fix(audio): refuse trim windows shorter than one codec frame (#679)

trim-audio stream-copies, and a window below one frame ships a container with zero audio frames as a 200 success. Floor the window at 0.1s in the schema, and refuse after endS clamps to the real duration if the window drops under the floor. Fixes #671.
This commit is contained in:
SnapOtter
2026-07-30 09:34:56 +08:00
committed by GitHub
parent 6aacb4f3a9
commit 192d56e2ca
3 changed files with 34 additions and 1 deletions
@@ -67,4 +67,17 @@ describe.skipIf(!ffmpegAvailable())("trim-audio (requires ffmpeg)", () => {
const res = await runTool({ startS: 0.5, endS: 0.2 });
expect(res.statusCode).toBe(400);
});
it("rejects a sub-frame trim window instead of returning an empty file", async () => {
const res = await runTool({ startS: 0, endS: 0.000001 });
expect(res.statusCode).toBe(400);
});
it("rejects when clamping endS to the duration leaves a sub-frame window", async () => {
// tiny.mp3 is ~1.0-1.045s depending on the ffprobe build; endS clamps to
// the duration, leaving well under 0.1s either way.
const res = await runTool({ startS: 0.98, endS: 9 });
expect(res.statusCode).toBe(422);
expect(JSON.parse(res.body).details).toMatch(/Trim window/);
});
});