Rosanswers logo

I am trying to convert a .bag file to .mp4 by following this tutorial: How to export image and video data from a bag file

I did the following steps:

  1. Ran: roscd image_view && rosmake image_view && sudo apt-get install mjpegtools
  2. Created an export.launch file containing the code from the tutorial (file placed in /opt/ros/melodic/share/image_view)
  3. Placed test.bag in /opt/ros/melodic/share/image_view
  4. Ran roslaunch export.launch

After running the command roslaunch export.launch, there are no .jpeg files in the ~/.ros directory like the tutorial says there should be.

The output of the roslaunch command is:

ThinkCentre-M90n-1:/opt/ros/melodic/share/image_view $ roslaunch export.launch
... logging to /home/max/.ros/log/801ba47c-f76e-11ea-b576-4074e0bec8b4/roslaunch-max-ThinkCentre-M90n-1-12751.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://max-ThinkCentre-M90n-1:33177/


 * /rosdistro: melodic
 * /rosversion: 1.14.9

    extract (image_view/extract_images)
    rosbag (rosbag/play)

auto-starting new master
process[master]: started with pid [12761]

setting /run_id to 801ba47c-f76e-11ea-b576-4074e0bec8b4
process[rosout-1]: started with pid [12774]
started core service [/rosout]
process[rosbag-2]: started with pid [12780]
process[extract-3]: started with pid [12782]
[ INFO] [1600186456.400606637]: Initialized sec per frame to 0.100000
================================================================================REQUIRED process [rosbag-2] has died!
process has finished cleanly
log file: /home/max/.ros/log/801ba47c-f76e-11ea-b576-4074e0bec8b4/rosbag-2*.log
Initiating shutdown!
[extract-3] killing on exit
[rosbag-2] killing on exit
[rosout-1] killing on exit
[master] killing on exit
shutting down processing monitor...
... shutting down processing monitor complete

The log file contains:

[ INFO] [1600186456.311782786]: Opening /opt/ros/melodic/share/image_view/test_mask.bag

Waiting 0.2 seconds after advertising topics... done.

Hit space to toggle paused, or 's' to step.
 [RUNNING]  Bag Time:     34.406766   Duration: 34.406766 / 34.439933               6456.59 

Does anyone know what's wrong? I am new to ROS (using melodic), am just using it to try to convert a .bag file I recorded on an Intel Realsense camera to .mp4.

Originally posted by mhudne11 on ROS Answers with karma: 3 on 2020-09-15

Post score: 0


1 Answer 1


Rosanswers logo

It looks like there are several problems here:

  1. The contents of this tutorial are incredibly old. The rosmake command hasn't been used since before kinetic, which will be EOL next year.
  2. You should be creating your files in a ROS workspace in your home directory instead of trying to make changes to /opt/ros which is where binary packages are installed. See this page for more information about workspaces.
  3. For some reason, the launch file assumes that your rosbag will be in /opt/ros as well. For the reasons stated in 2, you should have it elsewhere (like your workspace) and replace the path $(find image_view)/test.bag with the full path to the rosbag.
  4. Based on the code in image_view/extract_images, the node will drop the images in the folder in which you run the launch file, not ~/.ros. This is why it is important to run the launch file somewhere that your user has write access to (like your home folder).

You should install the image_view package instead of building it from source. There is no need to build it from source as binaries exist for all current ROS versions. If you're using Ubuntu, the package name is ros-melodic-image-view. Once it's installed, source /opt/ros/melodic/setup.bash and your launch file should work.

Originally posted by Josh Whitley with karma: 1766 on 2020-09-15

This answer was ACCEPTED on the original site

Post score: 1

Original comments

Comment by mhudne11 on 2020-09-16:
Thank you for the clear explanation. By installing image_view, sourcing that bash file and using a different workspace, it worked! I also realized that I had to replace the topic in export.launch, i was able to find a list of topics in the .bag file with rostopic -b test_mask.bag. There were many topics, but the one which sounded the most reasonable was /device_0/sensor_1/Color_0/image/data.

The only issue I have now is the extracted number of frames was much less than expected (it output 295 when the .bag file contains ~1100). Do you know what might cause it to skip frames?

Comment by Josh Whitley on 2020-09-16:
Sorry, not sure what's causing that. Might want to check the rate at which the images are being produced from the bag file and how the saver is imlemented in extract_images.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.