ffmpeg查看音频文件信息

时间:2023-01-22 06:58:27

查看音频文件的信息(基于本地路径)

import subprocess
import json
path = r'D:\learn\download\NosVJ60QCIs0b8PVHMPomZJsrFU2b8eRnuiZp9yz.aac'
command = (r'ffprobe -print_format json -loglevel quiet -show_streams %s'%path)
result = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
out = result.stdout.read()
temp = str(out.decode('utf-8'))
print(json.loads(temp))

也可以把本地路径换成文件的url地址

command = ["ffprobe.exe", "-loglevel", "quiet", "-print_format", "json", "-show_format", "-show_streams", "-i",
r'https://imglive.ehafo.com/course/temp/2019/02/ZlliRoa7fPPgofrGP2okVVBjgh3k43P518sw1AUd.aac']