title: OpenCV - Play AVI File
body: <p>I am trying to play in avi file using opencv c++ in ubuntu but i am getting no output. The code im using is a standard code that i found online that is used to play an avi video but im seeing no output. And yes the video is in the same directory as my src code folder. The only thing im seeing is that on the first iteration of the while loop, frame is empty and hence breaks. but i do not know why it is happening as the video is working on vlc. I would really appreciate some help here as i have been stuck on it for the past 4-5 hours.
      #include "cv.h"      // include it to used Main OpenCV functions.
      #include "highgui.h" //include it to use GUI functions.</p>
  
  <pre><code>int main(int argc, char** argv)
  {
  cvNamedWindow("Example3", CV_WINDOW_AUTOSIZE);
  
  //CvCapture* capture = cvCreateFileCapture("20051210-w50s.flv");
  CvCapture* capture = cvCreateFileCapture("tree.avi");
  /* if(!capture)
      {
          std::cout &lt;&lt;"Video Not Opened\n";
          return -1;
      }*/
  IplImage* frame = NULL;
  
  while(1) {
  
      frame = cvQueryFrame(capture);
      //std::cout &lt;&lt; "Inside loop\n";
      if (!frame)
          break;
      cvShowImage("Example3", frame);
      char c = cvWaitKey(33);
      if (c == 27) break;
  }
  cvReleaseCapture(&amp;capture);
  cvDestroyWindow("Example3");
  std::cout &lt;&lt; "Hello!";
  return 0;
  }
  </code></pre>