Skip to main content
LeRobot supports efficient video encoding for visual observations, including hardware acceleration and real-time streaming encoding.

Video Storage Format

Visual observations are stored as MP4 videos with configurable codecs:

Why Video?

  • Compression: 10-50x smaller than PNG sequences
  • Efficiency: Faster to download and load
  • Hub-friendly: Fewer files, easier to manage

Codec Selection

Available Codecs

Hardware Acceleration

Codec Comparison

Streaming Encoding

Encode video frames in real-time during recording:

How It Works

  1. Background threads: One encoder thread per camera
  2. Lock-free queues: Frames sent to encoders without blocking
  3. Real-time encoding: Video written incrementally to disk
  4. Instant save: save_episode() just finalizes the file

Benefits

  • No intermediate PNG files: Direct pixel → MP4
  • Lower memory usage: No frame buffers
  • Faster recording: No batch encoding step
  • Parallel encoding: Multi-camera encoding in parallel

Batch Encoding

Encode multiple episodes at once (traditional approach):

When to Use Batch Encoding

  • Post-processing: Converting existing datasets
  • Offline encoding: When recording and encoding are separate
  • Custom pipelines: Need to modify frames before encoding

Encoding Options

Quality Settings

CRF (Constant Rate Factor)

  • Lower values = better quality, larger files
  • Higher values = worse quality, smaller files
  • Recommended: 28-32 for robotics

GOP Size

Keyframe interval affects:
  • Decode speed: Smaller = faster random access
  • Compression: Larger = better compression
  • Recommended: 2-10 for robotics

Video Decoding

Backend Selection

Decoder Comparison

Advanced Examples

Multi-Camera Streaming

Custom Encoding Pipeline

Monitoring Encoding Performance

Troubleshooting

Dropped Frames

If you see warnings about dropped frames:

Encoder Crashes

Video Quality Issues

See Also