Skip to content

Use FFMPEG Index for Seeking#214

Merged
voegtlel merged 19 commits intodevelopfrom
feature/pyav-index
Apr 9, 2026
Merged

Use FFMPEG Index for Seeking#214
voegtlel merged 19 commits intodevelopfrom
feature/pyav-index

Conversation

@Queuecumber
Copy link
Copy Markdown
Collaborator

This PR switches from manual container parsing to using the internal FFMPEG frame index wherever possible, deprecating and removing the Fastseek interface (RIP, you served us well)

PyAV PR: PyAV-Org/PyAV#2136 added the necessary plumbing to expose this index to the python side

Conceptually this is the same algorithm that Fastseek was using but now the index is built by ffmpeg which is much faster (and happens during container loading regardless of if we use it or not).

The exact shape of this index depends on the container format so right now we support mp4/mov/mkv/webm with the index (as before) and there is a functionally identical probe fallback for other containers.

This should be a drop-in replacement and all tests pass but I recommend trying it on non-critical runs before bumping any production versions.

@Queuecumber
Copy link
Copy Markdown
Collaborator Author

Queuecumber commented Mar 17, 2026

Questions and Comments

  1. In AVReaderByFrames I included bounds checking that returns None if an out-of-bounds frame is requested. This matches the ByPts code path which naturally returns None if it can't find a frame in-bounds. Is that intentional or should this be a warning/error? It came up during the audio sync test.
  2. I modified the strided_resized functional test to load the actual baseline video for comparison rather than comparing to the externally loaded mp4. This makes sure the seek is at least self-consistent rather than self-consistent and pixel-close with the mp4 decoding. This worked for mkv because the codecs were similar but was failing for avi which uses a different codec.
  3. MP4/MOV are back to using the frame index, in my testing I found no issue decoding long videos like we had with Fastseek (because ffmpeg builds the index for us there's no perf hit), but we should try some out if you have any pathological cases

@voegtlel voegtlel merged commit d84075a into develop Apr 9, 2026
9 checks passed
@voegtlel voegtlel deleted the feature/pyav-index branch April 9, 2026 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants