2014-02-14 52 views
1

我感興趣的是在UBUNTU中使用python腳本查找視頻文件(常用格式)的持續時間。 我發現代碼:如何使用python腳本(在ubuntu中)獲取任何視頻文件(.avi .mp4 .flv .mkv等)的持續時間?

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 

我只希望時間那麼有沒有更簡單的方法或如何使上述代碼工作 有什麼簡單的方法嗎?

回答

2

剛剛安裝的ffmpeg與

sudo apt-get install ffmpeg 
0

Ubuntu自帶的默認,而不是ffmpeg的avconv(ffmpeg的僅僅是avconv的包裝)。

看來你還沒有安裝。

相關問題