我想在Python中通过命令行运行命令。当我打开cmd并发出以下命令时,它将起作用:
ffmpeg -f concat -safe 0 -i C:\test\test.txt -c copy C:\test\out.MP4
现在,我尝试通过以下方式在Python中运行它:
from subprocess import check_call
concat_list = "C:\\test\\test.txt"
out_file = "C:\\test\\out.MP4"
check_call(["ffmpeg", "-f", "concat", "-safe", "0", "-i", concat_list, "-c", "copy", out_file])
执行此操作时,出现错误“ FileNotFoundError:[WinError 2]系统找不到指定的文件”。
我怎么了?
完整的错误消息是:
'ffmpeg' is not recognized as an internal or external command,
operable program or batch file.
Traceback (most recent call last):
File "C:/Users/xxx/Desktop/xxx/trunk/python/xxx/src/videos/processVideo.py", line 48, in <module>
check_call(["ffmpeg", "-f", "concat", "-safe", "0", "-i", concat_list, "-c", "copy", out_file])
File "C:\Users\xxx\AppData\Local\Continuum\anaconda3\lib\subprocess.py", line 336, in check_call
retcode = call(*popenargs, **kwargs)
File "C:\Users\xxx\AppData\Local\Continuum\anaconda3\lib\subprocess.py", line 317, in call
with Popen(*popenargs, **kwargs) as p:
File "C:\Users\xxx\AppData\Local\Continuum\anaconda3\lib\subprocess.py", line 769, in __init__
restore_signals, start_new_session)
File "C:\Users\xxx\AppData\Local\Continuum\anaconda3\lib\subprocess.py", line 1172, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified