Reputation: 169
I am using Python 3.5 and Opencv for an interactive video. However I can't figure out how to detect when my video finishes playing. Any ideas how I can detect when the video ends?
Thanks a bunch.
Upvotes: 4
Views: 15046
Reputation: 1
May be this will help
cv2.CAP_PROP_FRAME_COUNT
cv2.cv.CV_CAP_PROP_FRAME_COUNT
Upvotes: 0
Reputation:
When ret is False, it means that the video is in the last frame.
Here is my code.You can try it.
import cv2
video_capture = cv2.VideoCapture("huge.mp4")
while True:
ret, frame = video_capture.read()
if ret:
cv2.imshow('Video', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
else:
break
video_capture.release()
cv2.destroyAllWindows()
Upvotes: 8