title: OpenCV videoInput.h Capture speed different than write speed
body: <p>I am trying to write recording software that would write a video stream coming in the computer to an avi file. I am using OpenCV and accompanied videoInput.h to handle the directshow code. Just in case it matters I am using Visual Studio 2010 as a compiler.</p>
  
  <p>The problem I am having is the recorded file plays faster than the previewed file. Not by alot, but just enough to be noticable. EXAMPLE: 10 second preview is roughly 7 second file so everyone moves just a little bit too fast.</p>
  
  <pre><code>if( bWriteVideo )
  {
      writer=cvCreateVideoWriter(szFileName,CV_FOURCC('D','I','V','X'),
                                  fps,cvSize(width, height),isColor);
      if( !writer ) return 1;
  }
  
  if( bDisplayVideo )
      cvNamedWindow("video", 0);
  
  while( key != 'q')
  {
      if(VI.isFrameNew(nSource))
      {
          VI.getPixels(nSource, yourBuffer1, false, true);
  
          frame = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3);
          frame-&gt;imageData = (char*)yourBuffer1;
          frame-&gt;imageDataOrigin = frame-&gt;imageData;
  
          if( !frame ) break;
  
          // Display Image to Screen
          if( bDisplayVideo )
              cvShowImage( "video" , frame );
  
          if( bWriteVideo )
              cvWriteFrame( writer, frame );      
      }   
          key = cvWaitKey ( 1000 / fps );     
  }
  </code></pre>