Unable to open video file in opencv3.2.0?

asked 2017-06-19 06:50:12 -0500

akash29 gravatar image

updated 2017-06-20 14:10:13 -0500

Video files can't read although camera is working using VideoCapture. I have added the correct ffmpeg file from opencv directory to C:/Python27 environment variable. What to do now, still the video is not working? Here's my simple code to open video file import numpy as np import cv2

Capture video from file

cap = cv2.VideoCapture('vtest.avi')

while True:

ret, frame = cap.read()

if ret == True:

    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)


    if cv2.waitKey(30) & 0xFF == ord('q'):
        print True

    print False

cap.release() cv2.destroyAllWindows()

edit retag flag offensive close merge delete



Well. In order for ANYONE to be able to help you out with this we need some more information. What kind of format is the video you're trying to open? What is the exact error message you're getting? Does the video you're trying to open have "delays" or jitter when being opened in a media player like VLC?

ThorbjornSomod gravatar imageThorbjornSomod ( 2017-06-19 08:45:48 -0500 )edit

OS could help too

LBerger gravatar imageLBerger ( 2017-06-19 10:50:15 -0500 )edit

I have tried .avi and .mp4 format. No extract error messages are getting. The shell restarts after few seconds. No, the video has no jitter when playing through VLC

akash29 gravatar imageakash29 ( 2017-06-19 17:44:03 -0500 )edit

make sure, opencv_ffmpeg.dll is on your PATH or next to your app (also, _x64 or not ...)

berak gravatar imageberak ( 2017-06-21 00:57:49 -0500 )edit

opencv_ffmpeg.dll file is added to the PATH and to the root directory of Python27 too.

akash29 gravatar imageakash29 ( 2017-06-21 02:59:15 -0500 )edit

check 32/64bit again

berak gravatar imageberak ( 2017-06-21 03:02:37 -0500 )edit

Yeah, I have copied the file from C:\opencv\build\x64\vc14\bin to the root directory of Python27 and added the path to the environment variable too. Please, anything you can point it out more that would be lot helpful.Thanks in advance.

akash29 gravatar imageakash29 ( 2017-06-22 01:25:20 -0500 )edit