fps = 24
width = int(cv.GetCaptureProperty(cap, cv.CV_CAP_PROP_FRAME_WIDTH))
height = int(cv.GetCaptureProperty(cap, cv.CV_CAP_PROP_FRAME_HEIGHT))
fourcc = cv.CV_FOURCC('I', '4', '2', '0')
writer = cv.CreateVideoWriter('out.avi', fourcc, fps, (width, height), 1)
for i in range(90):
    cv.GrabFrame(cap)
frame = cv.RetrieveFrame(cap)
cv.WriteFrame(writer, frame)
Writing video with OpenCV + Python + Mac