vc = cv2.VideoCapture('Test.avi') #讀入視頻文件
c=1
if vc.isOpened(): #判斷是否正常打開
rval , frame = vc.read()
else:
rval = False
timeF = 1000 #視頻幀計數間隔頻率
while rval: #循環讀取視頻幀
rval, frame = vc.read()
if(c%timeF == 0): #每隔timeF幀進行存儲操作
cv2.imwrite('image/'+str(c) + '.jpg',frame) #存儲為圖像
c = c + 1
cv2.waitKey(1)
vc.release()