Performing pip install python-opencv fixed the problem and the FPS is correctly detected.

EDIT: tested with python 3.8 and indeed it is pip install opencv-python. Cannot remember two years ago what python I was using.

EDIT November 2022: please also check Perry's answer below, if you are using a newer opencv-python version

Answer from Tasos on Stack Overflow
🌐
GitHub
github.com › opencv › opencv › issues › 24000
.get(cv2.CAP_PROP_FPS) returns incorrect FPS · Issue #24000 · opencv/opencv
July 17, 2023 - This mp4 video (attached below) has a length of 24:22mins, and a frame rate of 14.9 fps when checking the properties of the file in Windows. However, cv2 says that it has 30 fps as shown below. Additionally, when I try to find the length of the video in milliseconds (following this post) to calculate the fps manually, I get 0.033. Code: video_capture = cv2.VideoCapture('C:\\Users\\AShetty12\\Downloads\\raw_videos\\MOV_2564.mp4') print(video_capture.isOpened()) # returns True print(video_capture.get(cv2.CAP_PROP_FPS)) # returns 30 total_frames = int(video_capture.get(cv2.CAP_PROP_FRAME_COUNT))
Discussions

python - Understanding the function CAP_PROP_FPS in cv2 - Stack Overflow
I am trying to understand the output frames I received using the code below. I am learning to use OpenCV and how it functions. My idea is to get one frame per second in a video. Here are some of the More on stackoverflow.com
🌐 stackoverflow.com
VideoCapture.get(cv::CAP_PROP_FPS) is wrong for some special video
System information (version) OpenCV => 4.5.0 Operating System / Platform => MacOS 12.0.1 Compiler => clang 12.0.5 Detailed description The FPS get from VideoCapture.get(cv::CAP_PROP_FPS) i... More on github.com
🌐 github.com
11
November 4, 2021
Windows get camera cv2.CAP_PROP_FPS incorrect value for low fps.
System Information Self built Opencv 4.10 for windows with python. Detailed description OpenCV for Windows reports incorrect FPS if Camera was read before and low FPS was set. Steps to reproduce fr... More on github.com
🌐 github.com
1
October 4, 2024
set property of cv2.VideoCapture is returning false for cv2.CAP_PROP_FPS
Expected behaviour Write here how did you expect the library to function. if fps rate of a video file is 25 ,i need to read only 10 frames per second so i set fps as 10 using set property cv2.CAP_PROP_FPS , after setting capture.read() o... More on github.com
🌐 github.com
1
January 6, 2020
🌐
GitHub
github.com › opencv › opencv › issues › 21006
VideoCapture.get(cv::CAP_PROP_FPS) is wrong for some special video · Issue #21006 · opencv/opencv
November 4, 2021 - System information (version) OpenCV => 4.5.0 Operating System / Platform => MacOS 12.0.1 Compiler => clang 12.0.5 Detailed description The FPS get from VideoCapture.get(cv::CAP_PROP_FPS) i...
🌐
LearnOpenCV
learnopencv.com › home › find frame rate (frames per second-fps) in opencv (python/c++)
Find frame rate (frames per second-fps) in OpenCV (Python/C++)
July 31, 2026 - The documentation says that get(CAP_PROP_FPS) gives the frames per second. Now that is true for video files, but not for webcams. For webcams and many other connected cameras, you have to calculate the frames per second manually. You can read a certain number of frames from the video and see how much time has elapsed to calculate frames per second. #!/usr/bin/env python import cv2 import time if __name__ == '__main__' : # Start default camera video = cv2.VideoCapture(0); # Find OpenCV version (major_ver, minor_ver, subminor_ver) = (cv2.__version__).split('.') # With webcam get(CAP_PROP_FPS) does not work.
🌐
GitHub
github.com › opencv › opencv-python › issues › 281
set property of cv2.VideoCapture is returning false for cv2.CAP_PROP_FPS · Issue #281 · opencv/opencv-python
January 6, 2020 - if fps rate of a video file is 25 ,i need to read only 10 frames per second so i set fps as 10 using set property cv2.CAP_PROP_FPS , after setting capture.read() only return 10 frames per second
Author: opencv
Find elsewhere
Top answer
1 of 3
22

The get() for CAP_PROP_FRAME_COUNT is never supposed to be accurate! If you check the opencv source code. You can find this:

int64_t CvCapture_FFMPEG::get_total_frames() const
{
    int64_t nbf = ic->streams[video_stream]->nb_frames;

    if (nbf == 0)
    {
        nbf = (int64_t)floor(get_duration_sec() * get_fps() + 0.5);
    }
    return nbf;
}

This means it will first look into the stream header for nb_frames, which you can check with ffprobe. If there is no such field, then there is no better way to get frame number than directly decoding the video. The opencv did a rough estimation by get_duration_sec() * get_fps() + 0.5 which surely not mean for accuracy.

Thus, to obtain the correct frame number you have to decode and read through the entire stream, or you have to ask the video generator to generate correct stream header with nb_frames field.

It is unfortunately to see after almost 10 years opencv still does not correct the implementation: we should use av_read_frame(fmt_ctx, &pkt) to read and parse all packet without actual decode them.

I personally stopped relies on opencv for video decoding more than 10 years ago, but recently I have to collaborate with some project using opencv to do so. I have to call ffprobe in a subprocess to get the correct frame counts:

ffprobe -v error -select_streams v:0 -count_packets -show_entries stream=nb_read_packets -of csv=p=0 input.mp4
2 of 3
9

CV_CAP_PROP_FRAME_COUNT gives the property of 'number of frames', that comes from the video header. The other number is basically "How many frames can I read from this video file?".

If the video contains frames that cannot be read/decoded (e.g., due to being corrupted), OpenCV skips those frames (after trying to read them) and gives you the next valid frame. So the difference between your two numbers is the number of frames that couldn't be read.

Also, if your video header is corrupted and/or cannot be parsed by the underlying codecs that OpenCV uses, then those numbers can be different too.

🌐
NVIDIA Developer Forums
forums.developer.nvidia.com › robotics & edge computing › jetson systems › jetson nano
Opencv Camera Properties : CAP_PROP_FOURCC Not working - Jetson Nano - NVIDIA Developer Forums
June 1, 2021 - One of my code related to Fiducial markers detection have following lines : codec = 0x47504A4D # MJPG cap.set(cv2.CAP_PROP_FPS, 30.0) cap.set(cv2.CAP_PROP_FOURCC, codec) cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1920) cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080) This parameter setting is working fine in other hardware platforms.
🌐
Raspberry Pi Forums
forums.raspberrypi.com › board index › programming › python
Cannot get frame from cv2 - Raspberry Pi Forums
June 17, 2023 - <class 'cv2.VideoCapture'> True 640 Traceback (most recent call last): File "/home/pi/./bodycam.py", line 21, in <module> cv2.imwrite("/home/pi/test.png", img) cv2.error: OpenCV(4.7.0) /io/opencv/modules/imgcodecs/src/loadsave.cpp:783: error: (-215:Assertion failed) !_img.empty() in function 'imwrite' So it means that the camera is opend and works but the cap.read() fails. I get the same error from lokal or ssh console. What could this be? Thanks? Edit: if I try fps = int(cap.get(cv2.CAP_PROP_FPS)) it gives me an error it can not get camera fps.
🌐
Stack Overflow
stackoverflow.com › questions › 70202515 › cv2-cap-getcv2-cap-prop-fps-returns-inf
python - cv2 cap.get(cv2.CAP_PROP_FPS) Returns 'inf' - Stack Overflow
Copyfps = cap.get(cv2.CAP_PROP_FPS) # fps = inf fc = cap.get(cv2.CAP_PROP_FRAME_COUNT) # fc = -9223372036854775808 · I found nothing on the internet. It's critical in my project :/ ... that is 0x8000_0000_0000_0000 or a float of -0.0. could be a bug, or an error.
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-get-properties-of-python-cv2-videocapture-object
How to get properties of Python cv2.VideoCapture object ? - GeeksforGeeks
July 23, 2025 - # importing cv2 import cv2 #For Video File #capture=cv2.VideoCapture("sample.webm") #For webcam capture=cv2.VideoCapture(0) # showing values of the properties print("CV_CAP_PROP_FRAME_WIDTH: '{}'".format(capture.get(cv2.CAP_PROP_FRAME_WIDTH))) print("CV_CAP_PROP_FRAME_HEIGHT : '{}'".format(capture.get(cv2.CAP_PROP_FRAME_HEIGHT))) print("CAP_PROP_FPS : '{}'".format(capture.get(cv2.CAP_PROP_FPS))) print("CAP_PROP_POS_MSEC : '{}'".format(capture.get(cv2.CAP_PROP_POS_MSEC))) print("CAP_PROP_FRAME_COUNT : '{}'".format(capture.get(cv2.CAP_PROP_FRAME_COUNT))) print("CAP_PROP_BRIGHTNESS : '{}'".format
🌐
GitHub
github.com › opencv › opencv-python › issues › 618
FPS returned as zero · Issue #618 · opencv/opencv-python
January 30, 2022 - cap = cv2.VideoCapture(test_video) fps = cap.get(cv2.CAP_PROP_FPS) This is supposed to return the fps of the video. However the fps it returns it zero as is clear from the ss below · video link: https://drive.google.com/file/d/10zkHWb0OseC1-EBYgaVFLDKx-CKDtk3c/view?usp=sharing ·
Author: opencv
🌐
GitHub
github.com › opencv › opencv › issues › 21673
cv::VideoCapture set cv::CAP_PROP_FPS is not working · Issue #21673 · opencv/opencv
March 2, 2022 - Please try to use some sample code to setup the fps for web cameras, like: #include "opencv2/videoio.hpp" cv::VideoCapture capture; capture.open("/dev/video0"); bool success = capture.isOpened(); if (success) { capture.set(cv::CAP_PROP_FPS, 25); }
🌐
OpenCV
forum.opencv.org › python
When cap.read() is not as fast as the FPS of a camera - Python - OpenCV
October 12, 2021 - Hello everyone. I have a question regarding the OpenCV VideoCapture class. Any answer will be helpful. Suppose that we have the following code import cv2 import time cap = cv2.VideoCapture('/dev/video0', cv2.V4L2) cap.set(cv2.CAP_PROP_FPS, 30.0) while True: ret, frame = cap.read() time.sleep(0.1) My question is that, what is actually happening inside the camera when the cap.read() loop is way slower than the actual FPS?
🌐
Reddit
reddit.com › r/computervision › speeding up frame capture in opencv
r/computervision on Reddit: Speeding up frame capture in opencv
January 15, 2020 -

I'm working on an application in python using opencv for use in athletic coaching. I'd like it to run at 60fps, but I can't seem to get it to that speed. I've determined that the part that is slowing everything down is the capture process; frames aren't getting from the camera to the cpu fast enough. All testing I've done so far indicates that the processing and the rendering are not the bottleneck; it's specifically the video input that is slowing everything down.

Now, I know it is possible for the camera to run at 60fps, because when I open up the same camera in guvcview (at the same resolution), I can get a full 60fps.

I don't want to share my entire project, but here's the part that manages frame capture: https://pastebin.com/nnx32rQK. My main app calls the get_frame() function in its own thread. I'm running this on an intel NUC6CAYH (celeron CPU, 2.3 ghz), running linux.

Any help would be welcome!

EDIT: I went into more detail below, but it looks like having the cap.read() within the Feed class is a whole lot slower than just accessing cap.read() directly..... and I have no idea why

🌐
OpenCV Q&A Forum
answers.opencv.org › question › 204632 › python-opencv-returns-wrong-fps
Python OpenCV returns wrong FPS - OpenCV Q&A Forum
December 3, 2018 - 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.