From f71712e7d3c507897fb2353873c3f634fe81e108 Mon Sep 17 00:00:00 2001 From: webadderall <131426131+webadderall@users.noreply.github.com> Date: Sun, 15 Mar 2026 10:35:10 +1100 Subject: [PATCH] fix(export): avoid false early-decode failure when frames are complete --- src/lib/exporter/streamingDecoder.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/exporter/streamingDecoder.ts b/src/lib/exporter/streamingDecoder.ts index f5685391..bdf22ada 100644 --- a/src/lib/exporter/streamingDecoder.ts +++ b/src/lib/exporter/streamingDecoder.ts @@ -162,6 +162,7 @@ export class StreamingVideoDecoder { const segmentOutputFrameCounts = segments.map(segment => Math.ceil(((segment.endSec - segment.startSec) / segment.speed) * targetFrameRate) ); + const expectedOutputFrames = segmentOutputFrameCounts.reduce((sum, count) => sum + count, 0); const frameDurationUs = 1_000_000 / targetFrameRate; const epsilonSec = 0.001; @@ -405,10 +406,11 @@ export class StreamingVideoDecoder { if ( !this.cancelled && lastDecodedFrameSec !== null && - requiredEndSec - lastDecodedFrameSec > 1 + requiredEndSec - lastDecodedFrameSec > 1 && + exportFrameIndex < expectedOutputFrames ) { throw new Error( - `Video decode ended early at ${lastDecodedFrameSec.toFixed(3)}s (needed ${requiredEndSec.toFixed(3)}s).` + `Video decode ended early at ${lastDecodedFrameSec.toFixed(3)}s (needed ${requiredEndSec.toFixed(3)}s; rendered ${exportFrameIndex}/${expectedOutputFrames} frames).` ); } } @@ -504,4 +506,4 @@ export class StreamingVideoDecoder { } } } - +