Video codec for H264 with opencv

mans picture mans · Jun 10, 2013 · Viewed 19.5k times · Source

I am trying to create a movie using opencv and I need that output file be in H264 format.

I used the following fourcc in opencv, but I am getting error that suitable codec is not installed.

fourcc=CV_FOURCC('H','2','6','4') ;

When I run my application I get the following error message:

Could not find encoder for codec id 28: Encoder not found

What do I need to be able to use this codec in OpenCV?

Answer

kamjagin picture kamjagin · Jun 26, 2013

H264 is not a codec, but rather a standard, while for example x264 is an encoder that implements the H264 standard (CV_FOURCC('X','2','6','4') ;).

OpenCV can write videos using FFMPEG or VFW. You need to compile FFPMEG with x264-support (instructions can be found on FFMPEG's website)

If you are using VFW: Take a look at http://sourceforge.net/projects/x264vfw/