Open reem90 opened 3 years ago
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]
Was able to reproduce this faulty behaviour.
This is typically caused by the fact that a file of the same name ffmpeg is writing to exist. When attempting to overwite the existing output video file, it will result in the following error captured in this thread:
BrokenPipeError: [Errno 32] Broken pipe
The error AttributeError: '_sensor_msgs__Image' object has no attribute 'format
is a red herring, meaning that it has already been handled appropriately in function addBag
. The core error lies with the former.
Just remove the output video file with the same name in the directory you are running rosbag2video.py
in.
If unsure which video is it, please remove all video files in the directory in question.
Will write up a Pull Request with a modification to generate timestamped output video file name by default to generate uniquely-named output video file.
Will update here once done.
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: