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();
 

友情链接
KaDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:637538335
关注微信