1
votes

I am trying to open a video file (.MOV,.AVI or .MP4) using OpenCV on linux. So that I can extract specific frames as images on the disc and do image processing. I have also installed ffmpeg on linux.

My code snippet is :

CvCapture* capture = cvCreateFileCapture("sample.avi");

    if(!capture)  // check if we succeeded
        printf("Video failed to open\n");
    else
        printf("Video opened\n");

I cannot open an avi file. Can anyone guide me:

  1. Why I cannot open AVI video file using OpenCV?
  2. I was reading somewhere that OpenCV can only handle .avi files. So, what I will do with other movie formats?

Any help will be really appreciated . .

1
Opencv can handle avi files definitely : docs.opencv.org/modules/highgui/doc/…. Consider using c++ API next time, C-one id deprecated. Do you have appropriate privileges to access the video file? The problem does not lay on opencv side I think. - marol
may be its right problem. I have tried the same code on my windows laptop and it works with avi file. I will try to change rights on the video file on Linux system. In my opinion, I have not configured ffmpeg properly on Linux and have to do that . . - user3358147

1 Answers

2
votes

I have also installed ffmpeg on linux.

Did you just install ffmpeg after installing OpenCV? The proper way would be to install ffmpeg first, then build OpenCV with ffmpeg support. Like here: Setting/Installing up OpenCV 2.4.6.1+ on Ubuntu 12.04.02