Python OpenCV returns wrong FPS

asked Dec 4 '18

0 down vote favorite

I recorded 1 minute video using my webcam and then I used that video in a python program and checked the frame rate per second using opencv, but it returned false fps. It returned 1000 fps and 60883 total frames. I used following code to find above two.

import cv2
cap = cv2.VideoCapture(filename)
frames_per_sec = cap.get(cv2.CAP_PROP_FPS)  
total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))

While total number of frames correctly read by the following statement were around 1800.

 ret, frame = cap.read()

Now how do I correctly find fps of a video file recorded through webcam in python?

Preview: (hide)

Comments

I tested it. Returned 30 fps. Are you using linux using raspberry pi?

supra56 gravatar imagesupra56 (Dec 4 '18)edit

Here is the webm file that I'm using: https://drive.google.com/file/d/1eusL... For this file it returns 1000 fps.

Muhammad Hassan gravatar imageMuhammad Hassan (Dec 5 '18)edit