title: OpenCV VideoCapture too slow
body: <p>I'm developping since a year a software that process video stream from an IP camera. This software displays the video in real-time and can also record it, do some video processing, etc.
  The IP camera can stream MJPEG or H264 video via RTSP. The video size is 768x576 at 25fps.
  My problem is when I use H264 stream, the grab method is far too slow, taking beetween 30 to 60 msec. My program doesn't only grab frames, so if the grab method takes 50ms, I cannot handle the 25fps of the video. What I don't understand is that I have a quite powerfull computer DualCore @3Ghz.
  Is there any way to quick grab frame with OpenCv ?</p>
  
  <p>Here's a part of my code ( using Qt + home built OpenCv 2.4.1 MinGw ) :</p>
  
  <p>Start capture :</p>
  
  <pre><code>videoCapture.open(fileName.toStdString());
  queryFrameTimer-&gt;start(20);
  connect(queryFrameTimer,SIGNAL(timeout()),this,SLOT(queryFrame()));
  </code></pre>
  
  <p>The queryFrame method</p>
  
  <pre><code>void VideoStreamer::queryFrame()
  {
      qDebug() &lt;&lt; QTime::currentTime().toString("mm:ss:zzz") &lt;&lt; "queryFrame start";
      QTime elapsedTimer;
      elapsedTimer.start();    
      Mat frame;
      videoCapture &gt;&gt; frame;
      qDebug()  &lt;&lt;" VideoStreamer::queryFrame " + QString::number(elapsedTimer.elapsed());
      [...]
  }
  </code></pre>
  
  <p>The debug output</p>
  
  <pre><code>"41:07:366" queryFrame start 
  " VideoStreamer::queryFrame 44 ms" 
  "41:07:429" queryFrame start 
  " VideoStreamer::queryFrame 35 ms" 
  "41:07:493" queryFrame start 
  " VideoStreamer::queryFrame 37 ms" 
  "41:07:556" queryFrame start 
  " VideoStreamer::queryFrame 28 ms" 
  "41:07:595" queryFrame start 
  " VideoStreamer::queryFrame 38 ms" 
  "41:07:648" queryFrame start 
  " VideoStreamer::queryFrame 42 ms" 
  "41:07:710" queryFrame start 
  " VideoStreamer::queryFrame 34 ms" 
  "41:07:772" queryFrame start 
  " VideoStreamer::queryFrame 38 ms" 
  "41:07:835" queryFrame start 
  " VideoStreamer::queryFrame 28 ms" 
  "41:07:866" queryFrame start 
  " VideoStreamer::queryFrame 56 ms" 
  "41:07:959" queryFrame start 
  " VideoStreamer::queryFrame 25 ms" 
  "41:07:990" queryFrame start 
  " VideoStreamer::queryFrame 60 ms" 
  "41:08:053" queryFrame start 
  " VideoStreamer::queryFrame 35 ms" 
  "41:08:115" queryFrame start 
  " VideoStreamer::queryFrame 27 ms" 
  "41:08:147" queryFrame start 
  " VideoStreamer::queryFrame 64 ms" 
  "41:08:241" queryFrame start 
  " VideoStreamer::queryFrame 24 ms" 
  "41:08:275" queryFrame start 
  " VideoStreamer::queryFrame 56 ms" 
  "41:08:335" queryFrame start 
  " VideoStreamer::queryFrame 50 ms" 
  </code></pre>