问题
I am trying to run an ffmpeg command on Windows 7 (python 2.7) which runs on command line just fine, but the env
of my Popen
is not working.
Here is the working command line:
SET FFREPORT=level=48:file=C\:\\temp\\TESTFFMPEGOUTPUT.txt && C:\Temp\ffmpeg\ffmpeg.exe -i “I:\somefolder\testInput.mov" "I:\somefolder\testOutput.mov"
And here is my current python code:
ffreport = "level=48:file={}".format(self.logFilePath) + " && "
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
self.process1 = Popen(command, startupinfo=startupinfo, shell=False, env={'SET FFREPORT':ffreport})
This results in windows reporting "ffmpeg has stopped working". Not sure how to fix.
回答1:
command = r"C:\Temp\ffmpeg\ffmpeg.exe -i I:\somefolder\testInput.mov I:\somefolder\testOutput.mov"
self.process1 = Popen(
shlex.split(command), shell=False,
env=dict(FFREPORT="level=48:file=C\:\\temp\\TESTFFMPEGOUTPUT.txt"))
回答2:
How about this?
using os.startfile(path[, operation])
https://docs.python.org/3/library/os.html#os.startfile
来源:https://stackoverflow.com/questions/28048602/python-popen-env-ffmpeg-crash