如何使用Python
执行以下linux命令行命令mplayer -identify -frames 0 -vo null -nosound metallica.mp4 2>&1 | awk -F= '/LENGTH/{print $2}'
我试过
p1 = subprocess.Popen(["mplayer","-identify","-frames","0","-vo","null","-nosound","test1.mp4","2>&1"], stdout=subprocess.PIPE)
p2 = subprocess.Popen(["awk","-F","'/LENGTH/{print $2}'"], stdin=p1.stdout, stdout=subprocess.PIPE)
p2.communicate()
上面的
我收到以下错误mplayer:无法连接到套接字mplayer:没有这样的文件或 目录无法打开LIRC支持。你将无法使用 你的遥控器。
请帮助
答案 0 :(得分:0)
import subprocess
cmdline = "mplayer -identify -frames 0 -vo null -nosound metallica.mp4 2>&1 | awk -F= '/LENGTH/{print $2}'"
p1 = subprocess.Popen(cmdline, shell=True, stdout=subprocess.PIPE)
print(p1.communicate())