I am trying to record the Logitech Webcam video. The cam is able to record it but 40 sec video is recorded for only 6 seconds with some nX speed. I referred the following link for the solution but it couldn't solves the problem in RPi. The important thing is the code works find in Ubuntu desktop but may be RPi is slower to process.
Here is my code snippet:
fourcc = cv2.cv.CV_FOURCC(*'XVID')
videoOut = cv2.VideoWriter("video_clip.avi", fourcc, 20.0, (640, 480))
start_time = time.time()
frame_count = 0
while True:
ret, frame = cap.read()
videoOut.write(frame) # write each frame to make video clip
frame_count += 1
print int(time.time()-start_time) # print the seconds
if int(time.time()-start_time) == 10:
videoOut.release()
break
# get out of loop after 10 sec video
print 'frame count =', frame_count
# gives me 84 but expected is 20.0 * 10 = 200