1

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 . .

user3358147
  • 69
  • 5
  • 12
  • Opencv can handle avi files definitely : http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html#videocapture. 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 12 '14 at 07:58
  • 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 May 12 '14 at 09:15

1 Answers1

2

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

Community
  • 1
  • 1
etoropov
  • 1,185
  • 11
  • 16
  • nopes.. i installed OpenCV first . Do I need to reinstall OpenCV again ? – user3358147 May 13 '14 at 00:21
  • in this case I would try doing something with your .avi file using ffmpeg from command line to check if it's ffmpeg's fault (e.g. convert the video format: http://www.linuxjournal.com/article/8517?page=0,1). If ffmpeg runs fine, then you may check if you can read *any* video file from OpenCV. If you can't then something's wrong with the opencv installation – etoropov May 14 '14 at 17:42