mlaiacker / rosbag2video

converts image sequence in ros bag files to video files
GNU General Public License v2.0
309 stars 109 forks source link

Port to ROS2 #19

Closed cardboardcode closed 3 years ago

cardboardcode commented 3 years ago

Hi @mlaiacker, thank you for providing this convenient tool. It has been helpful in converting ROS1 bags to .mp4 videos. :smile: :+1:

Question

Do you plan to port this script to ROS2 Foxy?

If none at the moment, I will be happy to take a look at porting the script myself and sharing it via a Pull Request.

mlaiacker commented 3 years ago

Hi, thanks for the message. I am happy that my (not so nice code) is helping. I am currently not working with ROS so it would be nice if you do the porting.

cardboardcode commented 3 years ago

Thanks for the quick response. @mlaiacker

Noted. Then I get started working on a quick prototype and update my progress using this issue thread. :smile:

cardboardcode commented 3 years ago

An experimental port of the rosbag2video.py python script has been done and can be found under the new foxy branch.

https://github.com/mlaiacker/rosbag2video/tree/foxy

The new script is called ros2bag2video.py.

Status

This port is still incomplete due to the dirty hacky nature of the port and the lack of a proper rosbag2 python API that allows us to read a ROS2 bag file fully programmatically. The API implementation will be in the rolling distribution, instead of ROS2 Foxy, as seen in this issue thread.

That being said, it still works for simple ROS2 bag files (at least the ones I have tested on my own). For now, it is able to read sensor_msgs/Image ROS2 messages only and deal with bgr8 encoding.

Remaining Porting Tasks

Will continue working on this when I have the time.

Hope this helps anyone who is looking to convert their ROS2 bag files into .mp4 files.

cardboardcode commented 3 years ago

To verify the ported features to accomodate different ROS2 image message type,

If you have a ROS2 bag file that has a ROS2 sensor_msgs/msg/CompressedImage or theora_image_transport/msg/Packet topic,

please comment below to indicate if you can share it with me in order to do the testing.

cardboardcode commented 3 years ago

We won't be using avconv anymore

Porting the use of avconv is determined to be unnecessary based on my own understanding of the differences between avconv and ffmpeg.

Reference: https://superuser.com/a/507473

Rationale

Libav or avconv development activity has nearly ceased as of 13th December 2019. ffmpeg will continue to be maintained with talks of Libav developers participating in FFmpeg once again, signalling a reintegration of Libav into FFmpeg.

Also, it is so much easier and intutive to use ffmpeg instead, at least in my opinion.

mlaiacker commented 3 years ago

I am fine with using ffmpeg

cardboardcode commented 3 years ago

Python script ros2bag2video.py has been adhered to PEP8 python linting standards.

It is verified to adhere by running the following pycodestyle too and generating the following output:

pip3 install pycodestyle
pycodestyle --show-source ros2bag2video.py
# No output shown. No linting errors found.

pycodestyle is the renamed pep8 linting python tool. Click here for more details.

cardboardcode commented 3 years ago

Porting has been completed tentatively, to the best of my understanding of what a robust and readable python script ought to be.

Closing issue. :closed_book:

For further testing and issues. Please submit as an issue and I will address them with the appropriate fixes. Thank you. :smile: