1

This may seem like an issue related to a special version of OpenCV. However, when I have searched nearly everywhere and specially StackOverFlow, no reasonable answer was found.

I am trying to load a video file with ffmpeg in OpenCV using VideoCapture handle. The file is loaded if it is the tree.avi sample movie in the OpenCV samples directory, but every other avi file leads to the following error:

warning: Error opening file (../../modules/highgui/src/cap_ffmpeg_impl.hpp:526)

The hpp file seems to be the file where the error is detected and is not the file containing the error. I can only assume that ffmpeg is not compatible with OpenCV and either I should start looking for another library to open video files or I should assume that OpenCV works only for its own samples. If anyone has any idea, please share. Should I use another library to open all different kinds of files, formats with encodings instead of OpenCV or not?

Shane Hou
  • 4,808
  • 9
  • 35
  • 50
Amir Zadeh
  • 3,481
  • 2
  • 26
  • 47
  • Have you tried with the full path name of the video? Sometimes the compilation result is placed in a different folder. – Pablosproject Apr 09 '13 at 14:20
  • yeah that doesn't work. works only for the sample avi. – Amir Zadeh Apr 09 '13 at 14:47
  • 1
    Do not assume that just because OpenCV uses FFmpeg it can load all kinds of video formats, because it's not true. *AVI* is a simple a container that can store all kinds of audio/video codecs. – karlphillip Apr 09 '13 at 15:50
  • 1
    karl: yes I assume that is correct. However, I would like to know your opinion about what to do with this situation. – Amir Zadeh Apr 09 '13 at 19:24

4 Answers4

3

The OpenCV seems to have platform dependencies and its better to be compiled for every platform, to sum up all the search I have done for my problems with it. I had problems with VideoCapture which originated not from codec, but from OpenCV itself. I had similar problems with OpenCV to the extent that it couldn't even open a JPG file. All got solved for me by recompiling it.

For those who do not know how to compile OpenCV for Visual Studio, here is a good tutorial: Installing OpenCV 2.4.3 in Visual C++ 2010 Express

Community
  • 1
  • 1
Amir Zadeh
  • 3,481
  • 2
  • 26
  • 47
2

Do not assume that just because OpenCV uses FFmpeg it can load all kinds of video formats, because it's not true.

AVI is a simple a container that can store all kinds of audio/video codecs. OpenCV has page that lists the formats it supports.

karlphillip
  • 92,053
  • 36
  • 243
  • 426
  • I have put aside online video processing and started to process each of the frames in a different JPG file. However, CV cannot open image files as well. Not even the baboon.jpg in its own samples. I have been searching and I found you had similar problem in a post. May I ask how you solved it? – Amir Zadeh Apr 09 '13 at 21:17
  • Yeah, reinstalled FFmpeg and OpenCV on Windows. There was one time that `cv::imread()` throwed exceptions for no reason, so I abandoned the C++ interface and used the C interface of OpenCV with no problems. – karlphillip Apr 09 '13 at 22:12
  • Karl, I have found that opencv needs to be compiled on every single platform independently and there is no cure for all! even between my PC and laptop I needed to recompile the entire CV! the problem with the VideoCapture was also solved by recompiling! – Amir Zadeh Apr 13 '13 at 19:38
2

In OpenCV 2.4.4 : there is only opencv_ffmpeg244.dll (release dll) and not opencv_ffmpeg244d.dll (debug dll)

So try in release compilation mode !

Ismax
  • 31
  • 1
1

You may need to compile your own ffmpeg (get the latest snapshot from here),and then compile opencv again.Check your output during the configure step,it should say something like:

...
Video I/O--------------
Use QuickTime      no
Use xine           no
Use ffmpeg:        yes
Use v4l            yes
...
Rodrigo Vasconcelos
  • 1,270
  • 2
  • 14
  • 26