1import cv2
2
3cap = cv2.VideoCapture("./video.mp4")
4fps = cap.get(cv2.CAP_PROP_FPS) # OpenCV2 version 2 used "CV_CAP_PROP_FPS"
5frame_count = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
6duration = frame_count/fps
7
8print('fps = ' + str(fps))
9print('number of frames = ' + str(frame_count))
10print('duration (S) = ' + str(duration))
11minutes = int(duration/60)
12seconds = duration%60
13print('duration (M:S) = ' + str(minutes) + ':' + str(seconds))
14
15cap.release()
16