I can only get the number of frames CAP_PROP_FRAME_COUNT using CV2.
CAP_PROP_FRAME_COUNT
However, I cannot find the parameter to get the duration of the video using cv2.
First calculate frame per second like this
fps = cap.get(cv2.cv.CV_CAP_PROP_FPS)
Then duration can be calculated as (number of frames) / (frames per second)
duration = float(num_frames) / float(fps) # in seconds