跳至主要內容

获取一个音频的时长

爱喝水的木子...小于 1 分钟pythonpythonpydub

安装依赖

pip install pydub

code

import os
import shutil

try:
    from pydub.utils import mediainfo
except:
    os.system("pip3 install pydub")
    from pydub.utils import mediainfo


def count_time(file_path):
    song = mediainfo(file_path)
    return float(song["duration"])
评论
  • 按正序
  • 按倒序
  • 按热度
Powered by Waline v3.1.3