lerobot-record command records robot demonstrations to create datasets for training.
Command
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 makessave_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
- Connect Devices: Plug in robot and teleoperator
- Calibrate (if needed): Run
lerobot-calibratefirst - Start Recording: Run
lerobot-recordcommand - Episode Loop:
- Reset environment (manual)
- Press Enter to start episode
- Perform demonstration
- Press Enter to stop episode
- Episode is saved automatically
- 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
- 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
- Camera Testing: Use
lerobot-find-camerasto identify camera indices - Port Finding: Use
lerobot-find-portto identify device ports - Calibration: Run
lerobot-calibratebefore first use - FPS Stability: Use
--dataset.streaming_encoding=truefor stable FPS - Storage: ~1GB per 10 minutes of multi-camera recording at 30fps
- Network: Upload to Hub happens after all episodes are recorded
See Also
- lerobot-replay - Replay recorded episodes
- lerobot-teleoperate - Test teleoperation
- lerobot-calibrate - Calibrate devices
- LeRobotDataset - Dataset format
- Robot API - Robot interface