Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions tests/ffmpeg-core.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,9 @@ describe(genName("setTimeout()"), () => {
});

it("should timeout", () => {
core.setTimeout(1); // timeout after 1ms
expect(core.exec("-i", "video.mp4", "video.avi")).to.equal(1);
core.setTimeout(50);
// Long enough that it cannot finish first, however fast the machine is.
expect(core.exec("-f", "lavfi", "-i", "testsrc=size=320x240:rate=30:duration=3600", "-f", "null", "-")).to.equal(1);
});
});

Expand Down
10 changes: 3 additions & 7 deletions tests/ffmpeg-node.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -233,16 +233,12 @@ describe(genName("FFmpeg"), function () {
});

it("stops exec() after the given timeout", async () => {
await ffmpeg.writeFile(
"timeout.mp4",
b64ToUint8Array(VIDEO_1S_MP4)
);
// Long enough that it cannot finish before the timeout.
const ret = await ffmpeg.exec(
["-i", "timeout.mp4", "timeout.avi"],
1 // 1ms, well under the time a transcode takes
["-f", "lavfi", "-i", "testsrc=size=320x240:rate=30:duration=3600", "-f", "null", "-"],
50
);
expect(ret).to.equal(1);
await ffmpeg.deleteFile("timeout.mp4");
});
});

Expand Down
3 changes: 2 additions & 1 deletion tests/ffmpeg.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ describe(genName("FFmpeg.exec()"), function () {
});

it("should stop if timeout", async () => {
const ret = await ffmpeg.exec(["-i", "video.mp4", "video.avi"], 1);
// Long enough that it cannot finish before the timeout.
const ret = await ffmpeg.exec(["-f", "lavfi", "-i", "testsrc=size=320x240:rate=30:duration=3600", "-f", "null", "-"], 50);
expect(ret).to.equal(1);
});

Expand Down
Loading