Video Not Saving - Python Binding OpenCV
I am following along with this tutorial: http://docs.opencv.org/trunk/doc/py_t...
The program starts and activates the webcam but it does not write anything to disk. The file is created but the size is 0KB.
I receive the following error when trying to play the video: "Windows Media Player cannot play the file. The Player might not support the file type or might not support the codec that was used to compress the file."
My source-code is below:
import numpy as np
import cv2
cap = cv2.VideoCapture(0)
#Define the codec and create VideoWriter object
fourcc = cv2.cv.CV_FOURCC('D', 'I', 'V', 'X')
out = cv2.VideoWriter('output.AVI', fourcc, 20.0, (640,480), 1)
while(cap.isOpened()):
ret, frame = cap.read()
if ret == True:
frame = cv2.flip(frame,0)
#write the flipped frame
out.write(frame)
cv2.imshow('frame', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
else:
break
#Release everything if job is finished
cap.release()
#out.release()
cv2.destroyAllWindows()
Why are the frames not written to disk?
Regards,
Hi, I have the same problem use Phython 2.7.9 and version 2.7.9 CV2.py, can capture video but not saved. out.write (frame) seems to not work. CAN SOMEONE PLEASE HELP. SPANISH Hola, yo tengo el mismo problema uso Phython 2.7.9 y la versión de CV2.py 2.7.9, puedo capturar video pero no guarda. out.write(frame) parece que no funciona. POR FAVOR ALGUIEN PUEDE AYUDARNOS.