summaryrefslogtreecommitdiff
path: root/apps/web/src/services
diff options
context:
space:
mode:
authorMaze Winther <mazewinther@gmail.com>2026-04-25 02:46:31 +0200
committerMaze Winther <mazewinther@gmail.com>2026-04-25 02:46:31 +0200
commit0dffefdd59d8c70fece63436e8556f8ec1e43a49 (patch)
tree2fad7166bbc7e5e7645bbd0456c8f4eef44c19dc /apps/web/src/services
parentcceb835a84c125990ad8e49784e01a7c52636bb3 (diff)
downloadopencut-0dffefdd59d8c70fece63436e8556f8ec1e43a49.tar.gz
fix: surface unsupported video codec on import, fix Input leaks
Diffstat (limited to 'apps/web/src/services')
-rw-r--r--apps/web/src/services/video-cache/service.ts14
1 files changed, 9 insertions, 5 deletions
diff --git a/apps/web/src/services/video-cache/service.ts b/apps/web/src/services/video-cache/service.ts
index e5f3991d..31467065 100644
--- a/apps/web/src/services/video-cache/service.ts
+++ b/apps/web/src/services/video-cache/service.ts
@@ -7,6 +7,7 @@ import {
} from "mediabunny";
interface VideoSinkData {
+ input: Input;
sink: CanvasSink;
iterator: AsyncGenerator<WrappedCanvas, void, unknown> | null;
currentFrame: WrappedCanvas | null;
@@ -262,12 +263,12 @@ export class VideoCache {
mediaId: string;
file: File;
}): Promise<void> {
- try {
- const input = new Input({
- source: new BlobSource(file),
- formats: ALL_FORMATS,
- });
+ const input = new Input({
+ source: new BlobSource(file),
+ formats: ALL_FORMATS,
+ });
+ try {
const videoTrack = await input.getPrimaryVideoTrack();
if (!videoTrack) {
throw new Error("No video track found");
@@ -284,6 +285,7 @@ export class VideoCache {
});
this.sinks.set(mediaId, {
+ input,
sink,
iterator: null,
currentFrame: null,
@@ -293,6 +295,7 @@ export class VideoCache {
prefetchPromise: null,
});
} catch (error) {
+ input.dispose();
console.error(`Failed to initialize video sink for ${mediaId}:`, error);
throw error;
}
@@ -305,6 +308,7 @@ export class VideoCache {
void sinkData.iterator.return();
}
+ sinkData.input.dispose();
this.sinks.delete(mediaId);
}