我想要做的是在Python中打开一个ffmpeg进程。我的代码看起来像这样:
import subprocess
import os
def Main():
ffmpeg = "C:\ffmpeg\bin\ffmpeg.exe"
args = " -i C:\video.mp4 -r 1 -f image2 C:\FRAMES\frame-%03d.jpg"
subprocess.Popen(ffmpeg + args).wait()
Main()
但即使是在这种简单的形式中,我总是得到同样的错误:
Traceback (most recent call last):
File "C:/Users/Francesco/Desktop/test.py", line 9, in <module>
Main()
File "C:/Users/Francesco/Desktop/test.py", line 7, in Main
subprocess.Popen(ffmpeg + args).wait()
File "C:\Users\Francesco\Desktop\WinPython-64bit-2.7.9.4\python-2.7.9.amd64\lib\subprocess.py", line 710, in __init__
errread, errwrite)
File "C:\Users\Francesco\Desktop\WinPython-64bit-2.7.9.4\python-2.7.9.amd64\lib\subprocess.py", line 958, in _execute_child
startupinfo)
WindowsError: [Error 2] Impossibile trovare il file specificato
>>>
怎么了?
答案 0 :(得分:0)
你需要逃避反斜杠并在两个
之间留出空格%s
但是,这不是推荐的方法。 您应该有一个列表,您将其作为args而不是字符串传递。
ffmpeg = "C:\\ffmpeg\\bin\\ffmpeg.exe "
args = " -i C:\\video.mp4 -r 1 -f image2 C:\\FRAMES\\frame-%03d.jpg"