Skip to content

Fix StreamingLeRobotDataset using global index for video frame lookup#3110

Open
he-yufeng wants to merge 1 commit intohuggingface:mainfrom
he-yufeng:fix/streaming-video-frame-index
Open

Fix StreamingLeRobotDataset using global index for video frame lookup#3110
he-yufeng wants to merge 1 commit intohuggingface:mainfrom
he-yufeng:fix/streaming-video-frame-index

Conversation

@he-yufeng
Copy link

What this PR does

Fixes StreamingLeRobotDataset crashing with IndexError: Invalid frame index on datasets with multiple episodes.

Root cause

streaming_dataset.py:312 computed the current timestamp from item["index"] (the global dataset index):

current_ts = item["index"] / self.fps  # e.g. 134029 / 30 = 4467.6s

But each .mp4 file is per-episode, so torchcodec received a frame index far beyond the video length (e.g. frame 134029 in a 25215-frame video), causing IndexError.

Fix

Use item["timestamp"] (per-episode timestamp) instead, matching what LeRobotDataset.__getitem__ does at line 1099.

Fixes #3080

@github-actions github-actions bot added the dataset Issues regarding data inputs, processing, or datasets label Mar 8, 2026
streaming_dataset.py computed current_ts from item["index"] (global
dataset index) instead of item["timestamp"] (per-episode timestamp).
Since each .mp4 file is per-episode, torchcodec received a frame index
far beyond the video length, causing IndexError.

Use item["timestamp"] to match what LeRobotDataset.__getitem__ does.

Fixes huggingface#3080
@he-yufeng he-yufeng force-pushed the fix/streaming-video-frame-index branch from d262d1c to cdc8182 Compare March 8, 2026 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dataset Issues regarding data inputs, processing, or datasets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Local LeRobotDataset works fine but StreamingLeRobotDataset fails

1 participant