mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
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:
@@ -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/);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user