Ask Your Question
0

Video not recording. No errors

asked 2014-12-26 11:53:18 -0600

badwolf1210 gravatar image

Hi! I am new in this forum and also pretty new with opencv. I am trying to make some image processing codes, and I found a problem when trying to record video from my webcam. My code is supposed to display the webcam and record the images in a file. When I run it I don't get any errors, and the webcam is displayed correctly, but no file is created.

This is the minimum code:

import cv2
cap = cv2.VideoCapture(0)
## Define the codec and create VideoWriter object
fourcc = cv2.cv.CV_FOURCC(*'XVID')
out_writer = cv2.VideoWriter('output.avi',fourcc, 25, (640,480),isColor=True)
a = True
while a:
    a, frame = cap.read()
    out_writer.write(frame)
    cv2.imshow('Video',frame)
    # Break if <Esc> key
    k = cv2.waitKey(5) & 0xFF
    if k == 27:
      a = False
## Release everything if job is finished
cap.release()
out_writer.release()
cv2.destroyAllWindows()

When I run it I only get:

$ python save_video.py 
init done 
opengl support available

And no "output.avi" file is created.

Any idea of what I am doing wrong??!! Thanks for any help you can give me!!

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2014-12-30 13:54:56 -0600

badwolf1210 gravatar image

updated 2015-01-07 05:45:38 -0600

[SOLVED]

Apparently I made some mistake in the installation or something. This problem was solved by using this script to (re-)install OpenCV:

https://github.com/jayrambhia/Install...

I guess I had some dependencies missing or something (even though I got no errors when installing). Anyway, thank you very much for the help!

edit flag offensive delete link more
0

answered 2014-12-26 21:54:16 -0600

Haris gravatar image

Possible reasons,

1.Codec problem.
-> Try with other codec.

2.Image resolution.
-> If the camera not giving the frame of 640x480 resolution that may create the problem.
-> So either resize the image to 640X480 or use VideoCapture::get() to get the frame width, height and initialize VideoWriter with it.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-12-26 11:53:18 -0600

Seen: 1,299 times

Last updated: Jan 07 '15