OpenCV: How to get list of available codecs?

Viewed 3622

How to get list of codecs available on current system, i.e. as I understand cv2.VideoWriter can fail when codec is not available. What codec is used by default?

Not sure if it's for all cases, but seems opencv fallback to mp4v codec as default with message: OpenCV: FFMPEG: fallback to use tag 0x7634706d/'mp4v'

Also to add new codecs do we need to rebuild opencv or we can just install additional codecs \ update ffmpeg via something like apt get?

1 Answers

Here is the list of video codecs by FOURCC. You can get the char format there which you needed.

As the documentation says:

The constructors/functions initialize video writers. On Linux FFMPEG is used to write videos; on Windows FFMPEG or VFW is used; on MacOSX QTKit is used.

OpenCV uses FFMPEG supports(for linux in your case) to writes the videos so as @Mark Setchell mentioned on comment you can get the ffmpeg supported codec formats by the command:

ffmpeg -codecs
Related