feat(rldb): detect JPEG vs H264 image encoding instead of trusting dtype - #550
Draft
ElmoPA wants to merge 1 commit into
Draft
feat(rldb): detect JPEG vs H264 image encoding instead of trusting dtype#550ElmoPA wants to merge 1 commit into
ElmoPA wants to merge 1 commit into
Conversation
ZarrDataset dispatched purely on features[key]["dtype"]. That is a claim, and a
stale claim routes real mp4 payloads into simplejpeg -- which fails deep in the
decoder, far from the actual cause. Episodes converted before the codec switch,
or whose metadata was copied from a sibling, could not be loaded at all.
_classify_image_keys now uses three signals, cheapest first, escalating only on
disagreement:
1. the declared dtype;
2. the element count -- per-frame JPEG stores one element per frame, chunked
video one mp4 per frames_per_chunk, so a full-length array is JPEG and a
much shorter one is video. Compared with ">=" because writers pad past
total_frames (a 290-frame episode occupies 300 slots);
3. the magic bytes of element 0, read only to break a tie, and authoritative
when read.
Verified on 72 real episodes across 6 datasets: identical classification and
ZERO payload reads, so the common path costs nothing.
Also fixes two gaps this exposed:
* video keys with no "video" metadata block now recover frames_per_chunk by
decoding chunk 0. It is not derivable arithmetically -- 1000 frames over 4
chunks admits any fpc in (250, 333].
* ZarrDataset.__getitem__ had NO video branch, only _read_span did, so a
detected video key hit a frame-indexed read of a chunk-indexed array and
returned the wrong elements. It now mirrors _read_span, matching
decode_jpeg_single for horizon=None and _pad_sequences at the episode tail.
Mismatch warnings are deduped per (key, declared, detected) so a systematically
mislabelled dataset logs once, not once per episode.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012V58H37tmcvgDthELMd5Xk
This was referenced Aug 7, 2026
Contributor
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
ElmoPA
changed the base branch from
rldb/video-and-annotations
to
graphite-base/550
August 7, 2026 13:34
ElmoPA
changed the base branch from
graphite-base/550
to
rldb/video-and-annotations
August 7, 2026 13:35
ElmoPA
changed the base branch from
rldb/video-and-annotations
to
graphite-base/550
August 7, 2026 18:19
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.

ZarrDataset dispatched purely on features[key]["dtype"]. That is a claim, and a
stale claim routes real mp4 payloads into simplejpeg -- which fails deep in the
decoder, far from the actual cause. Episodes converted before the codec switch,
or whose metadata was copied from a sibling, could not be loaded at all.
_classify_image_keys now uses three signals, cheapest first, escalating only on
disagreement:
video one mp4 per frames_per_chunk, so a full-length array is JPEG and a
much shorter one is video. Compared with ">=" because writers pad past
total_frames (a 290-frame episode occupies 300 slots);
when read.
Verified on 72 real episodes across 6 datasets: identical classification and
ZERO payload reads, so the common path costs nothing.
Also fixes two gaps this exposed:
decoding chunk 0. It is not derivable arithmetically -- 1000 frames over 4
chunks admits any fpc in (250, 333].
detected video key hit a frame-indexed read of a chunk-indexed array and
returned the wrong elements. It now mirrors _read_span, matching
decode_jpeg_single for horizon=None and _pad_sequences at the episode tail.
Mismatch warnings are deduped per (key, declared, detected) so a systematically
mislabelled dataset logs once, not once per episode.
Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_012V58H37tmcvgDthELMd5Xk