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'

解决办法:
将'M', 'P', '4', 'V'改成小写即可

fourcc = cv2.VideoWriter_fourcc(*'mp4v')  # MPEG-4编码 .mp4 可指定结果视频的大小
fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v') 

https://blog.csdn.net/weixin_44641176/article/details/121758262

cv2.VideoWriter_fourcc('M', 'P', '4', 'V')   MPEG-4编码 .mp4 可指定结果视频的大小
cv2.VideoWriter_fourcc('X','2','6','4')      MPEG-4编码 .mp4 可指定结果视频的大小
cv2.VideoWriter_fourcc('I', '4', '2', '0')      该参数是YUV编码类型,文件名后缀为.avi 广泛兼容,但会产生大文件
cv2.VideoWriter_fourcc('P', 'I', 'M', 'I')       该参数是MPEG-1编码类型,文件名后缀为.avi
cv2.VideoWriter_fourcc('X', 'V', 'I', 'D')      该参数是MPEG-4编码类型,文件名后缀为.avi,可指定结果视频的大小
cv2.VideoWriter_fourcc('T', 'H', 'E', 'O')      该参数是Ogg Vorbis,文件名后缀为.ogv
cv2.VideoWriter_fourcc('F', 'L', 'V', '1')      该参数是Flash视频,文件名后缀为.flv

https://blog.csdn.net/weixin_43869605/article/details/119826406

import cv2
import numpy as np

cap = cv2.VideoCapture(0)
# Define the codec and create VideoWriter object
fourcc = cv2.cv.FOURCC(*'XVID')
out = cv2.VideoWriter('output.avi', fourcc, 20, (640, 480))

while(1):
    # get a frame
    ret, frame = cap.read()
    # save a frame
    out.write(frame)
    # show a frame
    cv2.imshow("capture", frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
cap.release()
out.release()
cv2.destroyAllWindows() 

https://blog.csdn.net/huanglu_thu13/article/details/52337234

你可能感兴趣的:(OpenCV: FFMPEG: tag 0x5634504d/'MP4V' is not supported with codec id 12 and format 'mp4 / MP4 (MP...)