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.
解决方案
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()