Skip to content

Commit 0e2c1ae

Browse files
committed
fix: generating thumbnails may cause the program to hang
1 parent ec11d40 commit 0e2c1ae

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

.changeset/wicked-worms-unite.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@webav/av-cliper': patch
3+
---
4+
5+
fix: generating thumbnails may cause the program to hang

packages/av-cliper/src/clips/__tests__/mp4-clip.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ test('thumbnails', async () => {
5757
clip.destroy();
5858
});
5959

60+
test('no thumbnails in time range', async () => {
61+
const clip = new MP4Clip((await fetch(mp4_bunny)).body!);
62+
await clip.ready;
63+
const thumbnails = await clip.thumbnails(800, {
64+
start: 1e6,
65+
end: 2e6,
66+
});
67+
expect(thumbnails.length).toBe(0);
68+
clip.destroy();
69+
});
70+
6071
test('thumbnails aborted', async () => {
6172
const clip = new MP4Clip((await fetch(mp4_bunny)).body!);
6273
await clip.ready;

packages/av-cliper/src/clips/mp4-clip.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,10 @@ async function thumbnailByKeyFrame(
13801380
),
13811381
fileReader,
13821382
);
1383-
if (chunks.length === 0 || abortSingl.aborted) return;
1383+
if (chunks.length === 0 || abortSingl.aborted) {
1384+
onOutput(null, true);
1385+
return;
1386+
}
13841387

13851388
let outputCnt = 0;
13861389
decodeGoP(createVideoDec(), chunks, {

0 commit comments

Comments
 (0)