Stream camera video frames instead of buffering episodes - #1000
Conversation
alexmillane
left a comment
There was a problem hiding this comment.
Self review 1.
CameraObsVideoRecorder held every frame of an episode in memory before encoding, costing num_envs x episode_length x H x W x C bytes. Frames are now written to a per-(env, camera) ffmpeg encoder as they arrive. Measured on canned_food_in_bin with 3x 1280x720 cameras: peak host RAM at 6 envs drops 60.5 GB -> 13.1 GB, with wall clock unchanged. Signed-off-by: alex <amillane@nvidia.com>
78173ad to
443177f
Compare
Greptile SummaryThe PR replaces per-episode raw camera-frame buffering with incremental encoding through one ffmpeg writer per environment and camera, substantially reducing peak host memory.
Confidence Score: 5/5The PR appears safe to merge, with no concrete blocking or independently actionable non-blocking issue identified. Episode counters are sampled when each current episode’s writer opens, completed streams are finalized on reset, partial streams are removed on shutdown, and the updated tests cover the principal lifecycle transitions. Important Files Changed
Sequence DiagramsequenceDiagram
participant Env
participant Recorder as CameraObsVideoRecorder
participant Writer as FFMPEG_VideoWriter
Env->>Recorder: step() observations
alt Environment is active
Recorder->>Writer: lazily open episode writer
Recorder->>Writer: write_frame(frame)
else Environment reset
Recorder->>Writer: close and finalize completed episode
end
alt Wrapper closes during partial episode
Recorder->>Writer: close
Recorder->>Recorder: delete partial mp4
end
Reviews (1): Last reviewed commit: "Stream camera frames to the encoder inst..." | Re-trigger Greptile |
🤖 Isaac Lab-Arena Review BotSummaryThis PR switches Findings🔵 Improvement — Test CoverageGood. Tests are CPU-only (no Isaac Sim), so the inner/outer sim pattern does not apply; the moviepy encoder is replaced by a counting stand-in and there is a VerdictShip it |
Summary
Encode camera videos incrementally so host RAM no longer scales with episode length.
Detailed description
CameraObsVideoRecorderstored every frame of an episode before encoding, costingnum_envs × episode_length × H × W × C. For robolab tasks (3× 1280x720 droid cameras, 1000-step episodes, 50Hz) that is 8.3 GB per env per episode.FFMPEG_VideoWriteras they arrive.canned_food_in_bin, peak host RAM drops 8.32 GB → 0.72 GB. Wall clock unchanged.Before and after experiment.