avoiding running of FFmpeg on terminal/cmd

老子叫甜甜 提交于 2021-01-28 03:50:00

问题


I'm using FFmpeg for a small project so I built a GUI basic application for video editing here is the image

Everything is working fine but I just want to avoid opening the terminal for the FFmpeg process the reason the terminal is opening is because

I used os.system("FFmpeg command here")

so is there a way to import FFmpeg completely and avoid using terminal and run in code
if u have any idea please suggest and let me know
for gui i used PYQT5 and python to code
Thank you

Tried using subprogram but didn't work (worked for normal commands but not for ffmpeg) I need the output to print also to store in a python variable Please check the image for more info


回答1:


I see 2 options to solve this:

  1. Running the ffmpeg command without console window. You can achieve this by using subprocess.run with the CREATE_NO_WINDOW flag, as:
    import subprocess
    
    subprocess.run(["path/to/ffmpeg", "arg1", "arg2"],
    creationflags=subprocess.CREATE_NO_WINDOW)

Note that the CREATE_NO_WINDOW flag is only available since Python 3.7

  1. Using a Python wrapper for libffmpeg see for example: https://github.com/kkroening/ffmpeg-python with many examples.



回答2:


Can you try appending '-hide_banner -loglevel warning' to your command?

os.system("FFmpeg command here -hide_banner -loglevel warning")

You can always redirect to /dev/null

os.system('FFmpeg command here 2> /dev/null')


来源:https://stackoverflow.com/questions/65679936/avoiding-running-of-ffmpeg-on-terminal-cmd

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