如何在python中使用cv2知道文件中的帧总数 [英] How to know total number of Frame in a file with cv2 in python

查看:33
本文介绍了如何在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆