Ask Your Question

OpenCV VideoCapture cannot read video in Python but able in VS11

asked 2013-05-06 00:32:21 -0600

ythen gravatar image

As title, I am not able to read video using VideoCapture in python with the following code:

v = 'C:\\test.mp4'
import cv2
cap = cv2.VideoCapture(v)
if cap.isOpened():
  print "Finally"
  print "BOOM"

BOOM is always being printed. sigh

Whereas in VS11, the following code works:

#include "stdafx.h"

#include <opencv2\highgui\highgui.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, char* argv[])
    string v = "C:\\test.mp4";
    VideoCapture cap;;
    if (cap.isOpened()) {
        cout << "Yes!" << endl;
    } else {
        cout << "BOOM" << endl;

    return 0;

I do realize there's a number solution in SO, but nothing works for me. I have the following dlls in C:\Python27 and C:\Python27\DLLs, as well as in PATH

  • opencv_ffmpeg.dll
  • opencv_ffmpeg_64.dll
  • opencv_ffmpeg_245_64.dll
  • opencv_ffmpeg_245.dll

I have no more idea what have not done.

Please help me. Thank you very much.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-05-13 00:48:58 -0600

ythen gravatar image

I have solved the problem by installing the binaries from this download link provided by this answer.

It copied all opencv DLLs to C:\Python27 (or maybe other files). But I don't understand why it wouldn't work earlier as I have already included those DLLs into my PATH

edit flag offensive delete link more

Question Tools


Asked: 2013-05-06 00:32:21 -0600

Seen: 632 times

Last updated: May 13 '13