update:ffmpeg依赖检查 (#162)

Co-authored-by: hrz <1710360675@qq.com>
This commit is contained in:
欣南科技
2025-03-01 17:09:01 +08:00
committed by GitHub
co-authored by hrz
parent b94842c312
commit b486599ab8
6 changed files with 70 additions and 17 deletions
+27
View File
@@ -3,6 +3,7 @@ import re
import json
import yaml
import socket
import subprocess
def get_project_dir():
@@ -114,3 +115,29 @@ def check_password(password):
# 如果满足所有条件,则返回True
return True
def check_ffmpeg_installed():
ffmpeg_installed = False
try:
# 执行ffmpeg -version命令,并捕获输出
result = subprocess.run(
['ffmpeg', '-version'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
check=True # 如果返回码非零则抛出异常
)
# 检查输出中是否包含版本信息(可选)
output = result.stdout + result.stderr
if 'ffmpeg version' in output.lower():
ffmpeg_installed = True
return False
except (subprocess.CalledProcessError, FileNotFoundError):
# 命令执行失败或未找到
ffmpeg_installed = False
if not ffmpeg_installed:
error_msg = "您的电脑还没正确安装ffmpeg\n"
error_msg += "\n建议您:\n"
error_msg += "1、按照项目的安装文档,正确进入conda环境\n"
error_msg += "2、查阅安装文档,如何在conda环境中安装ffmpeg\n"
raise ValueError(error_msg)