0
votes

I am trying to open video in openCV but it is not working i found solutions by adding full path i.e "D:/Folder1/Folder2/1.avi", converting video to .avi instead of mp4, copy the dll file from open cv to python folder after changing it is name by opencv version and windows 64 bit ffmpeg opencv_ffmpeg320_64.dll my opencv version 3.2.0 windows 64 python2.7 and Anaconda2

I am beginner in Python and unfortunately nothing of the above solved my problem.

below my code snippet:

import numpy as np
import cv2

cap = cv2.VideoCapture('1.avi')
if cap.isOpened():
    print "opend"
else:
    print "not opend"

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()
1
Looks like you are missing codecs in your computer. Try to download a codec package and then try again - Pedro Batista
Thank you @PedroBatista do you mean Codec for windows. or Codec Python Package. In case Codec Python package, do you mean that i should replace openCv code by Codec code? appreciate your reply. - dodo
No, I mean just installing a codec package to your system. OpenCV is trying to find the codec needed to open that video but is not finding it, so you need to install it. - Pedro Batista
Then I'll add my first comment as an answer and ask you to accept it so other people with similar issue can find the solution easierly. - Pedro Batista
Many thanks @PedroBatista Finally it is working after applying your solution :) how to upvote this reply - dodo

1 Answers

0
votes

OpenCV is trying to find the codec needed to open that video but is not finding it, so you need to install it. Try to download a codec package from the internet and then try again.