avoiding running of FFmpeg on terminal/cmd

Viewed 426

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

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

enter image description here

2 Answers

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.

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')
Related