You can also use mp4v
fourcc = cv2.cv.CV_FOURCC(*'mp4v')
where the video memory should look like this:
out = cv2.VideoWriter('output.mp4',fourcc, 15, size)
But for mp4 more codecs are available. You can see their list by setting fourcc = -1 , it will show a list like this:
OpenCV: FFMPEG: format mp4 / MP4 (MPEG-4 Part 14) fourcc tag 0x7634706d/'mp4v' codec_id 000C fourcc tag 0x31637661/'avc1' codec_id 001B fourcc tag 0x33637661/'avc3' codec_id 001B fourcc tag 0x31766568/'hev1' codec_id 00AD fourcc tag 0x31637668/'hvc1' codec_id 00AD fourcc tag 0x7634706d/'mp4v' codec_id 0002 fourcc tag 0x7634706d/'mp4v' codec_id 0001 fourcc tag 0x7634706d/'mp4v' codec_id 0007 fourcc tag 0x7634706d/'mp4v' codec_id 003D ....
They all support mp4, but h264 supported by web browsers if you want to post videos on the Internet.
source share