Extracting Data from Rosbag Files: Audio, Images, Video (ROS1)

Andreas Naoum
2 min readApr 16, 2024

Robot Operating System (ROS) bag files are a treasure trove of data collected from robotic sensors and systems. However, efficiently extracting specific types of data from these files, such as audio, images, or video, can be a hard task. In this blog post, I presented two Python scripts designed to handle the extraction of audio, images and video from ROS bag files.

For a detailed walkthrough and to access the script, check out the GitHub repository. Happy data extraction!

Rosbag Data Extractor

1. Audio Data Extraction

The script seamlessly extracts audio data from ROS bag files containing messages of type audio_common_msgs/AudioData. The extracted audio can be saved as a valid audio file, allowing for easy playback and analysis.

GitHub Repository: https://github.com/andreasnaoum/rosbag_to_mp3

2. Image/Video Extraction

For image data, the script supports messages of type sensor_msgs/Image. It converts these image messages into standard image files (JPEG, PNG, etc.), making it convenient for further image processing and visualization.

In addition to extracting individual images, the script can compile a sequence of image frames into a video file. This is particularly useful when dealing with ROS bag files that capture video streams.

GitHub Repository: https://github.com/andreasnaoum/rosbag_to_video

Contributions and Acknowledgments

I encourage contributions to the project. Whether it’s reporting issues or submitting pull requests, your input is valuable. The script is built upon the idea of making ROS bag data extraction more accessible and flexible in Python.

Sources:

[1] ROS logo by ROS under Creative Commons Attribution 3.0 license

--

--