Optimize video I/O with seek decoding instead of serial decoding - #172
Merged
Conversation
amazloumi
approved these changes
Aug 6, 2026
Member
|
Its look good to me. just two minor comment that can be fixed before merging. |
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
decode_video_framespreviously decoded every frame of a clip serially to extracttime_base, missing PTS, seek landing past its target, FFmpeg error) falls back to a single serial pass — the retained reference implementation — so seeking only ever changes speed, never output.Benchmarks
Frame-selection parity is byte-identical to serial in all cases below. Decode counts via an instrumented container; times single-threaded.
Known tradeoff: dense sampling inside long GOPs re-decodes the GOP prefix per target (e.g. 5s GOPs with 16 targets/30s: 465 vs 300 serial). Real workloads sample sparsely relative to GOP size, so this doesn't occur there; if it shows up in profiling, the fix is a demux-pass keyframe planner, not a heuristic (a stateful-cursor variant was prototyped, benchmarked at zero gain on sparse workloads, and rejected).
Testing
uv run ruff checkpassesuv run ruff format --checkpassesuv run pyright kempnerforge/passesuv run pytest tests/unit/ -vpasses (N tests, 0 failures)Closes #171