Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failing ffmpeg extension import Windows. #6870

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

silveroxides
Copy link
Contributor

Due to how comfy_extra nodes are imported as modules, importing of torchaudio_ffmpeg pyd libraries fails since there are no available dll libraries. That resulted in the error:

Loading FFmpeg6
Failed to load FFmpeg6 extension.
Traceback (most recent call last):
  File "C:\Users\ishim\Tools\ComfyUI\venv\Lib\site-packages\torio\_extension\utils.py", line 116, in _find_ffmpeg_extension
    ext = _find_versionsed_ffmpeg_extension(ffmpeg_ver)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ishim\Tools\ComfyUI\venv\Lib\site-packages\torio\_extension\utils.py", line 108, in _find_versionsed_ffmpeg_extension
    _load_lib(lib)
  File "C:\Users\ishim\Tools\ComfyUI\venv\Lib\site-packages\torio\_extension\utils.py", line 94, in _load_lib
    torch.ops.load_library(path)
  File "C:\Users\ishim\Tools\ComfyUI\venv\Lib\site-packages\torch\_ops.py", line 1357, in load_library
    ctypes.CDLL(path)
  File "C:\Program Files\Python312\Lib\ctypes\__init__.py", line 379, in __init__
    self._handle = _dlopen(self._name, mode)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: Could not find module 'C:\Users\ishim\Tools\ComfyUI\venv\Lib\site-packages\torio\lib\libtorio_ffmpeg6.pyd' (or one of its dependencies). Try using the full path with constructor syntax.

Which it repeats for version 5 and 4 as well.
This PR fixes this by adding paths in the "PATH" environment variable as dll library directories using os.add_dll_directory() which was introduced with Python version 3.8.

There might be need for some additions for conda environments but as I myself do not use this and it is not among the official methods of running ComfyUI apart from with Intel GPU, I leave the task of adding that to someone with the experience in that area.

Due to how comfy_extra nodes are imported as modules, importing of torchaudio_ffmpeg pyd libraries fails since there are no available dll libraries. That resulted in the error:
```
Loading FFmpeg6
Failed to load FFmpeg6 extension.
Traceback (most recent call last):
  File "C:\Users\ishim\Tools\ComfyUI\venv\Lib\site-packages\torio\_extension\utils.py", line 116, in _find_ffmpeg_extension
    ext = _find_versionsed_ffmpeg_extension(ffmpeg_ver)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ishim\Tools\ComfyUI\venv\Lib\site-packages\torio\_extension\utils.py", line 108, in _find_versionsed_ffmpeg_extension
    _load_lib(lib)
  File "C:\Users\ishim\Tools\ComfyUI\venv\Lib\site-packages\torio\_extension\utils.py", line 94, in _load_lib
    torch.ops.load_library(path)
  File "C:\Users\ishim\Tools\ComfyUI\venv\Lib\site-packages\torch\_ops.py", line 1357, in load_library
    ctypes.CDLL(path)
  File "C:\Program Files\Python312\Lib\ctypes\__init__.py", line 379, in __init__
    self._handle = _dlopen(self._name, mode)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: Could not find module 'C:\Users\ishim\Tools\ComfyUI\venv\Lib\site-packages\torio\lib\libtorio_ffmpeg6.pyd' (or one of its dependencies). Try using the full path with constructor syntax.
```
Which it repeats for version 5 and 4 as well.
This PR fixes this by adding paths in the "PATH" environment variable as dll library directories using os.add_dll_directory() which was introduced with Python version 3.8. 

There might be need for some additions for conda environments but as I myself do not use this and it is not among the official methods of running ComfyUI apart from with Intel GPU, I leave the task of adding that to someone with the experience in that area.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant