小编Man*_*sha的帖子

视频Python的帧率

代码:

    import cv2
    import numpy as np
    import sys
    import webcolors
    import time

    cam=cv2.VideoCapture('video2.avi')
    _, fo = cam.read()
    framei = cv2.cvtColor(fo, cv2.COLOR_BGR2GRAY)
    bg_avg = np.float32(framei)
    video_width = int(cam.get(3))
    video_height = int(cam.get(4))
    fr = int(cam.get(5))
    print("frame rate of stored video:::",fr)

    while(cam.isOpened): 
           f,img=cam.read()
           start_fps=time.time()
           .
           .
           .
           k = cv2.waitKey(20)
           if(k == 27):
               break
         endtime_fps=time.time()
         diff_fps=endtime_fps-start_fps
         print("Frame rate::",1/diff_fps)
Run Code Online (Sandbox Code Playgroud)

随着每一次迭代,这个打印不同的帧速率,如:31.249936670193268,76.92300920661702,142.85290010558222,166.67212398172063,200.00495922941204,38.46150460330851 ......等与正在反复几次后一些值。现在存储的视频的帧率值为 25。那么它被读取的实际帧率是多少?

video time frame-rate python-2.7

5
推荐指数
2
解决办法
7811
查看次数

标签 统计

frame-rate ×1

python-2.7 ×1

time ×1

video ×1