简体   繁体   中英

OpenCV Video Capture Not Loading Files

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?

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

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.

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 !

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM