fix(llava_vid): call read_video with its actual signature on the pyav path - #1492
Merged
pufanyi merged 1 commit intoAug 31, 2026
Merged
Conversation
… path read_video is keyword-only and returns just the frame array, but the pyav branch passed three positional arguments plus a force_sample keyword and unpacked a 3-tuple. Rebuild frame_time/video_time locally so the branch matches the decord path's contract.
Collaborator
|
lgtm, thanks for your contribution! |
pufanyi
self-requested a review
August 31, 2026 07:49
pufanyi
approved these changes
Aug 31, 2026
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.
Problem
Llava_Vid.generate_untildispatches onvideo_decode_backend. Thedecordbranch callsthe class's own
self.load_video(...), which returns(frames, frame_time, video_time).The
pyavbranch next to it calls the shared helperread_videoas if it had the samesignature and the same return contract — but it has neither:
Three separate mismatches:
num_frm/fpsare keyword-only, so the two positional arguments raiseTypeError: read_video() takes 1 positional argument but 3 were given.force_sampleis not a parameter ofread_videoat all.read_videoreturns a single(N, H, W, 3)array, sounpacking it into three names raises
ValueError: too many values to unpack (expected 3)for any video sampled to more than 3 frames.
The whole block sits inside
try: ... except Exception as e:, which logs the message andappends
f"Video {video_path} can not load, check the source"to the results. So thefailure is not loud — running
llava_vidwithvideo_decode_backend=pyavsilently scoresevery sample as an unloadable video instead of crashing.
This is the only call site that gets it wrong
Every other
pyavbranch in the repo calls the helper the way it is declared:longva.py:412read_video(visual[0], num_frm=self.max_frames_num)llava_onevision.py:322read_video(visual[0], num_frm=self.max_frames_num)llava_onevision.py:507read_video(visual[0], num_frm=self.max_frames_num)llava_onevision.py:737read_video(visual[0], num_frm=self.max_frames_num)llava_vid.py:463force_sample=It looks like the branch was copied from the
decordbranch three lines above it(which does take
(path, max_frames_num, fps, force_sample=...)) without adapting it toread_video.Fix
Call
read_videowith keyword arguments, and rebuild the timing metadata that thedecordbranch returns alongside the frames:force_sample=Trueinself.load_videomeans "ignore the target fps and takemax_frames_numframes uniformly".read_videodoes exactly that when it is given nofps, so the knob is preserved asfps=None if self.force_sample else self.fpsratherthan silently dropped.
frame_time/video_timeare recovered from the container metadata via the module'sexisting
_probe_video_metadata.read_videosamples withnp.linspace(0, total_frames - 1, sampled, dtype=int), solen(video)is enough toreproduce the exact frame positions it used — no second decode of the frames.
These two values are only consumed under
add_time_instruction, but they are unpackedunconditionally, so the branch has to produce them either way.
(Happy to rename
_probe_video_metadatato a public name if you'd rather not import anunderscore-prefixed helper across modules — say the word and I'll fold that in.)
Verification
No GPU/model needed for the failing mechanism — it is pure call-signature and unpacking.
Replayed the real signature from
load_video.pywithinspect.Signature.bind:And the
frame_timereconstruction is bit-identical to the indicesread_videoitselfpicks, checked against the module's own
_compute_uniform_indicesfor every(total_frames, sampled)pair intotal ∈ {1, 2, 7, 30, 101, 1000} × sampled ∈ {1, 2, 8, 20}:ruff formatandruff checkclean at the version pinned in.pre-commit-config.yaml(v0.16.4), run against the repo's own
pyproject.toml. The four pre-existing findings inthis file are unchanged by the patch (identical output before and after).
🤖 Generated with Claude Code