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