我有兴趣在 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
我只想要持续时间,所以有没有更简单的方法或如何使上述代码工作有没有简单的方法?