Repository navigation
fix(episode): align sampled JPEGs with decoded source frames - #732
Conversation
[Medium impact] The PR appears safe to merge; both previous findings are fixed, and no new actionable issue was established.
|
There was a problem hiding this comment.
Could you add coverage for sparse decoder output and fix the recovered source indices? I exercised _decoded_frame_indices with a 1/1000000 time base and surviving PTS values 0, 1000000, 2000000 at 30 fps: it returns {0, 1, 2}, so frames(fps=1) drops the usable pictures at source indices 30 and 60.
Could you also bound the decoded trace to the requested window? On a three-second, 5 fps clip, frames(fps=5, end_s=0.5) returns three JPEGs but writes all 15 decoded pictures to the trace.
Summary
Episode.frames()now labels extracted JPEGs with the source messages represented by their pixels instead of assigning later pictures to earlier sampling ticks. JPEGs for source frames missing from the decoder output are omitted without shifting subsequent sample labels.Why
FFmpeg's default nearest-frame sampling can choose pictures recorded after a requested tick and can repeat the last decoded picture across a missing keyframe. Using
fps=...:round=up, an unfilteredframecrctrace from the same decode, and the trace's actual PTS time base separates present source frames from padding; a versioned cache avoids reusing the older inaccurate JPEGs. The transform andframes_at_indices()are unchanged.Validation
uv run --no-sync pytest -q tests/test_episode.py tests/test_end_to_end.py::test_canonical_episode_accessors tests/test_video.py— 57 passed.uv run --no-sync ruff check --fix src/hflow/episode.py tests/test_episode.py,uv run --no-sync ruff format src/hflow/episode.py tests/test_episode.py, anduv run --no-sync ty check— passed; subsequent scoped Ruff lint and format checks passed.uv run --no-sync pytest -q— 2,567 passed, eight skipped, one unrelated cache-migration failure due to the task-requiredXDG_CACHE_HOME; the failing case passed separately withXDG_CACHE_HOMEunset andHOMEredirected to an isolated task-local directory.Verified on Linux with FFmpeg 6.1.1; the report's macOS/FFmpeg 8.1.1 environment was not available.
Checklist
uv run ruff check --fix,uv run ruff format, anduv run ty check.Fixes #731
Need help on this PR? Tag
@codesmith-botwith what you need.