opencv可以去讀.mp4視頻的常用屬性,參數(shù)詳見https://blog.csdn.net/u011436429/article/details/80604590
import os
from os import path
import cv2
# 子文件夾
sub = 'ykt.eduyun.cn'
path='G:/CRSR/test_seq/'+sub
videoList = os.listdir(path)
framenum=[]
fps=[]
width=[]
height=[]
for name in videoList:
cap=cv2.VideoCapture(path+'/'+name)
framenum.append(cap.get(7)) # 讀取幀數(shù)
fps.append(cap.get(5)) # 讀取幀率
height.append(cap.get(4)) # 讀取高度
width.append(cap.get(3)) # 讀取寬度
f=open('G:/CRSR/test_seq/'+sub+'_framenum.txt','w')
for i in range(len(framenum)):
f.write(sub+'\t'+videoList[i]+'\t'+str(width[i])+'x'+str(height[i])+'\t'+str(framenum[i])+'\t'+str(fps[i])+'\n')
其中寫入了.txt文件中,全選復(fù)制到excel中即可生成表格。(因?yàn)閑xcel表格中相鄰元素使用\t隔開)