title: How to play a video using opencv?
body: <p>I'm trying to play a video using <code>opencv</code> (the video is an avi file stored on the disk). However, the program stops execution on the following line in <code>cap_ffmppeg.cpp</code>:</p>
  
  <pre><code>if(!ffmpegCapture ||
     !icvRetrieveFrame_FFMPEG_p(ffmpegCapture,&amp;data,&amp;step,&amp;width,&amp;height,&amp;cn))
     return 0;
  </code></pre>
  
  <p>The error is: <code>Access violation reading location</code>... so a seg fault is occurring the first time <code>capture &gt;&gt; frame</code> is run.</p>
  
  <p>Here is the program:</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;fstream&gt;
  #include&lt;cv.h&gt;
  #include&lt;highgui.h&gt;
  #include&lt;opencv2/nonfree/features2d.hpp&gt;
  using namespace std;
  using namespace cv;
  
  
  int main(int argc, char *argv[])
  {
      if (argc &lt;= 1)
      {
          printf("Usage: %s video\n", argv[0]);
          return -1;
      }
  
      VideoCapture capture(argv[1]);
  
  
      if(!capture.isOpened())
      {
          printf("Failed to open the video\n");
          return -1;
      }
  
      for(;;)
      {
          Mat frame;
          capture &gt;&gt; frame; // get a new frame from camera
      }
  
      return 0;
  }
  </code></pre>
  
  <p>Any idea what I'm doing wrong?</p>