Repository navigation
fix(media): handle unset PyAV time_base after av 19 upgrade (#2134) - #2170
Mangesh Raut (mangeshraut712) wants to merge 5 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2170 +/- ##
=======================================
Coverage 87.29% 87.30%
=======================================
Files 402 402
Lines 52480 52482 +2
Branches 7309 7310 +1
=======================================
+ Hits 45814 45819 +5
+ Misses 5365 5363 -2
+ Partials 1301 1300 -1
*This pull request uses carry forward flags. Click here to find out more.
🚀 New features to boost your workflow:
|
Jamie Kim (jkim323)
left a comment
There was a problem hiding this comment.
Thank you for following up on #2134 so quickly, Mangesh Raut (@mangeshraut712). The truthiness guards are the right fix for av 19's AVRational(0, 1). The _stream_duration_s fallback works on both av 18 and 19, and the exporter now stops with a clear LeRobotExportError instead of an uncaught ZeroDivisionError.
We have a few suggested changes before merge:
_seek_and_decode: raise whentime_baseis unset, so theMediaInputErrorcontract from #2134 still holds (frames.py 149-156)._extract_frame_av: returnNonewhentime_baseis unset, so the existing cv2 fallback still runs (lerobot_handler.py 395-397).- Tests: update the new
_seek_and_decodetest to match, and add backend tests for_extract_frame_avand_EpisodeFrameswith an unsettime_base.
Dataviewer Backend Pytest is still running. It's the job that exercises the new tests against av 19.0.1, so it'd be great to see that green too. Each inline comment includes a suggestion you can apply directly. Please comment if you have questions about any of these, and we're happy to discuss.
…ession tests - Raise ValueError in evaluation/vlm_judge/frames.py:_seek_and_decode when stream has no valid time_base, preserving the MediaInputError contract. - Return None early in lerobot_handler.py:_extract_frame_av when time_base is unset, allowing clean fallback to _extract_frame_cv2. - Update test_frames.py with module-level imports and assert ValueError. - Add backend regression tests for lerobot_handler._extract_frame_av and lerobot_exporter._EpisodeFrames with unset time_base.
|
Thank you for the detailed and constructive review, Jamie Kim (@jkim323)! I've updated the PR with all the requested changes in commit
All local tests pass cleanly. Ready for another look! |
The new _extract_frame_av case used av.AVRational without importing av, so the test raised NameError before it could check the fallback.
|
Merged current Locally, |
Description
Closes #2134
In PyAV >= 19.0.0, unset rational attributes (
stream.time_base) returnav.AVRational(0, 1)rather thanNone. Underif stream.time_base is not None:, this evaluated toTrue, resulting inZeroDivisionError: float division by zeroduring seek timestamp calculation or returning an erroneous 0.0s duration.This PR addresses the issue as suggested in #2134:
if stream.time_base is not None:withif stream.time_base:inlerobot_handler.pyandlerobot_exporter.pyto gracefully skip seek whentime_baseis unset._stream_duration_sinframes.pywith truthiness check so unset stream time base falls back to container duration._seek_and_decodeto avoid divide-by-zero on unset time base.ZeroDivisionErrorto caught exceptions inextract_framesto translate unexpected division errors intoMediaInputError.evaluation/tests/vlm_judge/test_frames.pycoveringFraction(0, 1),av.AVRational(0, 1),ZeroDivisionErrortranslation, and decoding with unset time base.Type of Change
Component(s) Affected
workflows/- Training and evaluation workflowsTesting Performed
uv run pytest evaluation/tests/vlm_judge/test_frames.py --no-cov(23 passed)uv run pytest evaluation/vlm_judge(194 passed, 85.65% coverage)uv run pytest data-management/viewer/backend/tests/test_lerobot* --no-cov(142 passed)uv run ruff checkanduv run ruff format --check(clean, 0 warnings)Documentation Impact
Bug Fix Checklist
Checklist