我正在使用下面的代码,但是我得到了一个大小为0B的视频output.avi。如何设置/定义参数(视频的持续时间)以获得正确的输出?我打算使用获得的视频进行进一步处理。
import numpy as np
import cv2
cap = cv2.VideoCapture(0)
#Define the codec and create VideoWriter object
w=int(cap.get(cv2.cv.CV_CAP_PROP_FRAME_WIDTH ))
h=int(cap.get(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT ))
fourcc = cv2.cv.CV_FOURCC(*'DIVX')
out = cv2.VideoWriter('output.avi', fourcc, 25, (w,h))
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()