1

I followed these instructions to install opencv for python (i.e. copying the pyd file into site-packages). It works fine, except opencv cannot open any video files I try to open:

capture = cv2.VideoCapture("some_file.avi") 
capture.isOpened() # False

I tried videos with h264 and mpeg2 encodings without success. Windows 7 x64, 32bit Python 2.7.5 and opencv 2.4.7. So that presumably means that opencv cannot find the right codecs, but I made sure that opencv_ffmpeg247.dll is in the path.

Voo
  • 29,040
  • 11
  • 82
  • 156
  • This solved my problem: http://stackoverflow.com/questions/11699298/opencv-2-4-videocapture-not-working-on-windows – Paul May 14 '15 at 18:27

2 Answers2

1

Install the newest FFmpeg available from the repository:

git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg

The version you have installed is probably not compatible with OpenCV 2.4.7. The easiest way to test this hypothesis is to downgrade OpenCV to version 2.4.5.

And remember: cv2.VideoCapture("some_file.avi") will succeed only if some_file.avi is in the same directory as your source code. If that's not the case, you should use the full path to the file!

I want to quote another post from this forum:

The cause of your problem could be bug #2281: VideoCapture::read fails on uncompressed video.

Anyway, please try OpenCV 2.4.5 and let us know if it worked.

Community
  • 1
  • 1
karlphillip
  • 92,053
  • 36
  • 243
  • 426
  • Yes I'd expect a call that has to open a file only to succeed if the file was actually there ;) (more seriously though: normal calls to open() work fine and I tried absolute paths too). I'm using the ffmpeg dll that's shipped with opencv so why would those fail while the newest ones succeed? Not really looking forward to compiling any larger C library under windows if there's not a really good reason why that should help. – Voo Nov 24 '13 at 23:18
  • The easiest path is to go back to 2.4.5. Do that and tell me how it went. ;) – karlphillip Nov 25 '13 at 00:16
  • Apparently a bug in opencv 2.4.7. It ships with a ffmpeg dll that is not compatible with its shipped python module. I assume I should file a bug for that one *sigh*, well going back to 2.4.5 fixed the problem. The usual spiel - bounty rewarded as soon as SO lets me. – Voo Nov 25 '13 at 03:00
0

I'm struggling with same issue, I guess (OpenCV 2.4.7 with FFMpeg support build with VS 2010 (x86)). Just to make sure, you tried to open an existing video, including the full path, right?

Best

Community
  • 1
  • 1
GregPhil
  • 475
  • 1
  • 8
  • 20