Python VideoWriter on OSX only writes H264 video

asked 2017-01-12 15:31:59 -0500


I'm trying to create a video using cv2.VideoWriter object in the Python bindings of OpenCV. I've tried this with both OpenCV 2 and OpenCV 3, using homebrew to install. I'm running OSX 10.11, using Python 2.7.

My question is twofold, first, regardless of what FOURCC code I use, I cannot get the cv2.VideoWriter to create anything except H264 video. See below code snippet for an example, I've tried numerous code snippets, but ideally I'd like to create an uncompressed video (that I can compress later using something like FFMPEG).

video_code = cv2.VideoWriter_fourcc(*"raw ")

writer = cv2.VideoWriter('', video_code, frame_rate, (width, height))

Where width, height, frame_rate are variables set elsewhere, but sould work with 1920, 1080, 30. I'm guessing this issue is a limitation with QTKit? Is there a way to get this to work with a homebrew install that uses FFMPEG instead of QTKit?

My second question is, is it possible to create videos with NTSC framerates like 29.97 or 59.94? I've tried those values as inputs for the fps argument, but it seems to trim off the floating point frames, and output at 29 fps or 59 fps. Maybe using the right FOURCC code will help, but I can't get an output other than H264?

I can post more sample code if necessary, but I really just need the video writer to output the right codec, I'm probably missing something obvious!

edit retag flag offensive close merge delete