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

时间:2018-02-28 09:13:06

标签: python opencv mp4 frame-rate

这是我的视频

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

1 个答案:

答案 0 :(得分:4)

执行iex(2)> 1..5 |> (fn x -> for(i <- x, do: IO.puts(i)) end).() 1 2 3 4 5 [:ok, :ok, :ok, :ok, :ok] 修复问题并正确检测到FPS。