Reputation: 21632
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?
Upvotes: 9
Views: 37799
Reputation: 6632
You should change:
fourcc = cv2.VideoWriter_fourcc('h', '2', '6', '4')
to:
fourcc = cv2.VideoWriter_fourcc(*'avc1')
Upvotes: 4
Reputation: 1011
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.
Upvotes: 2
Reputation: 75
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.
Upvotes: 1
Reputation: 673
The codecs are platform dependent, that could be the problem. Try using this combination:
test.mkv
CV_FOURCC(*'X264)
Here is the reference link
Upvotes: 4