标签:rate pipe 使用 probe file imp desktop ret str
import subprocess
import re
def get_length(filename):
result = subprocess.Popen(["ffprobe", filename],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
for x in result.stdout.readlines():
if b"Duration" in x:
print(x)
x = re.search(rb"Duration.+?\d{2}:(\d{2}):\d{2}", x)
return int(x.group(1))
print(get_length(r"C:\Users\Administrator\Desktop\1.mp4"))
‘‘‘
b‘ Duration: 00:17:25.00, start: 0.000000, bitrate: 507 kb/s\r\n‘
17
‘‘‘
标签:rate pipe 使用 probe file imp desktop ret str
原文地址:https://www.cnblogs.com/traditional/p/9538205.html