0
我編譯了此代碼,它以灰色格式保存從網絡攝像頭捕獲的視頻。視頻最後得到保存,但未保存在任何視頻播放器上播放。請幫助..錯誤:視頻格式不支持,在嘗試對捕獲的幀執行操作時發生並保存視頻
import numpy as np
import cv2
cap = cv2.VideoCapture(0)
# Define the codec and create VideoWriter object
fourcc = cv2.VideoWriter_fourcc(*'DIVX')
out = cv2.VideoWriter('output.avi',fourcc, 20.0, (640,480))
while(cap.isOpened()):
ret, frame = cap.read()
if ret==True:
frame = cv2.flip(frame,0)
# write the flipped frame
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
out.write(gray)
cv2.imshow('frame',gray)
if cv2.waitKey(20) & 0xFF == ord('q'):
break
else:
break
# Release everything if job is finished
cap.release()
out.release()
cv2.destroyAllWindows()
我非常感謝您的支持...... –
如果解決了您的問題,請接受答案 –