After installed opencv like on Mac OS 10.13.6:
conda install -c conda-forge ffmpeg
conda install -c conda-forge opencv
And using fourcc = cv2.VideoWriter_fourcc('h', '2', '6', '4')
in videowriter
I get error:
OpenCV: FFMPEG: tag 0x34363268/'h264' is not supported with codec id 27 and format 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x31637661/'avc1'
How to fix it?
The codecs are platform dependent, that could be the problem. Try using this combination:
test.mkv
CV_FOURCC(*'X264)
Here is the reference link
You should change:
fourcc = cv2.VideoWriter_fourcc('h', '2', '6', '4')
to:
fourcc = cv2.VideoWriter_fourcc(*'avc1')
FourCC is a 4-byte code used to specify the video codec. The list of available codes can be found in fourcc.org. It is platform dependent. The following codecs work fine for me.
First like some answers pointed out, we should use "AVC1" instead of "h264". Secondly, when we are using opencv-python, there are some licence issues : https://github.com/opencv/opencv-python/issues/207 , we may need to compile on our own.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.