title: Error with while (cap.isopened()): in python using cv2
body: <p>There are a lot of examples using</p>
  
  <pre><code>while (cap.isopened()):
  </code></pre>
  
  <p>to loop through a video, but I've found that it always errors out on the last frame. I'm currently using this instead</p>
  
  <pre><code>while (cap.get(1) &lt; cap.get(7)):
  </code></pre>
  
  <p>but is there something I need to do to get the first method to work and not error out?</p>
  
  <p>I'm just doing normal things within the while loop; an example is below:</p>
  
  <pre><code>while (cap.get(1) &lt; cap.get(7)): #(cap.isOpened()):
      ret, frame = cap.read()
      gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
      cv2.imshow('frame',gray)
      if cv2.waitKey(1) &amp; 0xFF == ord('q'): 
          break
  </code></pre>