mlaiacker / rosbag2video

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

Transfer Process Doesn't Move Further #21

Open wangzizhe opened 3 years ago

wangzizhe commented 3 years ago

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.

kenkainkane commented 2 years ago

I have the same problem

innovation-x commented 1 year ago

I have the same problem as well. Is this issue be solved now?

innovation-x commented 1 year ago

However, I run the ros2 bag2videos. It stuck like the figure below. image

wangzizhe commented 1 year ago

I don't think this problem has been solved... You'd better try other ways to transfer the files...

innovation-x commented 1 year ago

I see... Would you please share some methods for converting the rosbag .db3 files into .mp4 files?

wangzizhe commented 1 year ago

I remember I used this code at that time and it worked perfect! Just create a python file and copy paste these codes into that file and modify the codes according to your own camera settings.

#!/usr/bin/python3
​
# general stuff
import cv2
import numpy as np
import time
import copy
import os
import math
​
# ros stuff
import rospy
from sensor_msgs.msg import Image
from cv_bridge import CvBridge
​
from datetime import datetime
​
# is used to convert ROS message into OpenCV structure
bridge = CvBridge()
# opencv video write object
# camera resolution is 2064x1544
out = cv2.VideoWriter('test.avi',cv2.VideoWriter_fourcc('M','J','P','G'), 30, (2064,1544))
​
def cbImg(msg):
    global bridge, out
    cv_image = bridge.imgmsg_to_cv2(msg, desired_encoding="bgr8")
    # image is flipped
    out.write(cv2.flip(cv_image, -1))
​
​
def main():
    global out
​
    rospy.init_node('video_writer', anonymous=True)
​
    #change comments for different topics
    rospy.Subscriber("/ximea_cam_left/image_raw", Image, cbImg, queue_size=1)
    # rospy.Subscriber("/ximea_cam_right/image_raw", Image, cbImg, queue_size=1)
​
    # spin() simply keeps python from exiting until this node is stopped
    rate = rospy.Rate(10)
    while not rospy.is_shutdown():
        rate.sleep()
​
    # end video write
    out.release()
​
    rospy.spin()
​
if __name__ == '__main__':
    main()