title: OpenCV (3.3.0) returns fail on VideoCapture with Video but works with Webcam [OS X]
body: <p>Thanks for reading already, I've been trying to get this to work for a day and I didn't get closer to the solution. </p>
  
  <p>I'm trying to get this <a href="https://github.com/bikz05/object-tracker" rel="nofollow noreferrer">object tracker</a> to work. When I use a video from my webcam (with: <code>python object-tracker-single.py -d 0</code>, everything works as expected.</p>
  
  <p>But as soon as I'm trying to use a video file (i've tried different formats: <code>.mp4</code>, <code>.mkv</code> &amp; <code>.avi</code>. I also tried to use the file given in the repository, that didn't work as well. To see if there is a <code>File not found</code>-Error, I passed an invalid path to the function and an error got printed, that has not been printed when I used the other videos. So the file(s) i'm using is(/are) valid and not corrupted. </p>
  
  <p>I installed <code>dlib</code> through <code>homebrew</code> following <a href="https://www.learnopencv.com/install-dlib-on-macos/" rel="nofollow noreferrer">this article</a> and compiled <code>OpenCV</code> from the official source. This is the <a href="https://pastebin.com/6tAEC3iC" rel="nofollow noreferrer">CMakeCache.txt</a> that <code>CMake</code> spit out. After the first time I compiled it, I added <a href="https://github.com/opencv/opencv_contrib" rel="nofollow noreferrer">opencv_contrib</a> to the mix, thinking that it could help (I also think that I actually needed it), but that didn't fix the problem.</p>
  
  <p>This is the code I'm having problems with:</p>
  
  <pre><code># Create the VideoCapture object
  cam = cv2.VideoCapture(source)
  
  # If Camera Device is not opened, exit the program
  if not cam.isOpened():
      print "Video device or file couldn't be opened"
      exit()
  
  print "Press key `p` to pause the video to start tracking"
  while True:
      # Retrieve an image and Display it.
      retval, img = cam.read() #&lt;-- this returns false when trying to read a video 
      if not retval:
          print "Cannot capture frame device"
          exit()
  </code></pre>
  
  <p>At the marked line, <code>retval</code> equals <code>False</code> and <code>image</code> equals <code>None</code>. 
  It would already help me if I could somehow debug this behavior, but I didn't find any way of doing so.</p>
  
  <p>I found that many Windows Users had problems with missing <code>ffmpeg</code> support, but that is not the case for me, since I used <code>ffmpeg</code> in previous (not OpenCV-related) projects and <code>CMakeCache.txt</code> reports that <code>ffmpeg</code> has been found and the compilation succeeded.</p>
  
  <p>I also tried using a fully qualified file-name for the video file, which either resulted in <code>Video device or file couldn't be opened</code> or the given problem.</p>
  
  <p>If you have any idea how this problem can be completely resolved, have an Idea on how to solve it or can provide me with a way of properly debugging this behavior, I'd be super glad to here it!</p>
  
  <p>Thanks already!</p>
  
  <p>-</p>
  
  <p>System: MacBook Pro (macOS Sierra <code>10.12.6</code>)</p>
  
  <p>OpenCV Version: <code>3.3.0</code></p>
  
  <p>Dlib Version (not necessary imo, but hey): <code>19.4.0</code> </p>
  
  <p><strong>Edit 2</strong>
  Output of <code>cmake -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-master/modules ../ &gt;&gt; result.txt</code>: <a href="https://pastebin.com/KbHPQm3L" rel="nofollow noreferrer">pastebin</a></p>