[英]Trying capture video to read frame by frame with OpenCV on MAC, but my “.avi” file has been encoded as mpeg4
我能够读取编码为mjpeg的avi文件,但不幸的是,编码情况为mpeg4时,我无法成功。 您的任何帮助都会对您有所帮助,我们将不胜感激。 这是我的代码段:
while(cap.isOpened()):
ret, frame = cap.read()
if ret:
frame=cv2.resize(frame(img_rows,img_cols),interpolation=cv2.INTER_AREA)
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
frames.append(gray)
cv2.imshow('frame',gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
为ubuntu / raspbian安装以下库sudo apt-get install ffmpeg
或者如果您是centos用户,则安装以下库sudo yum install ffmpeg
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.