Every time that I use VideoCapture trying to access the frames from a video file, the return value (ret
) is false. See the sample code below:
cap = cv2.VideoCapture('asd.mkv')
vid = []
while True:
ret, img = cap.read()
if not ret: # Always happens
break
vid.append(cv2.resize(img, (171, 128)))
I have already tried absolutely everything I could find today by googling, including the OpenCV guide and this long issue on Github. Also, I read some solutions involving moving ffmpeg dll files, but that only was in the case of Windows.
Any ideas? Because I defenitely ran out of them.
The problem was at my IDE (Visual Studio Code) and the association with bin files when installing OpenCV... my bad. This guide worked flawlessly.
For future reference: installing opencv with pip does not work with ffmpeg.
From the opencv-python FAQ:
Solutions: