引言
ComfyUI 是一个功能强大的 AI 图像框架,但在启动过程中可能会遇到 FFmpeg 和 Git 相关错误,导致音频/视频处理或仓库操作受阻。本文基于实际案例,结合完整的环境信息、错误提示和解决方案,详细总结如何修复这些问题,并提供优化建议。无论您是新手还是有经验的用户,本指南都能帮助您快速恢复 ComfyUI 的正常运行。
笔者运行环境
-
操作系统:Windows 11
-
Python 版本:3.12.9(Anaconda 打包)
-
Python 可执行文件 :
E:\anaconda3\envs\ComfyUI\python.exe
-
ComfyUI 版本:0.3.27
-
PyTorch 版本:2.8.0.dev20250414+cu128
-
硬件:
- CPU:Intel(R) Core(TM) i9-14900K
- GPU:NVIDIA GeForce RTX 5090(VRAM 32607 MB)
- 内存:97988 MB
-
启动命令:
csspython.exe -s ComfyUI\main.py --windows-standalone-build --use-sage-attention --fast --input-directory "E:\AI\Input" --output-directory "E:\AI\Output" --verbose DEBUG
环境解释由于从40显卡过渡到50,遭遇了很多糟心事从驱动问题到各种插件的问题,最后由于我经常编程,发觉我自己也可以用Anaconda自己来觉得Python问题,而且经过我的测试这比你不熟悉python原理乱用内嵌环境,最后造成本地Python环境污染强的多。所以如果你还是用内嵌Python运行ComfyUI的,请注意相关命令的执行环境。
问题一:FFmpeg 扩展加载失败
错误提示
启动 ComfyUI 时,日志显示以下错误:
arduino
Loading FFmpeg6
Failed to load FFmpeg6 extension.
Traceback (most recent call last):
File "E:\anaconda3\envs\ComfyUI\Lib\site-packages\torio_extension\utils.py", line 116, in _find_ffmpeg_extension
ext = _find_versionsed_ffmpeg_extension(ffmpeg_ver)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\anaconda3\envs\ComfyUI\Lib\site-packages\torio_extension\utils.py", line 108, in _find_versionsed_ffmpeg_extension
_load_lib(lib)
File "E:\anaconda3\envs\ComfyUI\Lib\site-packages\torio_extension\utils.py", line 94, in _load_lib
torch.ops.load_library(path)
File "E:\anaconda3\envs\ComfyUI\Lib\site-packages\torch_ops.py", line 1412, in load_library
ctypes.CDLL(path)
File "E:\anaconda3\envs\ComfyUI\Lib\ctypes__init__.py", line 379, in __init__
self._handle = _dlopen(self._name, mode)
^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: Could not find module 'E:\anaconda3\envs\ComfyUI\Lib\site-packages\torio\lib\libtorio_ffmpeg6.pyd' (or one of its dependencies). Try using the full path with constructor syntax.
类似错误也出现在 FFmpeg5、FFmpeg4 和通用 FFmpeg 加载尝试中,最终抛出:
vbnet
RuntimeError: FFmpeg extension is not available.
此外,WAS Node Suite 扩展提示:
r
WAS Node Suite Warning: `ffmpeg_bin_path` is not set in `E:\AI\ComfyUI\ComfyUI\custom_nodes\was-node-suite-comfyui\was_suite_config.json` config file. Will attempt to use system ffmpeg binaries if available.
错误原因
- FFmpeg 扩展加载失败是因为
torio
(torchaudio
的一部分)无法找到 FFmpeg 动态库,可能是未安装 FFmpeg 或版本不兼容。 torio
按顺序尝试加载 FFmpeg 6、5、4 版本的扩展,若均失败则抛出RuntimeError
。- WAS Node Suite 警告表明未明确指定 FFmpeg 可执行文件路径,可能导致视频处理功能不稳定。
- 尝试安装 FFmpeg 7.0.1 后仍失败,表明
torio
不支持 7.x 版本。
解决方案
1. 安装 FFmpeg 6.1
-
激活 ComfyUI 环境:
conda activate ComfyUI
-
安装 FFmpeg 6.1(与
torio
兼容):iniconda install -c conda-forge ffmpeg=6.1
-
验证安装:
ffmpeg -version
应输出类似:
ffmpeg version 6.1.1
2. 配置 WAS Node Suite 的 FFmpeg 路径
-
打开配置文件:
makefileE:\AI\ComfyUI\ComfyUI\custom_nodes\was-node-suite-comfyui\was_suite_config.json
-
添加或修改:
json{ "ffmpeg_bin_path": "E:\anaconda3\envs\ComfyUI\Library\bin\ffmpeg.exe" }
-
确认 FFmpeg 路径:
bashwhere ffmpeg
确保输出包含
E:\anaconda3\envs\ComfyUI\Library\bin\ffmpeg.exe
。
3. 验证修复
-
重启 ComfyUI:
bashcd E:\AI\ComfyUI python.exe -s ComfyUI\main.py --windows-standalone-build --use-sage-attention --fast --input-directory "E:\AI\Input" --output-directory "E:\AI\Output" --verbose DEBUG
-
检查日志,确认出现:
luaLoading FFmpeg6 Successfully loaded FFmpeg6
以及:
pythonWAS Node Suite: `ffmpeg_bin_path` is set to: E:\anaconda3\envs\ComfyUI\Library\bin\ffmpeg.exe
4. 测试音频/视频功能
- 打开 ComfyUI GUI(
http://127.0.0.1:8188
)。 - 使用视频处理节点(如
comfyui-videohelpersuite
的Load Video
和Save Video
节点)测试工作流,确保无 FFmpeg 相关错误。
注意事项
-
版本选择 :FFmpeg 7.x 与
torio
不兼容,优先选择 6.x(如 6.1)。 -
手动安装备选:
- 下载 FFmpeg 6.x(gyan.dev 的
ffmpeg-release-full
)。 - 解压到
E:\ffmpeg
,将E:\ffmpeg\bin
添加到系统 PATH。 - 更新
was_suite_config.json
的ffmpeg_bin_path
为E:\ffmpeg\bin\ffmpeg.exe
。
- 下载 FFmpeg 6.x(gyan.dev 的
-
Conda 问题 :若
conda install
失败,清理缓存(conda clean --all
)或重建环境:iniconda deactivate conda env remove -n ComfyUI conda create -n ComfyUI python=3.12 conda activate ComfyUI pip install -r E:\AI\ComfyUI\requirements.txt
问题二:Git 拥有权警告
错误提示
启动 ComfyUI 时,日志显示以下警告:
swift
AutoInterrupt wait stderr: b"fatal: detected dubious ownership in repository at 'E:/AI/ComfyUI/ComfyUI'\n'E:/AI/ComfyUI/ComfyUI' is owned by:\n\t(inconvertible) (S-1-5-21-505282455-2854907582-648027609-1001)\nbut the current user is:\n\tROG-5090/berryyan (S-1-5-21-597162383-2275910696-3619708607-1001)\nTo add an exception for this directory, call:\n\n\tgit config --global --add safe.directory E:/AI/ComfyUI/ComfyUI\n"
错误原因
- Git 2.35.2+ 版本引入了安全机制,检查仓库目录的拥有者是否与当前用户匹配。若不匹配,Git 标记仓库为不可信,触发警告。
- 警告可能影响 ComfyUI 的 Git 操作(如检查版本或更新节点),但不影响核心功能。
解决方案
1. 将仓库添加到安全目录
-
运行以下命令:
javascriptgit config --global --add safe.directory E:/AI/ComfyUI/ComfyUI
-
验证配置:
cssgit config --global --list
确认输出包含:
inisafe.directory=E:/AI/ComfyUI/ComfyUI
2. 验证修复
-
重启 ComfyUI,检查日志是否仍包含:
vbnetfatal: detected dubious ownership in repository at 'E:/AI/ComfyUI/ComfyUI'
-
确认 Git 命令正常运行(如
git status
或日志中的Popen(['git', 'rev-list', 'HEAD', '--']
)。
注意事项
-
确保
E:/AI/ComfyUI/ComfyUI
目录安全,避免信任不可信的仓库。 -
如遇权限问题,以管理员身份运行命令提示符:
javascriptcd E:\AI\ComfyUI git config --global --add safe.directory E:/AI/ComfyUI/ComfyUI
-
优化 Conda 环境:
-
清理缓存:
cssconda clean --all
-
更新 Conda:
sqlconda update conda
-
精简频道配置:
luaconda config --remove-key channels conda config --add channels conda-forge conda config --add channels defaults conda config --set channel_priority strict
-
总结
通过以上步骤,您可以彻底解决 ComfyUI 的 FFmpeg 和 Git 错误,确保音频/视频处理和仓库操作正常运行。以下是快速参考:
-
FFmpeg 错误:
- 安装 FFmpeg 6.1(
conda install -c conda-forge ffmpeg=6.1
)。 - 配置
was_suite_config.json
的ffmpeg_bin_path
。 - 验证日志显示
Successfully loaded FFmpeg6
。
- 安装 FFmpeg 6.1(
-
Git 警告:
- 添加安全目录(
git config --global --add safe.directory E:/AI/ComfyUI/ComfyUI
)。 - 确认日志无警告。
- 添加安全目录(
-
优化:
- 减少节点,优化 Conda 环境。
将此指南分享给其他 ComfyUI 用户,帮助他们快速解决类似问题。定期维护节点和环境配置,保持系统高效稳定!