如何从python传递命令到应用程序 [英] How to pass commands to an application from python
问题描述
我试图从python运行ffmpeg应用程序。我使用以下代码执行应用程序
I am trying to run ffmpeg application from python.I am using the following code to execute the application
import subprocess
subprocess.call(['C:/ffmpeg/bin/ffmpeg.exe'])
import subprocess
subprocess.call(['C:/ffmpeg/bin/ffmpeg.exe'])
应用程序正在执行。可以有人告诉我如何传递命令到应用程序,我尝试
by this command the application is getting executed. could somebody tell me how can i pass commands to the application, i tried
subprocess.call(['C:/ ffmpeg / bin / ffmpeg.exe','ffmpeg -i 2.mp4 -vn -ab 128 outputaudio.mp3'])
subprocess.call(['C:/ffmpeg/bin/ffmpeg.exe','ffmpeg -i 2.mp4 -vn -ab 128 outputaudio.mp3'])
。
推荐答案
它们需要是单独的参数:
They need to be individual args:
subprocess.check_call(['C:/ffmpeg/bin/ffmpeg.exe','ffmpeg','-i',"2.mp4","-vn", "-ab", "128", "outputaudio.mp3"])
也可以使用 check_call
而不是调用
, check_call
将引发CalledProcessError,如果命令返回非零退出状态。
我不确定'ffmpeg'
应该在那里。
Also use check_call
instead of call
, check_call
will raise a CalledProcessError if the command returns a non-zero exit status.
I am not sure the 'ffmpeg'
should be there.
这篇关于如何从python传递命令到应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!