title: OpenCV VideoWriter Framerate Issue
body: <p>I'm attempting to record video from a 1080p webcam into a file. I held a timer up in the video and in every trial the timestamp reported by a video player (VLC is what I used) doesn't sync up with the time in the video. It's always off a few seconds (usually in-video timer is faster than player-reported time).</p>
  
  <p>As seen below, I set up the C++ program to capture video in one thread, and record in another thread. This is working fine as my CPU usage is ~200% (possible max out?). I'm on a Macbook Air w/ OS X 10.8 @ 1.8 GHz Intel Core i7.</p>
  
  <p>I've tried changing the framerate to 15fps and that results in very choppy/slow video. I've also tried setting <code>CV_CAP_PROP_FRAME_WIDTH</code> &amp; <code>CV_CAP_PROP_FRAME_HEIGHT</code> to a lower resolution and it results in slow video. It appears that 1080p @ 30fps results in good steady video, but it is still always plays faster than it's supposed to. I've also tried putting in <code>waitKey(10);</code> after <code>record &lt;&lt; frame;</code> but it did not affect anything.</p>
  
  <p>Any recommendations on how to make the video match up in time?</p>
  
  <p>Thanks!
  Aakash</p>
  
  <pre><code>#include "opencv/cv.h"
  #include "opencv/highgui.h"
  #include &lt;boost/thread.hpp&gt;
  
  using namespace cv;
  
  void captureFunc(Mat *frame, VideoCapture *capture){
      for(;;){
          // get a new frame from camera
          (*capture) &gt;&gt; (*frame);
      }
  }
  
  int main(int, char**)
  {
      VideoCapture capture(0); // open the default camera
      if( !capture.isOpened() )  {
          printf("Camera failed to open!\n");
          return -1;
      }
  
      capture.set(CV_CAP_PROP_FPS,30); //set capture rate to 30fps
      Mat frame;
      capture &gt;&gt; frame; // get first frame for size
  
      // initialize recording of video
      VideoWriter record("test.avi", CV_FOURCC('D','I','V','X'), 30, frame.size(), true);
      if( !record.isOpened() ) {
          printf("VideoWriter failed to open!\n");
          return -1;
      }
  
      boost::thread captureThread(captureFunc, &amp;frame, &amp;capture); //start capture thread
  
      sleep(1); //just to make sure capture thread is ready
  
      for(;;)
      {
          // add frame to recorded video
          record &lt;&lt; frame;
      }
  
      return 0;
  }
  </code></pre>