Skip to content

Commit ec9fd21

Browse files
Zesen Qianclaude
andcommitted
fix: populate MKV Cues index on first screenshots() call
MKV demuxer loads Cues lazily — the AVIndexEntry array stays empty until a seek triggers it. Do a seek to INT64_MIN at the start of _screenshots_decode when the index has at most one entry. This gives screenshots() the full keyframe index for proper seek-based frame extraction instead of falling back to slow sequential decode. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1e38bf2 commit ec9fd21

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/nvidia_codec/utils/decode.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,11 @@ def _screenshots_decode(self, max_interval, start_kts, pic_q):
363363
"""
364364
max_gap = int(max_interval.total_seconds() / float(self.track._time_base))
365365

366+
# Trigger index population for containers that load it lazily (e.g. MKV Cues).
367+
# If there's at most one index entry, seek to force the demuxer to load its index.
368+
if self._keyframe_after(0) is None:
369+
self.track.fc.seek_file(self.track.stream, -(2**63), min_ts=-(2**63), max_ts=-(2**63))
370+
366371
kts = start_kts
367372

368373
while True:

0 commit comments

Comments
 (0)