您好,登錄后才能下訂單哦!
如下所示:
1、計算總幀數
import os import cv2 video_cap = cv2.VideoCapture('ffmpeg_test.avi') frame_count = 0 all_frames = [] while(True): ret, frame = video_cap.read() if ret is False: break all_frames.append(frame) frame_count = frame_count + 1 # The value below are both the number of frames print frame_count print len(all_frames)
2、計算視頻中的FPS,即每秒傳輸幀數(Frames per second)
import cv2 if __name__ == '__main__' : video = cv2.VideoCapture("video.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();
以上這篇使用python-opencv讀取視頻,計算視頻總幀數及FPS的實現就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持億速云。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。