Reputation: 31
i try to read .avi or .mpeg video file using VideoCapture class of OpenCV2.4.8 in C++ using QtCreator and CMake 2.8.12.1. Before built OpenCV, i download FFMPEG static version and put them into Program Files directory, i add their path into enviroments variable PATH, then i download K Lite Codec Pack Full, install it and only then i built OpenCV with CMAKE and mingw provide by Qt. After installation i add to PATH the right path of built OpenCV. The stream from webcam works fine, but the stream from a video file doesn't work. I tried on Windows 7 32bit and Windows 8 64bit. Here is the code
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include "opencv2/opencv.hpp"
cv::Mat img;
cv::VideoCapture cap("Prova.avi");
std::cerr << cap.isOpened() << std::endl;
while(cap.read(img)){
cv::imshow("Opencv", img);
cv::waitKey(33);
}
The same code works on Ubuntu 12.04 with the same version of OpenCV and with the ffmpeg build by myself. What is wrong?
Upvotes: 2
Views: 5781
Reputation: 872
Download the file opencv_ffmpeg.dll
. I got it from this
Now rename the opencv_ffmpeg.dll
according to the opencv version you are using. For OpenCv 2.4.8 rename it as opencv_ffmpeg248.dll
and add the location of this file to the PATH in environment variable. Now try to run your program.
Upvotes: 4
Reputation: 31
For some unknown reason in a system 32bit the building created a dll called opencv_ffmpeg248_64.dll and the installation of opencv was in a folder "x64", so i think that dll was for 64bit system. I download the pre built version of openCV and i use the dll included in that package.
Upvotes: 0