-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
30 lines (26 loc) · 885 Bytes
/
utils.py
File metadata and controls
30 lines (26 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# -*- coding = utf-8 -*-
# @Author : Grace
# @Description : Utility functions
import os
import subprocess
import imageio_ffmpeg # [新增] 引入库
# --- [新增] 获取 FFmpeg 可执行文件路径 ---
def get_ffmpeg_path():
"""
获取 imageio-ffmpeg 自带的 ffmpeg 可执行文件路径。
这样用户无需手动安装 ffmpeg 环境变量。
"""
try:
path = imageio_ffmpeg.get_ffmpeg_exe()
return path
except Exception as e:
# 如果获取失败,返回默认命令,寄希望于系统环境变量
print(f"Error finding bundled ffmpeg: {e}")
return 'ffmpeg'
# --- 辅助:Windows下隐藏控制台 ---
def get_subprocess_flags():
if os.name == 'nt':
info = subprocess.STARTUPINFO()
info.dwFlags |= subprocess.STARTF_USESHOWWINDOW
return subprocess.CREATE_NO_WINDOW
return 0