Unable to open video from C++ in opencv. It works from python

asked 2014-09-02 12:55:31 -0600

I'm trying to use open cv (2.4.9) video support from within C++. However, when I try to open a video file with cv::VideoCapture I get

warning: Error opening file (/tmp/opencv-mLsrDm/opencv-2.4.9/modules/highgui/src/cap_ffmpeg_impl.hpp:545)
WARNING: Couldn't read movie file videoname.mp4

Using cv2.VideoCapture from within python on the same file works. The python wrappers are from the same build of opencv as far as I can tell so I'm a bit perplexed.

Mac os 10.9.4. OpenCV is built with ffmpeg (but no quicktime as that wouldn't compile) via homebrew.

I'm linking against all the libraries that the the python cv2.so is linked against.

Any ideas? Thanks.

edit retag flag offensive close merge delete


Are you certain that the path to the video file in your C++ code is correct?

Martin Peris gravatar imageMartin Peris ( 2014-09-02 21:07:52 -0600 )edit

Ffmpeg is outdated and known to cause TONS of errors on linux. On Ubuntu it is replaced by libav. I suggest building opencv without ffmpeg support and trying again. That might work for you.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-09-03 07:17:28 -0600 )edit