torchaudio can't find FFmpeg

Windows, vscode, Python 3.11.4-64bit

import torch
import torchaudio


and i try

Traceback (most recent call last):
  File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\torchaudio\_extension\", line 85, in _init_ffmpeg
  File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\torchaudio\_extension\", line 61, in _load_lib
  File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch\", line 643, in load_library
  File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\ctypes\", line 376, in __init__
    self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\torchaudio\lib\libtorchaudio_ffmpeg.pyd' (or one of its dependencies). Try using the full path with constructor syntax.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "c:\Users\USER\Desktop\MyChatBot\", line 6, in <module>
  File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\torchaudio\_extension\", line 87, in _init_ffmpeg
    raise ImportError("FFmpeg libraries are not found. Please install FFmpeg.") from err
ImportError: FFmpeg libraries are not found. Please install FFmpeg.

my libtorchaudio_ffmpeg.pyd exists and it's path is correct, but ctypes can't seem to find it. how should i do?

I have also downloaded ffmpeg.

ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 10.2.1 (GCC) 20200726

but still not working. how should i do?


  • You need to install ffmpeg libraries, not CLI.

    What the error message means is that the dependencies of libtorchaudio_ffmpeg.pyd is not found. The dependencies here mean the libraries that consist FFmpeg, such as libavcodec and libavformat.

    Usually installing ffmpeg CLI also intall the libraries, but I often see people use statically built ffmpeg CLI on Windows due to its ease of installation.

    I cannot tell what ffmpeg CLI you have, but if your ffmpeg CLI is statically built, it does not work.

    As of how to install dynamically built FFmpeg, I cannot advise. There seems to be no straightforward way to install dynamically built FFmpeg on Windows unless using Anacaonda.