OpenCV 2.4 VideoCapture does not work on Windows

I am using Python bindings to OpenCV 2.4 installed with the following instructions .

My problem is similar to this , but I need a solution for Windows.

Problem: when I try to use

cap = cv2.VideoCapture(0) print cap.grab() 

it works fine but the following code

 cap = cv2.VideoCapture(filename) print cap.grab() 

always return false.

The file path is correct, absolute, and has no spaces.

I tried on two machines with Windows XP and Windows 7 with similar results. On Linux (Ubuntu), it works great for me.

+44
python windows opencv
Jul 28 '12 at 7:55
source share
9 answers

Add C:\OpenCV\3rdparty\ffmpeg\ to the Windows PATH environment variable or copy opencv_ffmpeg.dll from this directory to C:\Python27\ or to the directory that is located in PATH. Also, use the OpenCV binaries from http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv .

You may also need to rename the opencv_ffmpeg.dll file.

For OpenCV XYZ Version
opencv_ffmpeg.dll ==> opencv_ffmpegXYZ.dll

For 64-bit version of OpenCV XYZ
opencv_ffmpeg.dll ==> opencv_ffmpegXYZ_64.dll

+67
Jul 28 '12 at 19:28
source share

Copying opencv_ffmpeg.dll was not enough for me - I had to rename it to opencv_ffmpeg246.dll when I used OpenCV 2.4.6 with Python 2.7.5

+27
Jul 16 '13 at 9:25 am
source share

At first I tried copying, and then changed the environment of the Windows environment. This did not work until I changed the name to opencv_ffmpeg245.dll for my openCV version 2.4.5 and python 2.7. (notice ** 245.dll from opencv version 2.4.5)

+8
Mar 21 '14 at 13:02
source share

For 64-bit versions, rename opencv_ffmpeg_64.dll to opencv_ffmpeg249_64.dll. Change 249 to your version of opencv.

+7
Jun 13 '14 at 18:44
source share

For OpenCV 3.0.0 on a 64-bit environment, copy the opencv_ffmpeg_64.dll file and rename it to opencv_ffmpeg300_64.dll.

Also add this path to your PATH environment variable so that it works with OpenCV under Java.

+6
Oct 05 '14 at 21:34
source share

Update: this is still true for OpenCV 2.4.9, copy all files and rename dll opencv_ffmpeg249.dll

+5
Jun 09 '14 at 12:42 on
source share

I had the same issue with python 2.7 and opencv 2.4.10. I copied the opencv_ffmpeg2410_64.dll file from C: \ Applications \ opencv \ build \ x64 \ vc10 \ bin to the python path (mine is in C: \ Users \ mohammad \ Anaconda) and it was solved!

+4
03 Mar. '15 at 4:22
source share

First I use windows8.1 32bit and opencv 2.4.10.
I ran into the same problem to use the test1.wmv file that Logicool C270 created.
I tried using another test2.mov file that was made by a digital camera (Canon SX160). So I can play test2.mov to add the path C:\opencv\build\x86\vc12\bin .
But I can not play test1.wmv.
Therefore I am trying to change the format of test1.wmv to test1a.mp4 using VLC (before Video for youtube HD ).
Then I can play test1a.mp4.
I tried test1.wmv on Ubuntu 14.04 LTS, then I can play it easily.
There may be some difference in the default ffmpeg binary between windows8.1 and Ubuntu 14.04 LTS.

+3
Nov 23 '14 at 10:11
source share

For anaconda environment, copy opencv_ffmpeg249_64.dll from C: \ Python27 \ rename its version according to your version of opencv and past it C: \ Users \ KHALID \ Anaconda2 \ Library \ Bin

0
Jul 08 '17 at 11:30
source share



All Articles