List all supported codecs/fourcc tags on Raspberry Pi 4 using python, opencv


This is my code for recording videos on Raspberry Pi 4 running Raspbian Buster:

fourcc = cv2.VideoWriter_fourcc(*'MJPG')
writer = cv2.VideoWriter(tempVideo.path, fourcc, framerate, resolution, True)

However, no matter what codec I try, I keep getting errors like:

OpenCV: FFMPEG: tag 0x47504a4d/'MJPG' is not supported with codec id 7 and format 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x7634706d/'mp4v'

Setting fourcc = 1 also did not help. Here is what I see:

OpenCV: FFMPEG: tag 0xffffffff/'????' is not found (format 'mp4 / MP4 (MPEG-4 Part 14)'

Is there a way to list all the supported codecs and their tags?

asked on Stack Overflow Sep 17, 2019 by ddd

1 Answer


Here is the link with all fourcc codecs.

Some codecs don't exist there, but in your case, it is not an error it is just a fallback, so your code is running anyway and in the output you will get your mp4 file.

If you don't like how it looks just use this

fourcc = cv2.VideoWriter_fourcc(*'mp4v')


fourcc = 0x00000021
answered on Stack Overflow Nov 1, 2019 by Albert Badretdinov

User contributions licensed under CC BY-SA 3.0