解决:OpenCV: FFMPEG: tag 0x5634504d/‘MP4V‘ is not supported with codec id 12 and format ‘mp4 / MP4 (MP

问题描述:

利用python 的opencv包把图片合并为视频(mp4格式)的时候发现错误。

OpenCV: FFMPEG: tag 0x5634504d/'MP4V' is not supported with codec id 12 and format 'mp4 / MP4 (MPEG-4 Part 14)'

OpenCV: FFMPEG: fallback to use tag 0x7634706d/'mp4v'

 原因,主要是合成时采用的视频编码不对,

还是使用的是

fourcc = cv2.VideoWriter_fourcc('M','J','P','G')

来生成mp4文件,发现生成的时候无法播放。这种格式需要视频格式为 avi。

为了支持mp4格式,改为如下即可

fourcc = cv2.VideoWriter_fourcc('M', 'P', '4', 'V') 

总的代码结构大致如下:

fourcc = cv2.VideoWriter_fourcc('M', 'P', '4', 'V') # mp4
img_size = (image_w, image_h)
videoWriter = cv2.VideoWriter(save_video_path, fourcc, fps, img_size, isColor=True)

for  image_path in xxx:
    image = cv2.imread(image_path)
    videoWriter.write(image)
videoWriter.release()

 

  • 20
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 13
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 13
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值