【问题标题】:How to get the duration of any video file (.avi .mp4 .flv .mkv etc) using python script (in ubuntu)?如何使用 python 脚本(在 ubuntu 中)获取任何视频文件(.avi .mp4 .flv .mkv 等)的持续时间?
【发布时间】:2014-03-14 07:22:45
【问题描述】:

我有兴趣在 UBUNTU 中使用 python 脚本查找视频文件(常用格式)的持续时间。 我找到了代码:

def getLength(filename):
result = subprocess.Popen(["ffprobe", filename],
stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
return [x for x in result.stdout.readlines() if "Duration" in x]

但它在我的 UBUNTU BOX 上不起作用可能是因为缺少 ffprobe 或其他原因,我收到以下错误:

File "leng.py", line 8, in getLength
stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

我只想要持续时间,所以有没有更简单的方法或如何使上述代码工作 有什么简单的方法吗?

【问题讨论】:

    标签: python video ffmpeg ubuntu-12.04 ffprobe


    【解决方案1】:

    只需使用 ffmpeg 安装

    sudo apt-get install ffmpeg
    

    【讨论】:

      【解决方案2】:

      Ubuntu 默认带有 avconv 而不是 ffmpeg(ffmpeg 只是 avconv 的包装器)。

      您似乎都没有安装。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-04-10
        • 2021-10-08
        • 2014-11-04
        • 1970-01-01
        • 2013-08-11
        • 1970-01-01
        • 1970-01-01
        • 2012-04-28
        相关资源
        最近更新 更多