mirror of
https://github.com/JefferyHcool/BiliNote.git
synced 2026-06-09 01:29:55 +08:00
@@ -14,7 +14,17 @@ def check_ffmpeg_exists() -> bool:
|
|||||||
logger.info(f"FFMPEG_BIN_PATH: {ffmpeg_bin_path}")
|
logger.info(f"FFMPEG_BIN_PATH: {ffmpeg_bin_path}")
|
||||||
if ffmpeg_bin_path and os.path.isdir(ffmpeg_bin_path):
|
if ffmpeg_bin_path and os.path.isdir(ffmpeg_bin_path):
|
||||||
os.environ["PATH"] = ffmpeg_bin_path + os.pathsep + os.environ.get("PATH", "")
|
os.environ["PATH"] = ffmpeg_bin_path + os.pathsep + os.environ.get("PATH", "")
|
||||||
logger.info(f"ffmpeg 未配置路径,尝试使用系统路径PATH: {os.environ.get('PATH')}")
|
logger.info(f"使用FFMPEG_BIN_PATH: {ffmpeg_bin_path}")
|
||||||
|
else:
|
||||||
|
# 遍历系统PATH寻找ffmpeg.exe
|
||||||
|
system_path = os.environ.get("PATH", "")
|
||||||
|
path_dirs = system_path.split(os.pathsep)
|
||||||
|
for path_dir in path_dirs:
|
||||||
|
ffmpeg_exe_path = os.path.join(path_dir, "ffmpeg.exe")
|
||||||
|
if os.path.isfile(ffmpeg_exe_path):
|
||||||
|
os.environ["PATH"] = path_dir + os.pathsep + system_path
|
||||||
|
logger.info(f"在系统PATH中找到ffmpeg: {path_dir}")
|
||||||
|
break
|
||||||
try:
|
try:
|
||||||
subprocess.run(["ffmpeg", "-version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
|
subprocess.run(["ffmpeg", "-version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
|
||||||
logger.info("ffmpeg 已安装")
|
logger.info("ffmpeg 已安装")
|
||||||
@@ -36,4 +46,4 @@ def ensure_ffmpeg_or_raise():
|
|||||||
"🪟 Windows 推荐:https://www.gyan.dev/ffmpeg/builds/\n"
|
"🪟 Windows 推荐:https://www.gyan.dev/ffmpeg/builds/\n"
|
||||||
"💡 如果你已安装,请将其路径写入 `.env` 文件,例如:\n"
|
"💡 如果你已安装,请将其路径写入 `.env` 文件,例如:\n"
|
||||||
"FFMPEG_BIN_PATH=/your/custom/ffmpeg/bin"
|
"FFMPEG_BIN_PATH=/your/custom/ffmpeg/bin"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user