I am following the OpenCV documentation on video saving using the following code.
import numpy as np
import cv2
cap = cv2.VideoCapture(0)
height = int(cap.get(4))
width = int(cap.get(3))
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('output.avi', fourcc, 20.0, (width, height))
while(cap.isOpened()):
ret, frame = cap.read()
if ret==True:
frame = cv2.flip(frame,0)
out.write(frame)
cv2.imshow('frame',frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
else:
break
cap.release()
out.release()
cv2.destroyAllWindows()
When I run it, it works fine but the video file saved can't be opened by VLC/quick time etc.
From openCV video saving in python i've noticed you can change fourcc to -1 allowing you to pick your codec if you are on a windows machine. But I can't do this on a Mac (OSX 10.11.12).
I have also tried a bunch of other fourcc options, but none seem to work on Mac.
Any suggestions?