Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
191 views
in Technique[技术] by (71.8m points)

python - avoiding running of FFmpeg on terminal/cmd

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

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...