当前位置:   article > 正文

opencv图像处理-错误记录1-视频录制不能保存_ffmpeg: tag 0x67706a6d/'mjpg' is not supported wit

ffmpeg: tag 0x67706a6d/'mjpg' is not supported with codec id 7 and format 'm
  1. fourcc = cv2.VideoWriter_fourcc(*'MJPG/mjpg/mp4v/MP4V')
  2. 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:

  1. fourcc = cv2.VideoWriter_fourcc(*'MJPG')
  2. 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:

  1. fourcc = cv2.VideoWriter_fourcc(*'MP4V')
  2. 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:

  1. fourcc = cv2.VideoWriter_fourcc(*'mjpg/mp4v')
  2. 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:

  1. fourcc = cv2.VideoWriter_fourcc(*'mp4v')
  2. vw = cv2.VideoWriter('out.mp4', fourcc, 30, (640,480))

无报错:

现象:修改分辨率后无报错+视频能录制+播放器都能打开。

总结:

这个错误的重点是找到自己笔记本电脑摄像头输出图像的分辨率

(我被自带相机设置的分辨率误导了),我是从1080p、720p、360p试出来的!!!!!!!!!!

(如果对你有帮助,欢迎点赞支持)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/484760
推荐阅读
相关标签
  

闽ICP备14008679号