fourcc = cv2.cv.CV_FOURCC(*'XVID')
The above line is used for avi video. In the same fashion, which codec do we use for mp4 videos in Ubuntu?
fourcc = cv2.cv.CV_FOURCC(*'XVID')
The above line is used for avi video. In the same fashion, which codec do we use for mp4 videos in Ubuntu?
The codec is H.264.
One of these should work for you:
However, I should warn you that you'll probably need to have
ffmpeg
and thex264
libraries installed so since you are in Ubuntu, try doing this command in the terminal:Also, check out this link from OpenCV tutorials for more details as to the kinds of FourCC codes available for your platform: http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_gui/py_video_display/py_video_display.html#saving-a-video
In the above link, it says
X264
is the FourCC code you should use, but switch between them until you get it to work.This is an old question. But, if anyone is facing an issue lately using the codec who can't get a saved video. They can use
0X00000021
as the codec value for OpenCV 3 and later.