如何在python中使用cv2知道文件中帧的总数 [英] How to know total number of Frame in a file with cv2 in python
本文介绍了如何在python中使用cv2知道文件中帧的总数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用开放式cv模块通过Python知道文件(.avi)中的帧总数.
How to know total number of Frame in a file ( .avi) through Python using open cv module.
如果可能的话,我们可以从中获得视频文件的所有信息(分辨率,fps,持续时间等).
If possible what all the information (resolution, fps,duration,etc) we can get of a video file through this.
推荐答案
使用更新的OpenCV版本(我使用3.1.0),它的工作方式如下:
With a newer OpenCV version (I use 3.1.0) it works like this:
import cv2
cap = cv2.VideoCapture("video.mp4")
length = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
print( length )
和其他视频属性cv2.CAP_PROP_*
这篇关于如何在python中使用cv2知道文件中帧的总数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文