GithubHelp home page GithubHelp logo

mlaiacker / rosbag2video Goto Github PK

View Code? Open in Web Editor NEW
301.0 301.0 105.0 58 KB

converts image sequence in ros bag files to video files

License: GNU General Public License v2.0

Python 100.00%
python robotics ros

rosbag2video's People

Contributors

abelgabornng avatar andyblightleeds avatar fabianthomsen avatar mlaiacker avatar nicolaiharich avatar petrapa6 avatar plusk01 avatar randomlylelo avatar sneheshs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

rosbag2video's Issues

unsupported encoding: mono16 /depth_image

Hi, Thank you for the great work.

My rosbag topic is /depth_image with datatype: sensor_msgs/Image, it obtained by convert lidar (VLP-16) point clouds into a depth image (mono16).

Could you give me some suggestions to use your code to support my datatype?
Any help is much appreciated:)

-fps vs -r

You use both -fps (usage) and -r (example) as parameters in the readme. I guess it should only be -r?

how to convert a ros2 humble bag to a video using ros2bag2video.py Python script?

I am not sure how to use ros2bag2video.py file for a ros2 bag created using ros 2 humble. If I don't use -t flag it tells me I have to use topic name and when I select one of the topics from the metadata.yaml file of the recorded bag file, I get this error. What's your opinion? Thanks for any input.

(base) mona@ada:~/rosbag2video$ /usr/bin/python3.10 ros2bag2video.py -t /camera/camera/extrinsics/depth_to_color ~/rosbag2_2023_11_01-15_52_42/
FPS (int) =  25
Rate (float) =  1.0
Topic (str) =  /camera/camera/extrinsics/depth_to_color
Output File (str) =  output.mp4
Verbose (bool) =  False
Reading info from bag file: /home/mona/rosbag2_2023_11_01-15_52_42/
ROS Message name =  realsense2_camera_msgs/msg/Extrinsics
Image count =  1
msgtype =  None
AJB: subscribing to msg:  None on topic:  /camera/camera/extrinsics/depth_to_color
Traceback (most recent call last):
  File "/home/mona/rosbag2video/ros2bag2video.py", line 430, in <module>
    main(sys.argv)
  File "/home/mona/rosbag2video/ros2bag2video.py", line 420, in main
    videowriter = RosVideoWriter(args)
  File "/home/mona/rosbag2video/ros2bag2video.py", line 142, in __init__
    self.subscription = self.create_subscription(
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/node.py", line 1367, in create_subscription
    check_is_valid_msg_type(msg_type)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/type_support.py", line 35, in check_is_valid_msg_type
    check_for_type_support(msg_type)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/type_support.py", line 20, in check_for_type_support
    ts = msg_or_srv_type.__class__._TYPE_SUPPORT
AttributeError: type object 'NoneType' has no attribute '_TYPE_SUPPORT' This might be a ROS 1 message type but it should be a ROS 2 message type. Make sure to source your ROS 2 workspace after your ROS 1 workspace.

and with no topic, I get this error:

(base) mona@ada:~/rosbag2video$ /usr/bin/python3.10 ros2bag2video.py ~/rosbag2_2023_11_01-15_52_42/
FPS (int) =  25
Rate (float) =  1.0
Topic (str) =  
Output File (str) =  output.mp4
Verbose (bool) =  False
Reading info from bag file: /home/mona/rosbag2_2023_11_01-15_52_42/
ROS Message name =  geometry_msgs/msg/PointStamped
Image count =  0
msgtype =  None
AJB: subscribing to msg:  None on topic:  
Traceback (most recent call last):
  File "/home/mona/rosbag2video/ros2bag2video.py", line 430, in <module>
    main(sys.argv)
  File "/home/mona/rosbag2video/ros2bag2video.py", line 420, in main
    videowriter = RosVideoWriter(args)
  File "/home/mona/rosbag2video/ros2bag2video.py", line 142, in __init__
    self.subscription = self.create_subscription(
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/node.py", line 1356, in create_subscription
    raise ex from None
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/node.py", line 1354, in create_subscription
    self._validate_topic_or_service_name(topic)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/node.py", line 1183, in _validate_topic_or_service_name
    validate_topic_name(topic_or_service_name, is_service=is_service)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/validate_topic_name.py", line 43, in validate_topic_name
    raise InvalidTopicNameException(name, error_msg, invalid_index)
rclpy.exceptions.InvalidTopicNameException: Invalid topic name: topic name must not be empty string:
  ''
   ^

I also have:

$ ls ~/rosbag2_2023_11_01-15_52_42/
total 2.7G
-rw-r--r--  1 mona mona 2.7G Nov  1 15:54 rosbag2_2023_11_01-15_52_42_0.db3
-rw-rw-r--  1 mona mona  10K Nov  1 15:54 metadata.yaml
drwxr-x--- 56 mona mona 4.0K Nov  1 16:00 ..
drwxrwxr-x  2 mona mona 4.0K Nov  1 16:00 .

and here's the metadata.yaml file content:

rosbag2_bagfile_information:
  version: 5
  storage_identifier: sqlite3
  duration:
    nanoseconds: 86343663847
  starting_time:
    nanoseconds_since_epoch: 1698868362240195604
  message_count: 10373
  topics_with_message_count:
    - topic_metadata:
        name: /goal_pose
        type: geometry_msgs/msg/PoseStamped
        serialization_format: cdr
        offered_qos_profiles: "- history: 3\n  depth: 0\n  reliability: 1\n  durability: 2\n  deadline:\n    sec: 9223372036\n    nsec: 854775807\n  lifespan:\n    sec: 9223372036\n    nsec: 854775807\n  liveliness: 1\n  liveliness_lease_duration:\n    sec: 9223372036\n    nsec: 854775807\n  avoid_ros_namespace_conventions: false"
      message_count: 0
    - topic_metadata:
        name: /camera/camera/extrinsics/depth_to_color
        type: realsense2_camera_msgs/msg/Extrinsics
        serialization_format: cdr
        offered_qos_profiles: "- history: 3\n  depth: 0\n  reliability: 1\n  durability: 1\n  deadline:\n    sec: 9223372036\n    nsec: 854775807\n  lifespan:\n    sec: 9223372036\n    nsec: 854775807\n  liveliness: 1\n  liveliness_lease_duration:\n    sec: 9223372036\n    nsec: 854775807\n  avoid_ros_namespace_conventions: false"
      message_count: 1
    - topic_metadata:
        name: /events/write_split
        type: rosbag2_interfaces/msg/WriteSplitEvent
        serialization_format: cdr
        offered_qos_profiles: "- history: 3\n  depth: 0\n  reliability: 1\n  durability: 2\n  deadline:\n    sec: 9223372036\n    nsec: 854775807\n  lifespan:\n    sec: 9223372036\n    nsec: 854775807\n  liveliness: 1\n  liveliness_lease_duration:\n    sec: 9223372036\n    nsec: 854775807\n  avoid_ros_namespace_conventions: false"
      message_count: 0
    - topic_metadata:
        name: /camera/camera/color/camera_info
        type: sensor_msgs/msg/CameraInfo
        serialization_format: cdr
        offered_qos_profiles: "- history: 3\n  depth: 0\n  reliability: 1\n  durability: 2\n  deadline:\n    sec: 9223372036\n    nsec: 854775807\n  lifespan:\n    sec: 9223372036\n    nsec: 854775807\n  liveliness: 1\n  liveliness_lease_duration:\n    sec: 9223372036\n    nsec: 854775807\n  avoid_ros_namespace_conventions: false"
      message_count: 1295
    - topic_metadata:
        name: /tf_static
        type: tf2_msgs/msg/TFMessage
        serialization_format: cdr
        offered_qos_profiles: "- history: 3\n  depth: 0\n  reliability: 1\n  durability: 1\n  deadline:\n    sec: 9223372036\n    nsec: 854775807\n  lifespan:\n    sec: 9223372036\n    nsec: 854775807\n  liveliness: 1\n  liveliness_lease_duration:\n    sec: 9223372036\n    nsec: 854775807\n  avoid_ros_namespace_conventions: false"
      message_count: 1
    - topic_metadata:
        name: /camera/camera/aligned_depth_to_color/camera_info
        type: sensor_msgs/msg/CameraInfo
        serialization_format: cdr
        offered_qos_profiles: "- history: 3\n  depth: 0\n  reliability: 1\n  durability: 2\n  deadline:\n    sec: 9223372036\n    nsec: 854775807\n  lifespan:\n    sec: 9223372036\n    nsec: 854775807\n  liveliness: 1\n  liveliness_lease_duration:\n    sec: 9223372036\n    nsec: 854775807\n  avoid_ros_namespace_conventions: false"
      message_count: 1295
    - topic_metadata:
        name: /camera/camera/color/metadata
        type: realsense2_camera_msgs/msg/Metadata
        serialization_format: cdr
        offered_qos_profiles: "- history: 3\n  depth: 0\n  reliability: 1\n  durability: 2\n  deadline:\n    sec: 9223372036\n    nsec: 854775807\n  lifespan:\n    sec: 9223372036\n    nsec: 854775807\n  liveliness: 1\n  liveliness_lease_duration:\n    sec: 9223372036\n    nsec: 854775807\n  avoid_ros_namespace_conventions: false"
      message_count: 1295
    - topic_metadata:
        name: /camera/camera/depth/image_rect_raw
        type: sensor_msgs/msg/Image
        serialization_format: cdr
        offered_qos_profiles: "- history: 3\n  depth: 0\n  reliability: 1\n  durability: 1\n  deadline:\n    sec: 9223372036\n    nsec: 854775807\n  lifespan:\n    sec: 9223372036\n    nsec: 854775807\n  liveliness: 1\n  liveliness_lease_duration:\n    sec: 9223372036\n    nsec: 854775807\n  avoid_ros_namespace_conventions: false"
      message_count: 1295
    - topic_metadata:
        name: /rosout
        type: rcl_interfaces/msg/Log
        serialization_format: cdr
        offered_qos_profiles: "- history: 3\n  depth: 0\n  reliability: 1\n  durability: 1\n  deadline:\n    sec: 9223372036\n    nsec: 854775807\n  lifespan:\n    sec: 10\n    nsec: 0\n  liveliness: 1\n  liveliness_lease_duration:\n    sec: 9223372036\n    nsec: 854775807\n  avoid_ros_namespace_conventions: false\n- history: 3\n  depth: 0\n  reliability: 1\n  durability: 1\n  deadline:\n    sec: 9223372036\n    nsec: 854775807\n  lifespan:\n    sec: 10\n    nsec: 0\n  liveliness: 1\n  liveliness_lease_duration:\n    sec: 9223372036\n    nsec: 854775807\n  avoid_ros_namespace_conventions: false\n- history: 3\n  depth: 0\n  reliability: 1\n  durability: 1\n  deadline:\n    sec: 9223372036\n    nsec: 854775807\n  lifespan:\n    sec: 10\n    nsec: 0\n  liveliness: 1\n  liveliness_lease_duration:\n    sec: 9223372036\n    nsec: 854775807\n  avoid_ros_namespace_conventions: false\n- history: 3\n  depth: 0\n  reliability: 1\n  durability: 1\n  deadline:\n    sec: 9223372036\n    nsec: 854775807\n  lifespan:\n    sec: 10\n    nsec: 0\n  liveliness: 1\n  liveliness_lease_duration:\n    sec: 9223372036\n    nsec: 854775807\n  avoid_ros_namespace_conventions: false"
      message_count: 10
    - topic_metadata:
        name: /parameter_events
        type: rcl_interfaces/msg/ParameterEvent
        serialization_format: cdr
        offered_qos_profiles: "- history: 3\n  depth: 0\n  reliability: 1\n  durability: 2\n  deadline:\n    sec: 9223372036\n    nsec: 854775807\n  lifespan:\n    sec: 9223372036\n    nsec: 854775807\n  liveliness: 1\n  liveliness_lease_duration:\n    sec: 9223372036\n    nsec: 854775807\n  avoid_ros_namespace_conventions: false\n- history: 3\n  depth: 0\n  reliability: 1\n  durability: 2\n  deadline:\n    sec: 9223372036\n    nsec: 854775807\n  lifespan:\n    sec: 9223372036\n    nsec: 854775807\n  liveliness: 1\n  liveliness_lease_duration:\n    sec: 9223372036\n    nsec: 854775807\n  avoid_ros_namespace_conventions: false"
      message_count: 0
    - topic_metadata:
        name: /camera/camera/depth/camera_info
        type: sensor_msgs/msg/CameraInfo
        serialization_format: cdr
        offered_qos_profiles: "- history: 3\n  depth: 0\n  reliability: 1\n  durability: 2\n  deadline:\n    sec: 9223372036\n    nsec: 854775807\n  lifespan:\n    sec: 9223372036\n    nsec: 854775807\n  liveliness: 1\n  liveliness_lease_duration:\n    sec: 9223372036\n    nsec: 854775807\n  avoid_ros_namespace_conventions: false"
      message_count: 1295
    - topic_metadata:
        name: /initialpose
        type: geometry_msgs/msg/PoseWithCovarianceStamped
        serialization_format: cdr
        offered_qos_profiles: "- history: 3\n  depth: 0\n  reliability: 1\n  durability: 2\n  deadline:\n    sec: 9223372036\n    nsec: 854775807\n  lifespan:\n    sec: 9223372036\n    nsec: 854775807\n  liveliness: 1\n  liveliness_lease_duration:\n    sec: 9223372036\n    nsec: 854775807\n  avoid_ros_namespace_conventions: false"
      message_count: 0
    - topic_metadata:
        name: /camera/camera/color/image_raw
        type: sensor_msgs/msg/Image
        serialization_format: cdr
        offered_qos_profiles: "- history: 3\n  depth: 0\n  reliability: 1\n  durability: 1\n  deadline:\n    sec: 9223372036\n    nsec: 854775807\n  lifespan:\n    sec: 9223372036\n    nsec: 854775807\n  liveliness: 1\n  liveliness_lease_duration:\n    sec: 9223372036\n    nsec: 854775807\n  avoid_ros_namespace_conventions: false"
      message_count: 1295
    - topic_metadata:
        name: /camera/camera/aligned_depth_to_color/image_raw
        type: sensor_msgs/msg/Image
        serialization_format: cdr
        offered_qos_profiles: "- history: 3\n  depth: 0\n  reliability: 1\n  durability: 1\n  deadline:\n    sec: 9223372036\n    nsec: 854775807\n  lifespan:\n    sec: 9223372036\n    nsec: 854775807\n  liveliness: 1\n  liveliness_lease_duration:\n    sec: 9223372036\n    nsec: 854775807\n  avoid_ros_namespace_conventions: false"
      message_count: 1295
    - topic_metadata:
        name: /camera/camera/depth/metadata
        type: realsense2_camera_msgs/msg/Metadata
        serialization_format: cdr
        offered_qos_profiles: "- history: 3\n  depth: 0\n  reliability: 1\n  durability: 2\n  deadline:\n    sec: 9223372036\n    nsec: 854775807\n  lifespan:\n    sec: 9223372036\n    nsec: 854775807\n  liveliness: 1\n  liveliness_lease_duration:\n    sec: 9223372036\n    nsec: 854775807\n  avoid_ros_namespace_conventions: false"
      message_count: 1295
    - topic_metadata:
        name: /camera/camera/extrinsics/depth_to_depth
        type: realsense2_camera_msgs/msg/Extrinsics
        serialization_format: cdr
        offered_qos_profiles: "- history: 3\n  depth: 0\n  reliability: 1\n  durability: 1\n  deadline:\n    sec: 9223372036\n    nsec: 854775807\n  lifespan:\n    sec: 9223372036\n    nsec: 854775807\n  liveliness: 1\n  liveliness_lease_duration:\n    sec: 9223372036\n    nsec: 854775807\n  avoid_ros_namespace_conventions: false"
      message_count: 1
    - topic_metadata:
        name: /clicked_point
        type: geometry_msgs/msg/PointStamped
        serialization_format: cdr
        offered_qos_profiles: "- history: 3\n  depth: 0\n  reliability: 1\n  durability: 2\n  deadline:\n    sec: 9223372036\n    nsec: 854775807\n  lifespan:\n    sec: 9223372036\n    nsec: 854775807\n  liveliness: 1\n  liveliness_lease_duration:\n    sec: 9223372036\n    nsec: 854775807\n  avoid_ros_namespace_conventions: false"
      message_count: 0
  compression_format: ""
  compression_mode: ""
  relative_file_paths:
    - rosbag2_2023_11_01-15_52_42_0.db3
  files:
    - path: rosbag2_2023_11_01-15_52_42_0.db3
      starting_time:
        nanoseconds_since_epoch: 1698868362240195604
      duration:
        nanoseconds: 86343663847
      message_count: 10373

AttributeError: 'CompressedImage' object has no attribute 'encoding'

in ROS2 Environment when I run with ./ros2bag2video.py ~

./ros2bag2video.py: line 17: import: command not found
./ros2bag2video.py: line 18: import: command not found
./ros2bag2video.py: line 19: import: command not found
./ros2bag2video.py: line 20: import: command not found
./ros2bag2video.py: line 21: import: command not found
./ros2bag2video.py: line 22: import: command not found
./ros2bag2video.py: line 23: from: command not found
./ros2bag2video.py: line 24: from: command not found
./ros2bag2video.py: line 26: from: command not found
./ros2bag2video.py: line 27: from: command not found
./ros2bag2video.py: line 28: try:: command not found
./ros2bag2video.py: line 29: from: command not found
./ros2bag2video.py: line 30: except: command not found
./ros2bag2video.py: line 31: pass: command not found
./ros2bag2video.py: line 32: from: command not found
./ros2bag2video.py: line 33: from: command not found
./ros2bag2video.py: line 34: from: command not found
./ros2bag2video.py: line 35: from: command not found
./ros2bag2video.py: line 37: VIDEO_CONVERTER_TO_USE: command not found
./ros2bag2video.py: line 40: syntax error near unexpected token (' ./ros2bag2video.py: line 40: def print_help():'

in ROS2 Environment when I run with python3 ros2bag2video.py ~

AttributeError: 'CompressedImage' object has no attribute 'encoding'

Type: sensor_msgs/msg/CompressedImage

I am trying to convert Type: sensor_msgs/msg/CompressedImage to viedo file

how can I solve this problem?

Object has no attribute 'format'

I installed the code and I run it. There was no problem but no video has been generated. After that, I installed the following dependencies and tried to run the python code again and an error occurred.

sudo apt install python3-roslib python3-sensor-msgs python3-opencv

The error is as follows:


Traceback (most recent call last):
  File "./rosbag2video.py", line 209, in addBag
    if msg.format.find("jpeg")!=-1 :
AttributeError: '_sensor_msgs__Image' object has no attribute 'format'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./rosbag2video.py", line 305, in <module>
    videowriter.addBag(bagfile)
  File "./rosbag2video.py", line 264, in addBag
    self.write_output_video( msg, topic, t, RAWIMAGE_VIDEO, pix_fmt )
  File "./rosbag2video.py", line 185, in write_output_video
    self.p_avconv[topic].stdin.write(msg.data)
BrokenPipeError: [Errno 32] Broken pipe

Are there any other dependencies required? 


rosbag2video not showingup any output

robolab@robolab-Super-Server:$ python bag2video.py --fps 30 -t /device_0/sensor_1/Color_0/image/data /media/robolab/BISG_Siva/Rusko/20200121_132058.bag
('using ', 30.0, ' FPS')
############# USING ######################
('/device_0/sensor_1/Color_0/image/data', ' with datatype:', 'sensor_msgs/Image')
robolab@robolab-Super-Server:
$

no roslib module

Hi, I followed your instruction to install python3-roslib and it showed no error.
but when it finished, I can not import roslib module. It showed no such module.
my system is Ubuntu 20.04.3 LTS (Focal Fossa).
Thank you.

please,helpe me.How did this error occur

/rosbag2_2022_06_16-15_57_04/
import-im6.q16: unable to grab mouse ': No such file or directory @ error/xwindow.c/XSelectWindow/9187. import-im6.q16: unable to grab mouse ': No such file or directory @ error/xwindow.c/XSelectWindow/9187.
import-im6.q16: unable to grab mouse ': No such file or directory @ error/xwindow.c/XSelectWindow/9187. import-im6.q16: unable to grab mouse ': No such file or directory @ error/xwindow.c/XSelectWindow/9187.
import-im6.q16: unable to grab mouse ': No such file or directory @ error/xwindow.c/XSelectWindow/9187. import-im6.q16: unable to grab mouse ': No such file or directory @ error/xwindow.c/XSelectWindow/9187.
from: can't read /var/mail/rclpy.node
from: can't read /var/mail/cv_bridge
from: can't read /var/mail/sensor_msgs.msg
from: can't read /var/mail/sensor_msgs.msg
./ros2bag2video.py: line 28: try:: command not found
from: can't read /var/mail/theora_image_transport.msg
./ros2bag2video.py: line 30: except: command not found
./ros2bag2video.py: line 31: pass: command not found
from: can't read /var/mail/ros2bag.api
from: can't read /var/mail/ros2cli.node
from: can't read /var/mail/argparse
./ros2bag2video.py: line 37: VIDEO_CONVERTER_TO_USE: command not found
./ros2bag2video.py: line 40: syntax error near unexpected token (' ./ros2bag2video.py: line 40: def print_help():'

/usr/bin/python3.10 ros2bag2video.py ~/Downloads/cheezit_1280_whole.bag --> rclpy.exceptions.InvalidTopicNameException: Invalid topic name: topic name must not be empty string: ''

I have a bag file called cheezeit_1280_whole.bag how do I use ros2bag2video.py for converting it to a video? It seems the way I am using it is wrong.

(base) mona@ada:~/rosbag2video$ /usr/bin/python3.10 ros2bag2video.py ~/Downloads/cheezit_1280_whole.bag 
FPS (int) =  25
Rate (float) =  1.0
Topic (str) =  
Output File (str) =  output.mp4
Verbose (bool) =  False
Reading info from bag file: /home/mona/Downloads/cheezit_1280_whole.bag
[ERROR] [1698850707.416016253] [rosbag2_storage]: No storage id specified, and no plugin found that could open URI
No plugin detected that could open file /home/mona/Downloads/cheezit_1280_whole.bag
ROS Message name =  
Image count =  0
msgtype =  None
AJB: subscribing to msg:  None on topic:  
Traceback (most recent call last):
  File "/home/mona/rosbag2video/ros2bag2video.py", line 430, in <module>
    main(sys.argv)
  File "/home/mona/rosbag2video/ros2bag2video.py", line 420, in main
    videowriter = RosVideoWriter(args)
  File "/home/mona/rosbag2video/ros2bag2video.py", line 142, in __init__
    self.subscription = self.create_subscription(
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/node.py", line 1356, in create_subscription
    raise ex from None
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/node.py", line 1354, in create_subscription
    self._validate_topic_or_service_name(topic)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/node.py", line 1183, in _validate_topic_or_service_name
    validate_topic_name(topic_or_service_name, is_service=is_service)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/validate_topic_name.py", line 43, in validate_topic_name
    raise InvalidTopicNameException(name, error_msg, invalid_index)
rclpy.exceptions.InvalidTopicNameException: Invalid topic name: topic name must not be empty string:
  ''
   ^
(base) mona@ada:~/rosbag2video$ ls
total 72K
-rwxrwxr-x  1 mona mona  14K Nov  1 09:31 rosbag2video.py
-rwxrwxr-x  1 mona mona  14K Nov  1 09:31 ros2bag2video.py
-rw-rw-r--  1 mona mona 2.5K Nov  1 09:31 README.md
-rw-rw-r--  1 mona mona  18K Nov  1 09:31 LICENSE
-rw-rw-r--  1 mona mona  755 Nov  1 09:31 .gitignore
drwxrwxr-x  8 mona mona 4.0K Nov  1 09:31 .git
drwxrwxr-x  3 mona mona 4.0K Nov  1 09:31 .
drwxr-x--- 55 mona mona 4.0K Nov  1 10:48 ..
(base) mona@ada:~/rosbag2video$ mkdir bag_out
(base) mona@ada:~/rosbag2video$ /usr/bin/python3.10 ros2bag2video.py ~/Downloads/cheezit_1280_whole.bag  bag_out/
FPS (int) =  25
Rate (float) =  1.0
Topic (str) =  
Output File (str) =  output.mp4
Verbose (bool) =  False
Reading info from bag file: /home/mona/Downloads/cheezit_1280_whole.bag
[ERROR] [1698850810.162299632] [rosbag2_storage]: No storage id specified, and no plugin found that could open URI
No plugin detected that could open file /home/mona/Downloads/cheezit_1280_whole.bag
ROS Message name =  
Image count =  0
msgtype =  None
AJB: subscribing to msg:  None on topic:  
Traceback (most recent call last):
  File "/home/mona/rosbag2video/ros2bag2video.py", line 430, in <module>
    main(sys.argv)
  File "/home/mona/rosbag2video/ros2bag2video.py", line 420, in main
    videowriter = RosVideoWriter(args)
  File "/home/mona/rosbag2video/ros2bag2video.py", line 142, in __init__
    self.subscription = self.create_subscription(
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/node.py", line 1356, in create_subscription
    raise ex from None
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/node.py", line 1354, in create_subscription
    self._validate_topic_or_service_name(topic)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/node.py", line 1183, in _validate_topic_or_service_name
    validate_topic_name(topic_or_service_name, is_service=is_service)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/validate_topic_name.py", line 43, in validate_topic_name
    raise InvalidTopicNameException(name, error_msg, invalid_index)
rclpy.exceptions.InvalidTopicNameException: Invalid topic name: topic name must not be empty string:
  ''
   ^

I have ROS 2 Humble in Ubuntu 22.04. The bag file can be downloaded from here: NVlabs/BundleSDF#82 (comment)

Also, I have:

(base) mona@ada:~/rosbag2video$ ros2 bag info  /home/mona/Downloads/cheezit_1280_whole.bag

closing.

closing.
[ERROR] [1698864601.552300192] [rosbag2_storage]: No storage id specified, and no plugin found that could open URI
No plugin detected that could open file /home/mona/Downloads/cheezit_1280_whole.bag
(base) mona@ada:~/rosbag2video$ ls /home/mona/Downloads/cheezit_1280_whole.bag
-rw-rw-r-- 1 mona mona 11G Nov  1 09:33 /home/mona/Downloads/cheezit_1280_whole.bag

Cannot import name CvBridge

Hallo mlaiacker ,

since a new update of my ubuntu 16.04 LTS I get the following error message while I want to create a mp4-video from a rosbag:

Traceback (most recent call last):
File "rosbag2video.py", line 18, in
from cv_bridge import CvBridge, CvBridgeError
ImportError: cannot import name CvBridge"

My python version is:

Python 2.7.12 (default, Oct 8 2019, 14:14:10)
[GCC 5.4.0 20160609] on linux2

Could you please help me?

Best regards
MiroslavAndje

Generated video file is black

i've used the package and i had problems with the lz4 compressed file, so first i used a decompressed bag file.
Then i run the command:
python3 rosbag2video.py 20210915_091839.bag
with output:

Failed to load Python extension for LZ4 support. LZ4 compression will not be available.
############# UNCOMPRESSED IMAGE ######################
/device_0/sensor_1/Color_0/image/data  with datatype: sensor_msgs/Image

finished503 fps=143 q=28.0 size=    2304kB time=00:00:17.76 bitrate=1062.8kbits/s speed=5.03x 

and the .mp4 file is generated, but when i play it, it is a black screen only.
Any suggestions on what may be the problem?

Running rosbag info 20210915_091839.bag shows:

path:        20210915_091839.bag
version:     2.0
duration:    22.0s
start:       Dec 31 1969 19:00:00.00 (0.00)
end:         Dec 31 1969 19:00:21.97 (21.97)
size:        1.5 GB
messages:    28508
compression: none [1292/1292 chunks]
types:       diagnostic_msgs/KeyValue  [cf57fdc6617a881a88c16e768132149c]
             geometry_msgs/Transform   [ac9eff44abf714214112b05d54a3cf9b]
             realsense_msgs/StreamInfo [311d7e24eac31bb87271d041bf70ff7d]
             sensor_msgs/CameraInfo    [c9a58c1b0b154e0e6da7578cb991d214]
             sensor_msgs/Image         [060021388200f6f0f447d0fcd9c64743]
             std_msgs/Float32          [73fcbf46b49191e672908e50842a83d4]
             std_msgs/String           [992ce8a1687cec8c8bd883ec73ca41d1]
             std_msgs/UInt32           [304a39449588c7f8ce2df6e8001c5fce]
topics:      /device_0/info                                                       13 msgs    : diagnostic_msgs/KeyValue 
             /device_0/sensor_0/info                                               2 msgs    : diagnostic_msgs/KeyValue 
             /device_0/sensor_0/option/Auto_Exposure_Limit/description             1 msg     : std_msgs/String          
             /device_0/sensor_0/option/Auto_Exposure_Limit/value                   1 msg     : std_msgs/Float32         
             /device_0/sensor_0/option/Auto_Gain_Limit/description                 1 msg     : std_msgs/String          
             /device_0/sensor_0/option/Auto_Gain_Limit/value                       1 msg     : std_msgs/Float32         
             /device_0/sensor_0/option/Depth_Units/description                     1 msg     : std_msgs/String          
             /device_0/sensor_0/option/Depth_Units/value                           1 msg     : std_msgs/Float32         
             /device_0/sensor_0/option/Emitter_Always_On/description               1 msg     : std_msgs/String          
             /device_0/sensor_0/option/Emitter_Always_On/value                     1 msg     : std_msgs/Float32         
             /device_0/sensor_0/option/Emitter_Enabled/description                 1 msg     : std_msgs/String          
             /device_0/sensor_0/option/Emitter_Enabled/value                       1 msg     : std_msgs/Float32         
             /device_0/sensor_0/option/Emitter_On_Off/description                  1 msg     : std_msgs/String          
             /device_0/sensor_0/option/Emitter_On_Off/value                        1 msg     : std_msgs/Float32         
             /device_0/sensor_0/option/Enable_Auto_Exposure/description            1 msg     : std_msgs/String          
             /device_0/sensor_0/option/Enable_Auto_Exposure/value                  1 msg     : std_msgs/Float32         
             /device_0/sensor_0/option/Error_Polling_Enabled/description           1 msg     : std_msgs/String          
             /device_0/sensor_0/option/Error_Polling_Enabled/value                 1 msg     : std_msgs/Float32         
             /device_0/sensor_0/option/Exposure/description                        1 msg     : std_msgs/String          
             /device_0/sensor_0/option/Exposure/value                              1 msg     : std_msgs/Float32         
             /device_0/sensor_0/option/Frames_Queue_Size/description               1 msg     : std_msgs/String          
             /device_0/sensor_0/option/Frames_Queue_Size/value                     1 msg     : std_msgs/Float32         
             /device_0/sensor_0/option/Gain/description                            1 msg     : std_msgs/String          
             /device_0/sensor_0/option/Gain/value                                  1 msg     : std_msgs/Float32         
             /device_0/sensor_0/option/Global_Time_Enabled/description             1 msg     : std_msgs/String          
             /device_0/sensor_0/option/Global_Time_Enabled/value                   1 msg     : std_msgs/Float32         
             /device_0/sensor_0/option/Hdr_Enabled/description                     1 msg     : std_msgs/String          
             /device_0/sensor_0/option/Hdr_Enabled/value                           1 msg     : std_msgs/Float32         
             /device_0/sensor_0/option/Inter_Cam_Sync_Mode/description             1 msg     : std_msgs/String          
             /device_0/sensor_0/option/Inter_Cam_Sync_Mode/value                   1 msg     : std_msgs/Float32         
             /device_0/sensor_0/option/Laser_Power/description                     1 msg     : std_msgs/String          
             /device_0/sensor_0/option/Laser_Power/value                           1 msg     : std_msgs/Float32         
             /device_0/sensor_0/option/Output_Trigger_Enabled/description          1 msg     : std_msgs/String          
             /device_0/sensor_0/option/Output_Trigger_Enabled/value                1 msg     : std_msgs/Float32         
             /device_0/sensor_0/option/Sequence_Id/description                     1 msg     : std_msgs/String          
             /device_0/sensor_0/option/Sequence_Id/value                           1 msg     : std_msgs/Float32         
             /device_0/sensor_0/option/Sequence_Name/description                   1 msg     : std_msgs/String          
             /device_0/sensor_0/option/Sequence_Name/value                         1 msg     : std_msgs/Float32         
             /device_0/sensor_0/option/Sequence_Size/description                   1 msg     : std_msgs/String          
             /device_0/sensor_0/option/Sequence_Size/value                         1 msg     : std_msgs/Float32         
             /device_0/sensor_0/option/Stereo_Baseline/description                 1 msg     : std_msgs/String          
             /device_0/sensor_0/option/Stereo_Baseline/value                       1 msg     : std_msgs/Float32         
             /device_0/sensor_0/option/Visual_Preset/description                   1 msg     : std_msgs/String          
             /device_0/sensor_0/option/Visual_Preset/value                         1 msg     : std_msgs/Float32         
             /device_0/sensor_0/post_processing                                   10 msgs    : std_msgs/String          
             /device_0/sensor_1/Color_0/image/data                              1291 msgs    : sensor_msgs/Image        
             /device_0/sensor_1/Color_0/image/metadata                         27111 msgs    : diagnostic_msgs/KeyValue 
             /device_0/sensor_1/Color_0/info                                       1 msg     : realsense_msgs/StreamInfo
             /device_0/sensor_1/Color_0/info/camera_info                           1 msg     : sensor_msgs/CameraInfo   
             /device_0/sensor_1/Color_0/tf/0                                       1 msg     : geometry_msgs/Transform  
             /device_0/sensor_1/info                                               2 msgs    : diagnostic_msgs/KeyValue 
             /device_0/sensor_1/option/Auto_Exposure_Priority/description          1 msg     : std_msgs/String          
             /device_0/sensor_1/option/Auto_Exposure_Priority/value                1 msg     : std_msgs/Float32         
             /device_0/sensor_1/option/Backlight_Compensation/description          1 msg     : std_msgs/String          
             /device_0/sensor_1/option/Backlight_Compensation/value                1 msg     : std_msgs/Float32         
             /device_0/sensor_1/option/Brightness/description                      1 msg     : std_msgs/String          
             /device_0/sensor_1/option/Brightness/value                            1 msg     : std_msgs/Float32         
             /device_0/sensor_1/option/Contrast/description                        1 msg     : std_msgs/String          
             /device_0/sensor_1/option/Contrast/value                              1 msg     : std_msgs/Float32         
             /device_0/sensor_1/option/Enable_Auto_Exposure/description            1 msg     : std_msgs/String          
             /device_0/sensor_1/option/Enable_Auto_Exposure/value                  1 msg     : std_msgs/Float32         
             /device_0/sensor_1/option/Enable_Auto_White_Balance/description       1 msg     : std_msgs/String          
             /device_0/sensor_1/option/Enable_Auto_White_Balance/value             1 msg     : std_msgs/Float32         
             /device_0/sensor_1/option/Exposure/description                        1 msg     : std_msgs/String          
             /device_0/sensor_1/option/Exposure/value                              1 msg     : std_msgs/Float32         
             /device_0/sensor_1/option/Frames_Queue_Size/description               1 msg     : std_msgs/String          
             /device_0/sensor_1/option/Frames_Queue_Size/value                     1 msg     : std_msgs/Float32         
             /device_0/sensor_1/option/Gain/description                            1 msg     : std_msgs/String          
             /device_0/sensor_1/option/Gain/value                                  1 msg     : std_msgs/Float32         
             /device_0/sensor_1/option/Gamma/description                           1 msg     : std_msgs/String          
             /device_0/sensor_1/option/Gamma/value                                 1 msg     : std_msgs/Float32         
             /device_0/sensor_1/option/Global_Time_Enabled/description             1 msg     : std_msgs/String          
             /device_0/sensor_1/option/Global_Time_Enabled/value                   1 msg     : std_msgs/Float32         
             /device_0/sensor_1/option/Hue/description                             1 msg     : std_msgs/String          
             /device_0/sensor_1/option/Hue/value                                   1 msg     : std_msgs/Float32         
             /device_0/sensor_1/option/Power_Line_Frequency/description            1 msg     : std_msgs/String          
             /device_0/sensor_1/option/Power_Line_Frequency/value                  1 msg     : std_msgs/Float32         
             /device_0/sensor_1/option/Saturation/description                      1 msg     : std_msgs/String          
             /device_0/sensor_1/option/Saturation/value                            1 msg     : std_msgs/Float32         
             /device_0/sensor_1/option/Sharpness/description                       1 msg     : std_msgs/String          
             /device_0/sensor_1/option/Sharpness/value                             1 msg     : std_msgs/Float32         
             /device_0/sensor_1/option/White_Balance/description                   1 msg     : std_msgs/String          
             /device_0/sensor_1/option/White_Balance/value                         1 msg     : std_msgs/Float32         
             /device_0/sensor_1/post_processing                                    1 msg     : std_msgs/String          
             /file_version                                                         1 msg     : std_msgs/UInt32

arg parse error

elif opt in ("-r", "--fps"):
self.fps = float(arg)
elif opt in ("--rate"):
self.rate = float(arg)

should be

            elif opt in ("--fps"):
                self.fps = float(arg)
            elif opt in ("-r", "--rate"):
                self.rate = float(arg)

Code is not working

Dear @mlaiacker ,
Used you code, installed ffmpeg. The command executed

python rosbag2video.py --25 --1 -o testing.mp4 -/camera/image_raw data1.bag

and also

python rosbag2video.py --25 --1 -o testing.mp4 data1.bag

After that, followed the same syntax of your given example.

rosbag2video.py -r 50 -o test.mp4 data1.bag

I did not get any output. No video file was created.
Request support.
Thank you

ros2bag2video.py script gets stuck Python 3.10, ros2 humble, Ubuntu 22.04 in converting color raw bag to video

Could you please help to fix this problem? I am converting the color raw topic bag to video using your ros2bag2video.py script and it gets stuck here:

(base) mona@ada:~/rosbag2video$ /usr/bin/python3.10 ros2bag2video.py -v -t /camera/camera/color/image_raw ~/ros2bagmona/
Using  25  FPS
FPS (int) =  25
Rate (float) =  1.0
Topic (str) =  /camera/camera/color/image_raw
Output File (str) =  output.mp4
Verbose (bool) =  True
Reading info from bag file: /home/mona/ros2bagmona/
ROS Message name =  sensor_msgs/msg/Image
Image count =  198
msgtype =  <class 'sensor_msgs.msg._image.Image'>
AJB: subscribing to msg:  <class 'sensor_msgs.msg._image.Image'> on topic:  /camera/camera/color/image_raw
Starting ROS bag playback...
[INFO] [1698944459.964460939] [rosbag2_storage]: Opened database '/home/mona/ros2bagmona/ros2bagmona_0.db3' for READ_ONLY.
[INFO] [1698944459.964544848] [rosbag2_player]: Set rate to 1
[INFO] [1698944459.966846917] [rosbag2_player]: Adding keyboard callbacks.
[INFO] [1698944459.966888605] [rosbag2_player]: Press SPACE for Pause/Resume
[INFO] [1698944459.966900254] [rosbag2_player]: Press CURSOR_RIGHT for Play Next Message
[INFO] [1698944459.966908912] [rosbag2_player]: Press CURSOR_UP for Increase Rate 10%
[INFO] [1698944459.966915126] [rosbag2_player]: Press CURSOR_DOWN for Decrease Rate 10%
[INFO] [1698944459.967365578] [rosbag2_storage]: Opened database '/home/mona/ros2bagmona/ros2bagmona_0.db3' for READ_ONLY.

I used echo command and confirmed the bag is not empty. Also was able to play it back.

(base) mona@ada:~/rosbag2video$ /usr/bin/pip show opencv-python
Name: opencv-python
Version: 4.5.5.62
Summary: Wrapper package for OpenCV python bindings.
Home-page: https://github.com/skvark/opencv-python
Author: 
Author-email: 
License: MIT
Location: /home/mona/.local/lib/python3.10/site-packages
Requires: numpy, numpy, numpy, numpy
Required-by: 

(base) mona@ada:~/rosbag2video$ /usr/bin/pip show cv_bridge
Name: cv-bridge
Version: 3.2.1
Summary: UNKNOWN
Home-page: UNKNOWN
Author: 
Author-email: 
License: UNKNOWN
Location: /opt/ros/humble/local/lib/python3.10/dist-packages
Requires: 
Required-by: 
(base) mona@ada:~/rosbag2video$ git log
commit 13b4e064eb0ad748f3d4e20eb88353bdf76acd21 (HEAD -> master, origin/master, origin/HEAD)
Merge: 44d1637 14a7d26
Author: mlaiacker <[email protected]>
Date:   Mon Sep 18 20:11:28 2023 +0200

    Merge branch 'pipebots-humble-dev-joey'

(base) mona@ada:~/rosbag2video$ cd
(base) mona@ada:~$ uname -a
Linux ada 6.2.0-36-generic #37~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct  9 15:34:04 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
(base) mona@ada:~$ lsb_release -a
LSB Version:	core-11.1.0ubuntu4-noarch:security-11.1.0ubuntu4-noarch
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.3 LTS
Release:	22.04
Codename:	jammy

(base) mona@ada:~$ ros2 wtf
/opt/ros/humble/lib/python3.10/site-packages/ros2doctor/api/package.py: 112: UserWarning: joy has been updated to a new version. local: 3.1.0 < latest: 3.3.0
/opt/ros/humble/lib/python3.10/site-packages/ros2doctor/api/package.py: 112: UserWarning: sdl2_vendor has been updated to a new version. local: 3.1.0 < latest: 3.3.0

All 5 checks passed

(base) mona@ada:~$ ros2 bag info ros2bagmona/

Files:             ros2bagmona_0.db3
Bag size:          174.2 MiB
Storage id:        sqlite3
Duration:          13.142s
Start:             Nov  2 2023 11:52:10.972 (1698940330.972)
End:               Nov  2 2023 11:52:24.115 (1698940344.115)
Messages:          198
Topic information: Topic: /camera/camera/color/image_raw | Type: sensor_msgs/msg/Image | Count: 198 | Serialization Format: cdr

and results of bag play:

(base) mona@ada:~$ ros2 bag play ros2bagmona/
[INFO] [1698945254.104994765] [rosbag2_storage]: Opened database 'ros2bagmona/ros2bagmona_0.db3' for READ_ONLY.
[INFO] [1698945254.105062245] [rosbag2_player]: Set rate to 1
[INFO] [1698945254.108407299] [rosbag2_player]: Adding keyboard callbacks.
[INFO] [1698945254.108453868] [rosbag2_player]: Press SPACE for Pause/Resume
[INFO] [1698945254.108464504] [rosbag2_player]: Press CURSOR_RIGHT for Play Next Message
[INFO] [1698945254.108470104] [rosbag2_player]: Press CURSOR_UP for Increase Rate 10%
[INFO] [1698945254.108476593] [rosbag2_player]: Press CURSOR_DOWN for Decrease Rate 10%
[INFO] [1698945254.108946295] [rosbag2_storage]: Opened database 'ros2bagmona/ros2bagmona_0.db3' for READ_ONLY.
(base) mona@ada:~$ 

Transfer Process Doesn't Move Further

Hi,

thanks for the code. I've run it, at first it ran smoothly. After some minutes the process doesn't move forward. I waited for 30 minutes and it doesn't get any update (frozen as the screenshot below).

image

Is that a problem or how long should I wait? The .bag file is 1.4 GB.

Thanks a lot in advance.

dependencies not found

Running $ sudo apt install python3-roslib python3-sensor-msgs python3-opencv outputs:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package python3-roslib
E: Unable to locate package python3-sensor-msgs

I'm relatively new to ubuntu, do I need to add to apt source list to install these? How do I do that?

Update Readme To Make the Features of the Package Explicit. ros2bag2video.py only works with compressed image stream

I am running Master branch with ros2 foxy, and trying to convert a color stream (image_raw) to mp4. Apparently this script only works for compressed images out of the box, you can modify the 'img = self.bridge.compressed_imgmsg_to_cv2(msg, self.msg_fmt)' to ' img = self.bridge.imgmsg_to_cv2(msg, self.msg_fmt)' in listner_callback function in the ros2bag2video.py executable. I further commented out the some code in the _playback_ros_bag function to make it compatible for non-compressed image stream, here is how it looks

 def _playback_ros_bag(self):
        print("Starting ROS bag playback...")
        process = subprocess.Popen(
            [
                "ros2",
                "bag",
                "play",
                self.bag_file,
                # "-r",
                # str(self.rate),
                # "--topics",
                # # HACK AJB Use this for SkateBot
                # # "/camera_node/image_raw/compressed",
                # # HACK AJB Use this for joeys.
                # "/je7c/camera/compressed",
            ]
        )
        return process
    P.S this will work for ros2 image_raw non compressed streams but it breaks the capability to set rate, and topic name by passing arguments to the script from cmd line. For my use case I was cool with the original fps and my bag had only one stream

Can't extract the video from the bag

  File "./rosbag2video.py", line 136, in <module>
    p_avconv[topic] = subprocess.Popen(['avconv','-r',str(opt_fps),'-an','-c','mjpeg','-f','mjpeg','-i','-',out_file],stdin=subprocess.PIPE)
  File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

Can you help me to fix it?
Thanks

Ros2 Humble is installed on the Ubuntu 22.04 but I get error for no module named rclpy._rclpy_pybind11 while the package is installed

Can you guide me what's wrong?
Ros2 humble is installed and I was able to see my capture in rviz2

(base) mona@ada:~/rosbag2video$ tail -5 ~/.bashrc
export PATH=$PATH:/home/mona/Downloads/blender-2.79a-linux-glibc219-x86_64/2.79/python/bin
alias gpustat='watch -n 0.5 -c gpustat -cp --color'
source /opt/ros/humble/setup.bash
source ~/realsense-ros/install/setup.bash
. "$HOME/.cargo/env"
(base) mona@ada:~/rosbag2video$ source ~/.bashrc
(base) mona@ada:~/rosbag2video$ python ros2bag2video.py ~/Downloads/cheezit_1280_whole.bag 
Traceback (most recent call last):
  File "/home/mona/rosbag2video/ros2bag2video.py", line 21, in <module>
    import rclpy
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/__init__.py", line 49, in <module>
    from rclpy.signals import install_signal_handlers
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/signals.py", line 15, in <module>
    from rclpy.exceptions import InvalidHandle
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/exceptions.py", line 15, in <module>
    from rclpy.impl.implementation_singleton import rclpy_implementation as _rclpy
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/impl/implementation_singleton.py", line 32, in <module>
    rclpy_implementation = import_c_library('._rclpy_pybind11', package)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/ros/humble/lib/python3.10/site-packages/rpyutils/import_c_library.py", line 39, in import_c_library
    return importlib.import_module(name, package=package)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mona/anaconda3/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'rclpy._rclpy_pybind11'
The C extension '/opt/ros/humble/lib/python3.10/site-packages/_rclpy_pybind11.cpython-311-x86_64-linux-gnu.so' isn't present on the system. Please refer to 'https://docs.ros.org/en/humble/Guides/Installation-Troubleshooting.html#import-failing-without-library-present-on-the-system' for possible solutions
(base) mona@ada:~$ uname -a
Linux ada 6.2.0-35-generic #35~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Oct  6 10:23:26 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
(base) mona@ada:~$ lsb_release -a
LSB Version:	core-11.1.0ubuntu4-noarch:security-11.1.0ubuntu4-noarch
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.3 LTS
Release:	22.04
Codename:	jammy

(base) mona@ada:~$ gcc --version
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

(base) mona@ada:~$ python --version
Python 3.11.5

(base) mona@ada:~/rosbag2video$ git log
commit 13b4e064eb0ad748f3d4e20eb88353bdf76acd21 (HEAD -> master, origin/master, origin/HEAD)
Merge: 44d1637 14a7d26
Author: mlaiacker <[email protected]>
Date:   Mon Sep 18 20:11:28 2023 +0200

    Merge branch 'pipebots-humble-dev-joey'

and

$ printenv | grep -i ros
ROS_VERSION=2
ROS_PYTHON_VERSION=3
PWD=/home/mona/rosbag2video
AMENT_PREFIX_PATH=/home/mona/realsense-ros/install/realsense2_description:/home/mona/realsense-ros/install/realsense2_camera:/home/mona/realsense-ros/install/realsense2_camera_msgs:/opt/ros/humble
CMAKE_PREFIX_PATH=/home/mona/realsense-ros/install/realsense2_description:/home/mona/realsense-ros/install/realsense2_camera:/home/mona/realsense-ros/install/realsense2_camera_msgs
COLCON_PREFIX_PATH=/home/mona/realsense-ros/install
PYTHONPATH=/home/mona/realsense-ros/install/realsense2_camera_msgs/local/lib/python3.10/dist-packages:/opt/ros/humble/lib/python3.10/site-packages:/opt/ros/humble/local/lib/python3.10/dist-packages
LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64:/usr/local/cuda-11.8/lib64:/usr/local/cuda-11.8/lib64:/home/mona/realsense-ros/install/realsense2_camera/lib:/home/mona/realsense-ros/install/realsense2_camera_msgs/lib:/opt/ros/humble/opt/rviz_ogre_vendor/lib:/opt/ros/humble/lib/x86_64-linux-gnu:/opt/ros/humble/lib:/usr/local/cuda-11.8/lib64::/home/mona/Downloads/blender-2.79a-linux-glibc219-x86_64/2.79/python/lib:/home/mona/Downloads/blender-2.79a-linux-glibc219-x86_64/2.79/python/lib:/home/mona/Downloads/blender-2.79a-linux-glibc219-x86_64/2.79/python/lib:/home/mona/Downloads/blender-2.79a-linux-glibc219-x86_64/2.79/python/lib
ROS_LOCALHOST_ONLY=0
PATH=/usr/local/cuda-11.8/bin:/usr/local/cuda-11.8/bin:/usr/local/cuda-11.8/bin:/opt/ros/humble/bin:/usr/local/cuda-11.8/bin:/home/mona/anaconda3/bin:/home/mona/anaconda3/condabin:/home/mona/.nvm/versions/node/v18.18.0/bin:/home/mona/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/mona/Downloads/blender-2.79a-linux-glibc219-x86_64/2.79/python/bin:/home/mona/Downloads/blender-2.79a-linux-glibc219-x86_64/2.79/python/bin:/home/mona/Downloads/blender-2.79a-linux-glibc219-x86_64/2.79/python/bin:/home/mona/Downloads/blender-2.79a-linux-glibc219-x86_64/2.79/python/bin
ROS_DISTRO=humble

$ apt list | grep humble-rcl-action 

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

ros-humble-rcl-action-dbgsym/jammy 5.3.5-1jammy.20230919.213203 amd64
ros-humble-rcl-action/jammy,now 5.3.5-1jammy.20230919.213203 amd64 [installed,automatic]

$ file /opt/ros/humble/lib/librcl_action.so
/opt/ros/humble/lib/librcl_action.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=5d7ff8461bfa2e680cba23319961468f445959d7, stripped
$ ldd /opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/_rclpy_pybind11.cpython-310-x86_64-linux-gnu.so
	linux-vdso.so.1 (0x00007fffbe3e0000)
	librcl_action.so => /opt/ros/humble/lib/librcl_action.so (0x00007f787c8d4000)
	librcl_lifecycle.so => /opt/ros/humble/lib/librcl_lifecycle.so (0x00007f787c8ca000)
	libpython3.10.so.1.0 => /lib/x86_64-linux-gnu/libpython3.10.so.1.0 (0x00007f787c200000)
	librcl.so => /opt/ros/humble/lib/librcl.so (0x00007f787c860000)
	librcl_yaml_param_parser.so => /opt/ros/humble/lib/librcl_yaml_param_parser.so (0x00007f787c854000)
	librmw_implementation.so => /opt/ros/humble/lib/librmw_implementation.so (0x00007f787c847000)
	librcl_logging_interface.so => /opt/ros/humble/lib/librcl_logging_interface.so (0x00007f787c842000)
	librmw.so => /opt/ros/humble/lib/librmw.so (0x00007f787c836000)
	liblifecycle_msgs__rosidl_typesupport_c.so => /opt/ros/humble/lib/liblifecycle_msgs__rosidl_typesupport_c.so (0x00007f787c82f000)
	librcutils.so => /opt/ros/humble/lib/librcutils.so (0x00007f787c817000)
	libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f787be00000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f787c7f5000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f787ba00000)
	libtracetools.so => /opt/ros/humble/lib/libtracetools.so (0x00007f787c7f0000)
	liblifecycle_msgs__rosidl_generator_c.so => /opt/ros/humble/lib/liblifecycle_msgs__rosidl_generator_c.so (0x00007f787c7e0000)
	librosidl_runtime_c.so => /opt/ros/humble/lib/librosidl_runtime_c.so (0x00007f787c1f5000)
	libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f787c1c4000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f787c1a8000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f787c0c1000)
	librcl_logging_spdlog.so => /opt/ros/humble/lib/librcl_logging_spdlog.so (0x00007f787c7d7000)
	librcl_interfaces__rosidl_typesupport_c.so => /opt/ros/humble/lib/librcl_interfaces__rosidl_typesupport_c.so (0x00007f787c0b8000)
	librcl_interfaces__rosidl_generator_c.so => /opt/ros/humble/lib/librcl_interfaces__rosidl_generator_c.so (0x00007f787c09c000)
	libyaml.so => /opt/ros/humble/lib/libyaml.so (0x00007f787c078000)
	libament_index_cpp.so => /opt/ros/humble/lib/libament_index_cpp.so (0x00007f787c06d000)
	librcpputils.so => /opt/ros/humble/lib/librcpputils.so (0x00007f787c05f000)
	librosidl_typesupport_c.so => /opt/ros/humble/lib/librosidl_typesupport_c.so (0x00007f787c059000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f787c9cb000)
	libspdlog.so.1 => /lib/x86_64-linux-gnu/libspdlog.so.1 (0x00007f787bd85000)
	libbuiltin_interfaces__rosidl_generator_c.so => /opt/ros/humble/lib/libbuiltin_interfaces__rosidl_generator_c.so (0x00007f787c052000)
	libfmt.so.8 => /lib/x86_64-linux-gnu/libfmt.so.8 (0x00007f787c031000)

I Can't extract the video from bag file

Hello I did the command
./rosbag2video.py -r 50 -o test.mp4 MYBAG.bag
It returns

using  50.0  FPS
############# USING ######################
camera/rgb/image_raw  with datatype: sensor_msgs/Image
############# USING ######################
camera/depth_registered/image_raw  with datatype: sensor_msgs/Image
unsuportet encoding: bayer_grbg8

How Can I Fix this problem?

Code correction suggestion !!

               #write_output_video(msg, topic, t, MJPEG_VIDEO)
Line 207 write_output_video(msg, topic, t, cv_image, MJPEG_VIDEO)

unsuportet encoding: 8UC1

Hello,thanks for your great work.
I'm writing to ask a question.
I have followed your steps, and the final result is:

preproc_tf.bag
using 25.0 FPS
############# USING ######################
/rect_color_raw with datatype: sensor_msgs/Image
############# USING ######################
/cnn_label with datatype: sensor_msgs/Image
unsuportet encoding: 8UC1

It seems there are something wrong with the pictures' format.
Have you meet this problem before? and do you have any ideas?

Port to ROS2

Hi @mlaiacker, thank you for providing this convenient tool. It has been helpful in converting ROS1 bags to .mp4 videos. 😄 👍

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.