Ask Your Question

Revision history [back]

isOpened() returns false on files

Hey everyone, I've been trying to run the following code:

import cv2
cap = cv2.VideoCapture("asdf.mp4")
while cap.isOpened():
    ret, frame = cap.read()

    cv2.imshow('frame', frame)
cap.release()
cv2.destroyAllWindows()

However, cap.isOpened() returns false for anything that is not 0 (webcam). I tried to type both relative and absolute path, but none works. Am I missing something?

Thanks, Tal