title: OpenCV cap.get(cv2.CAP_PROP_FRAME_COUNT) returning -1
body: <p>I recently setup opencv 3.0 for python on my ubuntu pc using the following tutorial <a href="http://www.pyimagesearch.com/2015/06/22/install-opencv-3-0-and-python-2-7-on-ubuntu/" rel="nofollow">http://www.pyimagesearch.com/2015/06/22/install-opencv-3-0-and-python-2-7-on-ubuntu/</a></p>
  
  <p>So I ran the following code to get the number of frames of an mp4 video</p>
  
  <pre><code>   import cv2
  
     cap = cv2.VideoCapture('vid.mp4')
     length = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
     print length 
  </code></pre>
  
  <p>Strangely I get "-1" as output for "length". The video does infact load and I get accurate values for</p>
  
  <pre><code>   int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))  #480
  </code></pre>
  
  <p>and </p>
  
  <pre><code>   int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))   #640
  </code></pre>
  
  <p>so its a wonder why frame count doesn't work. Please Help.</p>