Extracting video with audio from rosbags

asked 2021-07-06 09:22:25 -0500

mjsobrep gravatar image

I am trying to extract video from rosbags with audio. This turns out to be non-trivial, I haven't found any tools that just do this. Does anyone have pointers on how to go about getting video with audio out of rosbags? My thinking so far:

There are two challenges:

  1. There are no tools to extract audio and video together, so getting them in sync is tough
  2. Some tools assume a constant frame rate, which is a bad assumption with our cameras

There are a two possible approaches:

  1. Extract the video and audio separately. Inspect the bag to find the offset of starts for each one and account for that.
  2. Try to write the video with audio directly from the bags.

A few possible tools:

  1. kinesis video encoder: Takes the video from a topic stream and records it with a correct frame rate. Requires replaying the rosbags, can't just seek through them looking for messages
  2. ros-gst-bridge: Takes audio and video topics from ROS2 and puts them into a g-streamer pipeline. This would make it all work, I think. But this has the downside of running on ROS2. Looks like the audio message type is different too. Also requires playing the rosbags
  3. ros-audio-convert: converts audio topic in a bag file into an mp3 or wav file.
  4. rosbag to images: can extract frames from rosbag and put into video container. But then there is no attempt at getting timing correct.
  5. bag2video: converts rosbag topic to video supporting variable frame rates with repeated frames.
edit retag flag offensive close merge delete