Python Popen - env - ffmpeg crash

送分小仙女□ 提交于 2019-12-23 02:28:17

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!