rosbag2video
rosbag2video copied to clipboard
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?
Encountered same problem, but I found it can run only when you did not specify any parameter.
python rosbag2video.py yourfile.bag
Hi! I had also faced this problem. Would you please tell me what should I do to solve this?
Try deleting the existing output file that was created. Must be naive to solve.
I made some attempts and found that it has strict requirements on the format of the command.
As written in -h:
rosbag2video.py [--fps 25] [--rate 1] [-o outputfile] [-v] [-s] [-t topic] bagfile1 [bagfile2] ...
It seems that the parameter needs to be entered before the bagfile name.
Work like: python rosbag2video.py -t /usb_cam/image_raw mybag.bag
Parameters don't work: python rosbag2video.py mybag.bag -t /usb_cam/image_raw
In addition, there cannot already be an MP4 file with the same name in the folder.
I think this cmd can solve the broken pipe issue
if video_fmt == MJPEG_VIDEO: cmd = [VIDEO_CONVERTER_TO_USE, '-y', '-v', '1', '-stats', '-r', str(self.fps), '-c', 'mjpeg', '-f', 'mjpeg', '-i', '-', '-an', out_file] elif video_fmt == RAWIMAGE_VIDEO: size = str(msg.width) + "x" + str(msg.height) cmd = [VIDEO_CONVERTER_TO_USE, '-y', '-v', '1', '-stats', '-r', str(self.fps), '-f', 'rawvideo', '-s', size, '-pix_fmt', pix_fmt, '-i', '-', '-an', out_file]