videocapture is not working in opencv 3.4.0
I have an .mp4 video saved in the path (D:\Personal\workspace\FirstVideo.mp4) and in the code when i call videocapture cap("filepath") it is returning false everytime and prints "cannot open the video file". Below is the code snippet. I have added the libopencv_videoio340 library in my eclipse c++ settings. Everytime when i run my code, it always prints "cannot open the video file", I have no clue now how to proceed o this. Can anyone help me on this? Thanks in advance!!!
//==================================
//Code snippet
//==================================
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main( int argc, char** argv)
{
//open the video file for reading
VideoCapture cap("D:\\Personal\\workspace\\FirstVideo.mp4");
if(cap.isOpened() == false)
{
cout<<"cannot open the video file"<<endl;
cin.get();
return -1;
}
//get the frames rate of the video
double fps = cap.get(CAP_PROP_FPS);
cout << "Frames per seconds : " << fps << endl;
// Create a window for display.
namedWindow( "First Test Video", WINDOW_AUTOSIZE );
while (true)
{
Mat frame;
bool bSuccess = cap.read(frame); // read a new frame from video
//Breaking the while loop at the end of the video
if (bSuccess == false)
{
cout << "Found the end of the video" << endl;
break;
}
imshow( "First Test Video", frame );
waitKey(0);
}
return 0;
}
make sure opencv_ffmpeg340.dll is on the PATH (since all video file functionality is taken from there)
I found this lib in the path (D:\Personal\opencv_3.4\opencv\build\bin\opencv_ffmpeg340.dll) Shall i add this lib from the above path into eclipse (project->properties->C++ Settings->C++ Linker->Libraries)
no, add the containing folder to the system's environment PATH variable
(your ide is entirely irrelevant here)
I added this into my system PATH variable. No Progress, still videocapture cap() is returning false and printing "cannot open the video file"
check again 32 / 64 bit
Yes i checked it again, it's added in the PATH variable. It is 64 bit. Can you confirm the ffmpeg lib path (D:\Personal\opencv_3.4\opencv\build\bin\opencv_ffmpeg340.dll), is this what i should refer to the path or is there any other path where i can found ffmpeg lib?
opencv_ffmpeg340_64.dll , then.
and, you'll probably have to restart your shell / ide , after changing env vars.
I tried restarting my system too, videocapture is still not working :(
Can anyone help me in resolving the issue?
@inn@nav8. R u running visual studio c++?