title: OpenCV videowriter H264 codec (ffmpeg)
body: <p>I want to save a video with opencv with lossless compresion so I don't lose any details of the frames. Everything works with the xvid codec but offcourse this is not a lossless compression so I found that the x264 codec is suitable. However it doesn't work, I tried the following sample code but while running I get the following error: "could not find encoder for codec id 28: encoder not found."</p>
  
  <pre><code>cv::VideoWriter makeVideo;
  makeVideo.open("makevideo//newVideo.mp4", CV_FOURCC('X','2','6','4'), 30, cv::Size(1600,1200), true);
  cv::Mat image = imread("makevideo//frames//111.png");
  
  for(int i = 0; i &lt; 200; i++)
      makeVideo &lt;&lt; image;
  
  makeVideo.release();
  </code></pre>
  
  <p>I found that for this to work, I need to have ffmpeg support. I'm currently using opencv2.4.6 and in this discussion (<a href="https://stackoverflow.com/questions/9387392/how-can-i-use-the-opencv-ffmpeg-video-i-o-rather-than-the-directshow-one-in-wind">how can I use the openCV FFMPEG video I/O rather than the DirectShow one in Windows?</a>) someone mentioned that in opencv2.4 ffmpeg is automatically included. But its not working....</p>
  
  <p>Here (<a href="https://stackoverflow.com/questions/7075180/how-to-compile-opencv-2-3-with-ffmpeg-support-with-visual-studio-2010">How to compile OpenCV 2.3 with ffmpeg support with Visual Studio 2010</a>) I found how to compile opencv and ffmpeg yourself on windows. I followed all the steps sucessfully but still I get the same error....</p>