videocapture error opening file

asked 2014-11-05 03:52:34 -0600

openprog gravatar image

when I use videocapture i get the error message

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

why?

I use visual c++ 2010.

edit retag flag offensive close merge delete

Comments

1

dear, it just did not find your videofile (wrong path , probably).

the message above is just the place in the code, where the exception occurred.

berak gravatar imageberak ( 2014-11-05 04:01:07 -0600 )edit

the video file is in the project folder, where should i put it?

openprog gravatar imageopenprog ( 2014-11-05 04:28:34 -0600 )edit

leave it there, instead look at the debugging settings of your project, and change the workingdir, so it starts from the same folder.

berak gravatar imageberak ( 2014-11-05 05:33:24 -0600 )edit

Or just skip placing files relatively to your executable at all and just pass along the abosute path to the file! Relative paths are the pitfall of every starting programmer.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-11-05 06:13:43 -0600 )edit

not work, what to do?

openprog gravatar imageopenprog ( 2014-11-05 06:29:46 -0600 )edit

the code is the next:

VideoCapture cap("video.avi"); // open the video file for reading

if ( !cap.isOpened() )  // if not success, exit program
{
     cout << "Cannot open the video file" << endl;
     return -1;
}
openprog gravatar imageopenprog ( 2014-11-05 06:38:27 -0600 )edit

to others the code works

openprog gravatar imageopenprog ( 2014-11-05 06:48:30 -0600 )edit

Change "video.avi" to the exact location, for example "/home/usr/data/video.avi" ...

StevenPuttemans gravatar imageStevenPuttemans ( 2014-11-05 08:10:40 -0600 )edit