Skip to content

Create polished demo videos without editing skills. Mac/Windows/Linux

fix(export): avoid false early-decode failure when frames are complete

webadderalldadf8b686230
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 {
}
}
}
-
+