Python2.7 with Opencv 3.3.0 - Videocapture problem

Asked

Viewed 239 times

0

I’m running Opencv 3.3.0. with Python 2.7 on a Windows 7 Professional x64 machine, and when I run the code below, falls in the prints "Something went wrong" and "Finished ..."

import cv2

capture = cv2.VideoCapture("video.mp4") #The video is in the same folder

if(not capture.isOpened()):
    print "Something went wrong"

while(cap.isOpened()):
     ret, frame = cap.read()

     cv2.imshow('Frame', frame)

print "Finished ..."

capture.release()
cv2.destroyAllWindows()

I did a search, and indicated that I should copy the file "opencv_ffmpeg{Versaodoopencvsempontos}. dll" for the Python root folder, and so I did.

I copied the file "opencv_ffmpeg330_64.dll" (and also copied renamed as "opencv_ffmpeg330.dll") to:

  • The Python root folder
  • The Python DLLS folder
  • The Python Lib folder
  • The Python Lib/site-Packages folder

But none of it worked ...

I kept searching, and one topic suggested that it was codec problems, so I downloaded FFMPEG, added it to my PATH environment variable, converted my "video.mp4" to "video.avi" with ffmpeg, but nothing working.

So I downloaded the VLC media player, to ensure that I have the codecs installed, but keeps giving that video does not open. (The video runs on my players, both in mp4 and avi, without any problem)

I’m not finding a solution to this, someone has faced this kind of problem and knows how to solve it?

  • Could you translate your question?

  • Done! When I posted, I was in the English version, nor did I realize that I had been redirected to the en ... my fault!

  • The only apparent problems with your code are: (1) you use two different variables (capture and cap) and (2) you do not use the cv2.waitKey(1), for example, to wait some time after the display of each frame of the video. About him printing error like there was a glitch in the video, I really couldn’t play it. If you installed Opencv with Pip, it should not even be necessary to copy any DLL.

1 answer

0


I decided to downgrade Opencv to Opencv 3.0.0.

I copied cv.pyd to the Python Lib/site-Packages folder, and the opencv_ffmpeg300.dll file to the Python root folder, and it worked!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.