Rosbag2video
converts image sequence in ros bag files to video files
Install / Use
/learn @mlaiacker/Rosbag2videoREADME
rosbag2video
rosbag2video.py
rosbag to video file conversion tool
by Maximilian Laiacker 2025
post@mlaiacker.de
with contributions from
David Silva 2025,
Abel Gabor 2019,
Bey Hao Yun 2024,
baquatelle@gmail.com,
beyhy94@gmail.com
a.j.blight@leeds.ac.uk
Install
Build docker images using the commands below:
- Download
rosbag2video:
install python3
cd $HOME
git clone https://github.com/mlaiacker/rosbag2video
install dependencies
sudo apt install ffmpeg
pip install rosbags
pip install opencv-python
Mostly tested with bags containing
msg_type: sensor_msgs/msg/CompressedImage msg_encoding: jpeg
Or use docker if you want to:
- Build docker image for running ROS 1
rosbag2video.py:
docker build -f Dockerfile.ros1 -t rosbag2video:noetic .
- Build docker image for running ROS 2
ros2bag2video.py:
docker build -f Dockerfile.ros2 -t rosbag2video:humble .
Usage
By default it will extract all compressed image topics inside the bag directory with the name of <topic>.mp4 ('/' inside the topic name will be replaced by '_') as mjpeg encoded video with 30fps.
usage: rosbag2video [-h] [-v] [-r RATE] [-t TOPIC] [-o OFILE] [--save_images] [--frames FRAMES] rosbag [rosbag ...]
Convert ROS bag (1/2) to video using ffmpeg.
positional arguments:
rosbag Input File(s)
options:
-h, --help show this help message and exit
-v, --verbose Run rosbag2video script in verbose mode.
-r RATE, --rate RATE Video framerate
-t TOPIC, --topic TOPIC
Topic Name
-o OFILE, --ofile OFILE
Output File
--save_images Boolean flag for saving extracted .png frames in frames/
--frames FRAMES Limit the number of frames to export
ROS 1
docker run -it --rm \
--name rosbag2video_c \
-v .:/rosbag2video_workspace \
rosbag2video:noetic bash
source /opt/ros/noetic/setup.bash
python3 rosbag2video.py -t <topic_name> -i <bag_file_name> -o <output_video_file_name>
# Eg. python3 rosbag2video.py -t /cam0/image_raw -i ar_tracking_1.bag -o myvideo.mp4
ROS 2
docker run -it --rm \
--name rosbag2video_c \
-v .:/rosbag2video_workspace \
rosbag2video:humble bash
source /opt/ros/humble/setup.bash
Example: extract all image topics form one ore more rosbag2 directories or bags
python3 rosbag2video.py <bag_folder_name>
# Eg. python3 rosbag2video.py rosbag2_2024_10_11-19_45_28 -o myvideo.mp4
Example: extract a specific topic
python3 rosbag2video.py -t <topic_name> -o <output_video_file_name> <bag_folder_name>
# Eg. python3 rosbag2video.py -t /cam0/image_raw -o myvideo.mp4 rosbag2_2024_10_11-19_45_28
Related Skills
qqbot-channel
352.0kQQ 频道管理技能。查询频道列表、子频道、成员、发帖、公告、日程等操作。使用 qqbot_channel_api 工具代理 QQ 开放平台 HTTP 接口,自动处理 Token 鉴权。当用户需要查看频道、管理子频道、查询成员、发布帖子/公告/日程时使用。
claude-opus-4-5-migration
111.1kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
docs-writer
100.6k`docs-writer` skill instructions As an expert technical writer and editor for the Gemini CLI project, you produce accurate, clear, and consistent documentation. When asked to write, edit, or revie
model-usage
352.0kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
