title: OpenCV real time streaming video capture is slow. How to drop frames or get synced with real time?
body: <h1>Goal and problem</h1>
  
  <p>I'd like to set up an opencv system to process either HLS streams or RMTP streams, however, I am running into a strange issue regarding a reduced frame-rate and an accumulating lag. It's as if the video gets further and further behind from where it is supposed to be in the stream.    </p>
  
  <p>I'm looking for a way to keep up to date with a live source even if it means dropping frames.  </p>
  
  <h1>Current approach</h1>
  
  <pre class="lang-py prettyprint-override"><code>import cv2
  
  cap = cv2.VideoCapture()
  cap.open('https://videos3.earthcam.com/fecnetwork/9974.flv/chunklist_w1421640637.m3u8')
  
  while (True):
      _, frame = cap.read()
      cv2.imshow("camCapture", frame)
      cv2.waitKey(1)
  </code></pre>
  
  <p>I've validated the quality of the stream on VLC and it seems to work fine there.  </p>
  
  <h2>cv2 speed</h2>
  
  <p><img src="https://media.giphy.com/media/LmrlaW11Oc2pLYB8EL/giphy.gif" alt=""> . </p>
  
  <h2>realistic/expected speed</h2>
  
  <p><img src="https://media.giphy.com/media/Y2zrQ0fUQ9jv08ioHi/giphy.gif" alt=""> </p>
  
  <h2>Questions:</h2>
  
  <ul>
  <li>What am I doing wrong here?  </li>
  <li>Why is it so slow?  </li>
  <li>How do I sync it to real-time speeds?</li>
  </ul>