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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Torchaudio is not detecting FFmpeg #3789

Open
ruliworst opened this issue May 13, 2024 · 2 comments
Open

Torchaudio is not detecting FFmpeg #3789

ruliworst opened this issue May 13, 2024 · 2 comments

Comments

@ruliworst
Copy link

馃悰 Describe the bug

Hi everyone,

I am trying to use torchaudio with FFmpeg but for some reason it is not being detected.

import torchaudio
print(torchaudio.list_audio_backends())

ffmpeg
ffmpeg files

I added the path 'C:\Program Files\ffmpeg\bin' to the PATH environment variable. As you can see I can execute ffmpeg from cmd. However, when I execute torchaudio.list_audio_backends() only 'soundfile' is detected. I tested this in a Python PIP (I can't use conda) virtual environment with version 3.10 and in another one with version 3.12 but, it didn't work in both. Torchaudio and torch versions are 2.2.1. I don't know if it is a problem with version compatibility but in the official documentation I saw ffmpeg 6 is supported and I checked the code which tries to load the libraries.

I checked a lot of related issues but I couldn't find the right solution.

Any suggestions are welcome!
Thanks.

Versions

Collecting environment information...

PyTorch version: 2.2.1+cpu
Is debug build: False
CUDA used to build PyTorch: Could not collect
ROCM used to build PyTorch: N/A
OS: Microsoft Windows Server 2022 Standard
GCC version: Could not collect
Clang version: Could not collect
CMake version: Could not collect
Libc version: N/A

Python version: 3.10.7 (tags/v3.10.7:6cc6b13, Sep  5 2022, 14:08:36) [MSC v.1933 64 bit (AMD64)] (64-bit runtime)
Python platform: Windows-10-10.0.20348-SP0
Is CUDA available: False
CUDA runtime version: 12.3.103
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: GPU 0: NVIDIA A100-PCIE-40GB
Nvidia driver version: 546.12
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
'wmic' is not recognized as an internal or external command,
operable program or batch file.

Versions of relevant libraries:

[pip3] numpy==1.26.4
[pip3] pytorch-lightning==2.2.4
[pip3] pytorch-metric-learning==2.5.0
[pip3] torch==2.2.1
[pip3] torch-audiomentations==0.11.1
[pip3] torch-pitch-shift==1.2.4
[pip3] torchaudio==2.2.1
[pip3] torchmetrics==1.4.0
[conda] Could not collect
@ruliworst
Copy link
Author

ruliworst commented May 16, 2024

Loading manullay the binaries is working but, I would like it was automatic.

ctypes.CDLL('C:/Program Files/ffmpeg/bin/avcodec-60.dll')
ctypes.CDLL('C:/Program Files/ffmpeg/bin/avdevice-60.dll')
ctypes.CDLL('C:/Program Files/ffmpeg/bin/avfilter-9.dll')
ctypes.CDLL('C:/Program Files/ffmpeg/bin/avformat-60.dll')
ctypes.CDLL('C:/Program Files/ffmpeg/bin/avutil-58.dll')

I still don't know why it is not working without preloading libraries.

@ruliworst
Copy link
Author

ruliworst commented May 16, 2024

If I locate the libraries in the same folder of libtorio_ffmpeg6.pyd , they are detected while importing. That is, in Lib/site-packages/torio/lib

EDIT: I have been checking the internal code and in file torchaudio\_extension\__init__.py line 24 there is a code which is not being executed:

if os.name == "nt" and (3, 8) <= sys.version_info < (3, 9):
    _init_dll_path()

This code adds the paths from PATH environment variable to the DLL search path. However, I would like to know why it is only executed in Python 3.8 version.

Thank you.

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

No branches or pull requests

1 participant