From 0dffefdd59d8c70fece63436e8556f8ec1e43a49 Mon Sep 17 00:00:00 2001 From: Maze Winther Date: Sat, 25 Apr 2026 02:46:31 +0200 Subject: fix: surface unsupported video codec on import, fix Input leaks --- apps/web/src/services/video-cache/service.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'apps/web/src/services') 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 | null; currentFrame: WrappedCanvas | null; @@ -262,12 +263,12 @@ export class VideoCache { mediaId: string; file: File; }): Promise { - 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); } -- cgit v1.3.1