Ask Your Question
0

Video Not Saving - Python Binding OpenCV

asked 2015-01-14 17:16:23 -0600

underscore gravatar image

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,

edit retag flag offensive close merge delete

Comments

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.

alejandrovalenciaw gravatar imagealejandrovalenciaw ( 2015-04-27 03:14:30 -0600 )edit

2 answers

Sort by » oldest newest most voted
0

answered 2017-01-23 15:49:36 -0600

I had a problem in the resolution of the image. Try to change the size to the default size for your camera.

edit flag offensive delete link more
0

answered 2015-05-28 21:25:45 -0600

zzdts gravatar image

I have the same problem too ...

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-01-14 17:16:23 -0600

Seen: 1,837 times

Last updated: Jan 14 '15