问题描述
我正在将FFmpeg用于一个小项目,所以我构建了一个用于视频编辑的GUI基本应用程序这是图像
I'm using FFmpeg for a small project so I built a GUI basic application for video editinghere is the image
一切正常,但我只想避免为FFmpeg进程打开终端,原因是终端打开是因为
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")
所以有一种方法可以完全导入FFmpeg并避免使用终端并在代码中运行
如果您有任何想法,请提出建议,并让我知道
对于gui,我使用了PYQT5和python进行编码
谢谢
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
尝试使用子程序但不起作用(适用于普通命令但不适用于ffmpeg)我需要输出也要打印以存储在python变量中请检查图片以获取更多信息
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 variablePlease check the image for more info
推荐答案
我看到2种解决方案:
- 在没有控制台窗口的情况下运行ffmpeg命令.您可以通过使用带有CREATE_NO_WINDOW标志的subprocess.run来实现此目标,如下所示:
import subprocess
subprocess.run(["path/to/ffmpeg", "arg1", "arg2"],
creationflags=subprocess.CREATE_NO_WINDOW)
请注意,CREATE_NO_WINDOW标志仅从Python 3.7开始可用
- 为libffmpeg使用Python包装器,请参见: https://github.com/kkroening/ffmpeg-python 和许多示例.
- Using a Python wrapper for libffmpeg see for example: https://github.com/kkroening/ffmpeg-python with many examples.
这篇关于避免在终端/cmd上运行FFmpeg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!