我有这样的代码:Python和OpenCV的 - 不能写可读的AVI视频文件
import numpy as np
import cv2
cap = cv2.VideoCapture('C:/Users/Hilman/haatsu/drive_recorder/sample/3.mov')
# Define the codec and create VideoWriter object
fourcc = cv2.VideoWriter_fourcc(*'XVID')
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
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()
但output.avi
无法播放。
也尝试将out = cv2.VideoWriter('output.avi', fourcc, 20.0, (640,480))
更改为像这样的东西(如有人建议)out = cv2.VideoWriter('output.avi', -1, 20.0, (640,480))
。但是当我这样做时,我收到了这条消息
OpenCV: FFMPEG: tag 0xffffffff/' ' is not found (format 'avi/AVI (Audio Video Interleaved)')'
。
可能是什么问题?顺便说一句,我正在使用Windows 10。
OP正在使用Windows 10. –
是的,您确实在您的问题中提到过。我希望这可以在你的机器上工作,就像它在我的机器上一样。 –