Python OpenCV video.get(cv2.CAP_PROP_FPS)返回0.0 FPS

问题描述 投票:3回答:1

这是我的视频

enter image description here

这是查找fps的脚本:

import cv2
if __name__ == '__main__' :

    video = cv2.VideoCapture("test.mp4");

    # Find OpenCV version
    (major_ver, minor_ver, subminor_ver) = (cv2.__version__).split('.')

    if int(major_ver)  < 3 :
        fps = video.get(cv2.cv.CV_CAP_PROP_FPS)
        print "Frames per second using video.get(cv2.cv.CV_CAP_PROP_FPS): {0}".format(fps)
    else :
        fps = video.get(cv2.CAP_PROP_FPS)
        print "Frames per second using video.get(cv2.CAP_PROP_FPS) : {0}".format(fps)

    video.release(); 

这是此视频脚本的输出:Frames per second using video.get(cv2.CAP_PROP_FPS) : 0.0

为什么它返回0.0? FPS是14.0

python opencv mp4 frame-rate
1个回答
3
投票

执行pip install python-opencv修复了问题并正确检测到FPS。

© www.soinside.com 2019 - 2024. All rights reserved.