我一直試圖解決這個問題永遠現在(我是編程新手),我無法弄清楚。使用Python獲取FFProbe信息
我試圖建立一個腳本來測試這個文件,並給我輸出從那裏我可以得到像「音頻格式」,然後我可以放入文件名。但是,我甚至無法讓腳本返回任何文件信息。我在插入輸入文件時碰到了一堵牆...
所以在這一點上,我只需要幫助讓它吐出基於我所引入的argvs的信息。希望我能夠了解如何從中解析音頻信息。
我的企圖,這似乎是接近:
#!/usr/bin/python
import os, sys, subprocess, shlex, re
from subprocess import call
def probe_file(filename):
p = subprocess.Popen(['/opt/local/bin/ffprobe', '-show_format', '-pretty', '-loglevel quiet', -i filename], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
print filename
print p.communicate()
[probe_file (f) for f in os.listdir('.') if not f.startswith('.')]
我得到'...'的/ opt/local/bin目錄/ ffprobe: \ n「) – 2012-03-27 20:14:38
@RobinHood這意味着您沒有將正確的參數傳遞給ffprobe,首先嚐試查看如何從命令行正確使用ffprobe,然後將其轉換爲python – 2012-03-27 20:21:32
命令'/opt/local/bin/ffprobe -pretty -i'foo.avi''返回信息;命令'/ opt/local/bin/ffprobe -pretty -i'foo.avi'\ n'不是;但我無法弄清楚究竟是什麼加入了'\ n' – 2012-03-27 20:47:15