From 337838294d69bf43089c993127bf44641794ba13 Mon Sep 17 00:00:00 2001 From: Enriquefft Date: Sun, 12 Apr 2026 18:06:01 -0500 Subject: [PATCH] fix: pass explicit range to packet scan read Some containers are truncated when read() has no end bound. Use container/stream duration + buffer as scan range, matching the same pattern used in decodeAll(). --- src/lib/exporter/streamingDecoder.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/exporter/streamingDecoder.ts b/src/lib/exporter/streamingDecoder.ts index 7e261ff..cc5ded5 100644 --- a/src/lib/exporter/streamingDecoder.ts +++ b/src/lib/exporter/streamingDecoder.ts @@ -230,9 +230,11 @@ export class StreamingVideoDecoder { // Scan video packets to find the true content boundary. // MediaRecorder (especially on Linux) writes unreliable container durations. // Packet timestamps are ground truth — no decode needed, just timestamp reads. + // Pass explicit range because some containers are truncated without one. + const scanEndSec = Math.max(mediaInfo.duration, videoStream?.duration ?? 0, 0) + 0.5; let maxPacketEndUs = 0; const scanReader = ( - this.demuxer.read("video") as ReadableStream + this.demuxer.read("video", 0, scanEndSec) as ReadableStream ).getReader(); try { while (true) {