Ask Your Question

How to extract video from bag file?

asked 2012-09-28 23:08:08 -0600

Astronaut gravatar image

updated 2012-10-01 16:11:56 -0600


I followed the tutorial [] about extracting video from bag file. I create a launch file like this

  <node pkg="rosbag" type="rosbag" name="rosbag" args="play -d 2 $(find image_view)/Data/test1.bag"/>
  <node name="extract" pkg="image_view" type="extract_images" respawn="false" output="screen" cwd="node">
    <remap from="image" to="/camera/image_raw"/>

But than got the following error

ERROR: cannot launch node of type [rosbag/rosbag]: can't locate node [rosbag] in package [rosbag]

Im using ROS Fuerte and Ubuntu 10.4. Any help??

This is my bag file info

version: 2.0 duration: 1:32s (92s) start: Apr 01 2011 14:17:41.82 (1301627861.82) end: Apr 01 2011 14:19:14.15 (1301627954.15)

size:        260.5 MB
messages:    6530
compression: none [284/284 chunks]
types:       sensor_msgs/Image     [060021388200f6f0f447d0fcd9c64743]
             sensor_msgs/Imu       [6a62c6daae103f4ff57a132d6f95cec2]
             sensor_msgs/LaserScan [90c7ef2dc6895d81024acba2ac42f369]
topics:      /camera/image_raw   1135 msgs    : sensor_msgs/Image    
             /imu/data           1802 msgs    : sensor_msgs/Imu      
             /scan               3593 msgs    : sensor_msgs/LaserScan


edit retag flag offensive close merge delete


How best to extract video depends on what you want to do with it. Please edit your question to provide that information. (Your time-stamp question was asked and answered separately).

joq gravatar imagejoq ( 2012-09-29 08:50:51 -0600 )edit

3 Answers

Sort by ยป oldest newest most voted

answered 2012-09-28 23:10:54 -0600

Mani gravatar image

updated 2012-10-01 18:25:16 -0600

Regarding your first question:

I would like to know how to extract video from the bagfile?

I would recommend reading this tutorial from from ROS image_view wiki page.


I summarized the steps needed to create the video in this tutorial: How to extract images from a rosbag file and convert them to video

edit flag offensive delete link more


I already done the tutorial and got an Error. I posted that in edit question. Any help??

Astronaut gravatar imageAstronaut ( 2012-10-01 16:13:10 -0600 )edit

There seems to be a mistake on the wiki page (I just fixed it). The correct string in the rosbag tag entry is type="play"

jarvisschultz gravatar imagejarvisschultz ( 2012-10-01 17:56:56 -0600 )edit

Still not working. I go this error. [FATAL] [1349151684.419671013]: Error opening file: play process[extract-3]: started with pid [5008] [rosbag-2] process has died [pid 4996, exit code 1, cmd /opt/ros/fuerte/share/rosbag/bin/play

Astronaut gravatar imageAstronaut ( 2012-10-01 18:22:18 -0600 )edit

I updated my answer with a link to steps that I usually use.

Mani gravatar imageMani ( 2012-10-01 18:26:02 -0600 )edit

Sorry. Where did you updated the answer?? On the wiki page??Sorry I saw. But Im using ROS Fuerte and Ubuntu 10.4 and I got the following error. Couldn't find package mjpeg-tools

Astronaut gravatar imageAstronaut ( 2012-10-01 19:18:19 -0600 )edit

I think the name for 10.04 used to be mjpegtools:

Mani gravatar imageMani ( 2012-10-01 19:32:25 -0600 )edit

Ok. But have problems with rosrun image_view extract_images _sec_per_frame:=0.01 . So First I execute osrun image_view extract_images sec_per_frame:=0.01. Yes?? Than image:=<IMAGETOPICINBAGFILE>. What means IMAGETOPICINBAGFILE???When I put the image path I got an error

Astronaut gravatar imageAstronaut ( 2012-10-01 19:45:53 -0600 )edit

And after rosrun image_view extract_images _sec_per_frame:=0.01 I got [ WARN] [1349156876.990156648]: extract_images: image has not been remapped! Typical command-line usage: $ ./extract_images image:=<image topic> [transport]

Astronaut gravatar imageAstronaut ( 2012-10-01 19:49:29 -0600 )edit

answered 2016-01-11 13:00:45 -0600

mlaiacker gravatar image


I wrote a python script that will directly output a video file from a ros bag without the need to convert them to images first.

This tool will also convert the images to a fixed frame rate to get a real-time video.

You need to have avconv installed!

just type:

./ yourbag.bag

and you will get a video file <topic>.mp4 with 25 fps and h264 encoded

edit flag offensive delete link more

answered 2012-12-06 06:52:55 -0600

anagena gravatar image


I am with the same problem. Can you post the link with the updated answer?


edit flag offensive delete link more


Yes sure. Here the link.

Astronaut gravatar imageAstronaut ( 2012-12-06 13:50:18 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2012-09-28 23:08:08 -0600

Seen: 12,739 times

Last updated: Dec 06 '12