2

I have installed OpenCV in Windows 7 (32 bit) and Put the cv2.pyd file in Python Modules Directory and everything is working just fine but except opening of Video file {I have tried 5-6 different kind of extensions but nothing is helping} CODE::

import numpy as np
import cv2
cap = cv2.VideoCapture('vtest.avi')
while(cap.isOpened()):
    ret, frame = cap.read()
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    cv2.imshow('frame',gray)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
cap.release()
cv2.destroyAllWindows()

the line cap.isOpened() always returns False {i also tried providing absolute path to the video file} but that too return false So please can please anybody help me that why that line is always returning False

1 Answer 1

5

I have found the solution there is a file present in C:\opencv\sources\3rdparty\ffmpeg\opencv_ffmpeg.dll just Copy and Paste that file into your Python base directory say C:\Python\opencv_ffmpeg.dll and rename the file to the version of the OpenCV you are using like in my case its v3.0.0 so i have to rename it as C:\Python\opencv_ffmpeg300.dll if your system is X64 then also add _64 at the end like C:\Python\opencv_ffmpeg300_64.dll

Sign up to request clarification or add additional context in comments.

3 Comments

Worked for me, why don't you mark it as a solution?
This worked for me also. I didn't need to rename the DLL as the version of OpenCV I downloaded had the DLLs named correctly. Important point is that this goes into the python dir e.g. C:\Python27 rather than the DLLs directory beneath that. I had to restart the python interpreter as well.
Are you able to play the sound with the video

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.