Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix: handle NaN in zero-scan fallback and symmetric divergence check
Enriquefft83ea025ed816
diff --git a/src/lib/exporter/streamingDecoder.test.ts b/src/lib/exporter/streamingDecoder.test.tsindex e3a0ecc48..55b9123b0 100644--- a/src/lib/exporter/streamingDecoder.test.ts+++ b/src/lib/exporter/streamingDecoder.test.ts@@ -27,9 +27,17 @@ describe("validateDuration", () => {expect(validateDuration(15.0, 15.3)).toBe(15.0);});+ it("returns scanned duration when container under-reports beyond threshold", () => {+ expect(validateDuration(10, 15.3)).toBe(15.3);+ });+it("returns container duration when scanned is zero (corrupted/empty file)", () => {expect(validateDuration(10, 0)).toBe(10);});++ it("returns 0 when both container is NaN and scanned is zero", () => {+ expect(validateDuration(NaN, 0)).toBe(0);+ });});describe("shouldFailDecodeEndedEarly", () => {diff --git a/src/lib/exporter/streamingDecoder.ts b/src/lib/exporter/streamingDecoder.tsindex cc5ded5aa..b0866f5ad 100644--- a/src/lib/exporter/streamingDecoder.ts+++ b/src/lib/exporter/streamingDecoder.ts@@ -86,12 +86,12 @@ export function validateDuration(containerDuration: number, scannedDuration: numif (scannedDuration <= 0) {// Zero scanned duration means corrupted/empty file — fall back to container// (downstream shouldFailDecodeEndedEarly will catch truly empty files)- return Math.max(containerDuration, 0);+ return Number.isFinite(containerDuration) ? Math.max(containerDuration, 0) : 0;}if (!Number.isFinite(containerDuration) || containerDuration <= 0) {return scannedDuration;}- if (containerDuration - scannedDuration > DURATION_DIVERGENCE_THRESHOLD_SEC) {+ if (Math.abs(containerDuration - scannedDuration) > DURATION_DIVERGENCE_THRESHOLD_SEC) {return scannedDuration;}return containerDuration;