Fix torchvision video frame indices offset - #2091
Open
Travor278 wants to merge 1 commit into
Open
Conversation
Travor278
marked this pull request as ready for review
May 3, 2026 04:22
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.
Fixes #2085
This PR makes
qwen_vl_utilsreport absoluteframes_indicesfor the torchvision video backend whenvideo_startis set.torchvision.io.read_videoreturns frames from the clipped segment requested bystart_pts/end_pts, so the sampled indices are relative to that segment. The decord and torchcodec backends already report indices in the original video timeline. This change adds thevideo_startframe offset back to the torchvision indices so the metadata is consistent across backends.I also added a focused regression test with a mocked
torchvision.io.read_videopath for:video_start=2.0at 25 fps, where the first index is 50video_start=1.0/video_end=3.0, where the first index is 25 and the clipped frame count is preservedValidation:
D:/Dev/conda-envs/py313/python.exe -m pytest tests/test_torchvision_frame_indices.py -vD:/Dev/conda-envs/py313/python.exe -m ruff check tests/test_torchvision_frame_indices.pyD:/Dev/conda-envs/py313/python.exe -m ruff format --check tests/test_torchvision_frame_indices.pygit diff --check