避免在终端/cmd上运行FFmpeg [英] avoiding running of FFmpeg on terminal/cmd

查看:40
本文介绍了避免在终端/cmd上运行FFmpeg的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将FFmpeg用于一个小项目,所以我构建了一个用于视频编辑的GUI基本应用程序这是图像

I'm using FFmpeg for a small project so I built a GUI basic application for video editing here 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 variable Please check the image for more info

推荐答案

我看到2种解决方案:

  1. 在没有控制台窗口的情况下运行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开始可用

  1. 为libffmpeg使用Python包装器,请参见: https://github.com/kkroening/ffmpeg-python 和许多示例.
  1. Using a Python wrapper for libffmpeg see for example: https://github.com/kkroening/ffmpeg-python with many examples.

这篇关于避免在终端/cmd上运行FFmpeg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆