ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

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

Hello

I followed the tutorial [http://www.ros.org/wiki/rosbag/Tutorials/Exporting%20image%20and%20video%20data] about extracting video from bag file. I create a launch file like this

<launch>
  <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"/>
  </node>
</launch>

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

Thanks

edit retag flag offensive close merge delete

Comments

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 image joq  ( 2012-09-29 08:50:51 -0600 )edit

4 Answers

Sort by ยป oldest newest most voted
3

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.

Update:

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

Comments

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

Astronaut gravatar image Astronaut  ( 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 image jarvisschultz  ( 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 image Astronaut  ( 2012-10-01 18:22:18 -0600 )edit

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

Mani gravatar image Mani  ( 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 image Astronaut  ( 2012-10-01 19:18:19 -0600 )edit

I think the name for 10.04 used to be mjpegtools: https://launchpad.net/ubuntu/lucid/+package/mjpegtools

Mani gravatar image Mani  ( 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 image Astronaut  ( 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 image Astronaut  ( 2012-10-01 19:49:29 -0600 )edit
2

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

mlaiacker gravatar image

Hello,

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. https://github.com/mlaiacker/rosbag2video

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:

./rosbag2video.py yourbag.bag

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

edit flag offensive delete link more
0

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

anagena gravatar image

Mani,

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

Tks,

edit flag offensive delete link more

Comments

Yes sure. Here the link. https://coderwall.com/p/qewf6g

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

answered 2022-06-29 20:26:09 -0600

iory gravatar image

You can use jsk_rosbag_toolsto extract video from bag files. https://github.com/jsk-ros-pkg/jsk_co...

Example

rosrun jsk_rosbag_tools bag_to_video.py $(rospack find jsk_rosbag_tools)/samples/data/20220530173950_go_to_kitchen_rosbag.bag \ --samplerate 16000 --channels 1 --audio-topic /audio \ --image-topic /head_camera/rgb/throttled/image_rect_color/compressed \ -o /tmp/20220530173950_go_to_kitchen_rosbag.mp4

edit flag offensive delete link more

Question Tools

1 follower

Stats

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

Seen: 23,084 times

Last updated: Dec 06 '12