Skip to main content
The lerobot-record command records robot demonstrations to create datasets for training.

Command

Location: src/lerobot/scripts/lerobot_record.py

Overview

The recording script:
  • Captures robot observations (cameras, joint states) and actions
  • Supports teleoperation or policy-driven recording
  • Encodes videos efficiently with hardware acceleration
  • Streams encoded videos in real-time (optional)
  • Uploads datasets to Hugging Face Hub
  • Visualizes data with Rerun

Key Options

Robot Configuration

str
required
Robot type: so100_follower, koch_follower, aloha, etc.
str
Serial port for robot connection (e.g., /dev/ttyUSB0).
str
required
Unique identifier for this robot instance.
dict
Camera configuration dictionary.Example:

Teleoperation Configuration

str
Teleoperator type: so100_leader, koch_leader, keyboard, etc.
str
Serial port for teleoperator device.
str
Unique identifier for teleoperator.

Dataset Configuration

str
required
Dataset repository ID in format {username}/{dataset_name}.
str
required
Task description (e.g., “Pick the cube and place it in the box”).
str
Local directory for dataset storage.
int
default:"30"
Frames per second for recording.
int
default:"50"
Number of episodes to record.
int
default:"60"
Maximum duration per episode in seconds.
int
default:"60"
Time allocated for resetting between episodes.

Video Encoding Options

str
default:"libsvtav1"
Video codec: h264, hevc, libsvtav1, auto, or hardware codecs like h264_nvenc, h264_videotoolbox.
bool
default:"False"
Enable real-time video encoding during capture (makes save_episode instant).
int
Number of threads per encoder. Lower values reduce CPU usage.
int
default:"30"
Maximum frames to buffer per camera when using streaming encoding.
int
default:"1"
Number of episodes to accumulate before batch encoding videos.

Upload Options

bool
default:"True"
Upload dataset to Hugging Face Hub.
bool
default:"False"
Create private repository on Hub.
list[str]
Tags for dataset card.

Visualization Options

bool
default:"False"
Display robot data in Rerun viewer.
str
IP address for remote Rerun server.
int
Port for remote Rerun server.

Usage Examples

Basic Recording with Teleoperation

Recording with Streaming Video Encoding

Streaming encoding makes save_episode() instant by encoding in real-time:

Recording with Hardware Video Encoding

Bimanual Robot Recording

Recording with Visualization

Recording with Policy (Autonomous)

Recording with Multiple Cameras

Using RealSense Cameras

Recording Workflow

  1. Connect Devices: Plug in robot and teleoperator
  2. Calibrate (if needed): Run lerobot-calibrate first
  3. Start Recording: Run lerobot-record command
  4. Episode Loop:
    • Reset environment (manual)
    • Press Enter to start episode
    • Perform demonstration
    • Press Enter to stop episode
    • Episode is saved automatically
  5. Upload: Dataset is pushed to Hub when complete

Keyboard Controls

During recording:
  • Enter: Start/stop episode recording
  • Ctrl+C: Stop recording and finalize dataset
  • Space: Pause/resume (if using keyboard teleop)

Output Structure

Video Encoding Performance

Streaming vs Batch Encoding

Streaming Encoding (--dataset.streaming_encoding=true):
  • Encodes frames in real-time during capture
  • save_episode() is near-instant
  • Uses more CPU during recording
  • Recommended for most use cases
Batch Encoding (default):
  • Writes PNG images during capture
  • Encodes to video after episode ends
  • save_episode() takes time
  • Lower CPU usage during recording

Hardware Acceleration

Use hardware encoders for best performance:

Tips

  1. Camera Testing: Use lerobot-find-cameras to identify camera indices
  2. Port Finding: Use lerobot-find-port to identify device ports
  3. Calibration: Run lerobot-calibrate before first use
  4. FPS Stability: Use --dataset.streaming_encoding=true for stable FPS
  5. Storage: ~1GB per 10 minutes of multi-camera recording at 30fps
  6. Network: Upload to Hub happens after all episodes are recorded

See Also