赞
踩
- fourcc = cv2.VideoWriter_fourcc(*'MJPG/mjpg/mp4v/MP4V')
- vw = cv2.VideoWriter('out.mp4/avi', fourcc, 30, (1280,720))
报错:
OpenCV: FFMPEG: tag 0x47504a4d/'MJPG/mjpg/mp4v/MP4V/' is not supported with codec id 8/13 and format 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x7634706d/'mp4v'
其中fourcc = cv2.VideoWriter_fourcc(*'mjpg/mp4v')不会报错,但是视频录制出来只有1kb,打不开。
将代码修改为:
case1:
- fourcc = cv2.VideoWriter_fourcc(*'MJPG')
- vw = cv2.VideoWriter('out.mp4', fourcc, 30, (640,480))
报错:
OpenCV: FFMPEG: tag 0x47504a4d/'MJPG' is not supported with codec id 8 and format 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x7634706d/'mp4v'
现象:修改分辨率后有报错+视频能录制+部分播放器能打开
case2:
- fourcc = cv2.VideoWriter_fourcc(*'MP4V')
- vw = cv2.VideoWriter('out.mp4', fourcc, 30, (640,480))
报错:
OpenCV: FFMPEG: tag 0x5634504d/'MP4V' is not supported with codec id 13 and format 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x7634706d/'mp4v'、
现象:修改分辨率后有报错+视频能录制+视频能打开
case3:
- fourcc = cv2.VideoWriter_fourcc(*'mjpg/mp4v')
- vw = cv2.VideoWriter('out.mp4', fourcc, 30, (640,480))
报错:
OpenCV: FFMPEG: tag 0x67706a6d/'mjpg' is not supported with codec id 8 and format 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x7634706d/'mp4v'
现象:修改分辨率后有报错+视频能录制+部分播放器能打开
case4:
- fourcc = cv2.VideoWriter_fourcc(*'mp4v')
- vw = cv2.VideoWriter('out.mp4', fourcc, 30, (640,480))
无报错:
现象:修改分辨率后无报错+视频能录制+播放器都能打开。
总结:
这个错误的重点是找到自己笔记本电脑摄像头输出图像的分辨率
(我被自带相机设置的分辨率误导了),我是从1080p、720p、360p试出来的!!!!!!!!!!
(如果对你有帮助,欢迎点赞支持)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。