rosbag2video icon indicating copy to clipboard operation
rosbag2video copied to clipboard

Object has no attribute 'format'

Open reem90 opened this issue 3 years ago • 4 comments

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? 


reem90 avatar May 02 '21 05:05 reem90

Encountered same problem, but I found it can run only when you did not specify any parameter.

python rosbag2video.py yourfile.bag 

vinesmsuic avatar Jun 01 '21 08:06 vinesmsuic

Hi! I had also faced this problem. Would you please tell me what should I do to solve this?

Zoey-946 avatar Jun 28 '22 04:06 Zoey-946

Try deleting the existing output file that was created. Must be naive to solve.

Pallav1299 avatar Sep 30 '22 10:09 Pallav1299

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.

ZhangZixuan97 avatar Jan 16 '23 13:01 ZhangZixuan97

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]

DrChungAlbert avatar Jun 13 '24 08:06 DrChungAlbert