如何使用 pip 或手动方式将 ffmpeg 实用程序下载到 Python venv 中以用于 torchaudio

问题描述 投票:0回答:1

torchaudio 需要 avutil 和其他二进制 dll 文件

来源:https://pytorch.org/audio/2.3.0/installation.html

但是他们只给出了 Anaconda 的示例

我没有使用 Anaconda,但我使用的是 Python 3.10.11 pip venv

我在任何地方都找不到这些DLL文件

如何找到它们并将其安装到 Python venv 中?

由于我找不到,所以出现以下错误

Traceback (most recent call last):
  File "R:\MMAudio_v1\MMAudio\venv\lib\site-packages\gradio\queueing.py", line 625, in process_events
    response = await route_utils.call_process_api(
  File "R:\MMAudio_v1\MMAudio\venv\lib\site-packages\gradio\route_utils.py", line 322, in call_process_api
    output = await app.get_blocks().process_api(
  File "R:\MMAudio_v1\MMAudio\venv\lib\site-packages\gradio\blocks.py", line 2047, in process_api
    result = await self.call_function(
  File "R:\MMAudio_v1\MMAudio\venv\lib\site-packages\gradio\blocks.py", line 1594, in call_function
    prediction = await anyio.to_thread.run_sync(  # type: ignore
  File "R:\MMAudio_v1\MMAudio\venv\lib\site-packages\anyio\to_thread.py", line 56, in run_sync
    return await get_async_backend().run_sync_in_worker_thread(
  File "R:\MMAudio_v1\MMAudio\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 2505, in run_sync_in_worker_thread
    return await future
  File "R:\MMAudio_v1\MMAudio\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 1005, in run
    result = context.run(func, *args)
  File "R:\MMAudio_v1\MMAudio\venv\lib\site-packages\gradio\utils.py", line 869, in wrapper
    response = f(*args, **kwargs)
  File "R:\MMAudio_v1\MMAudio\venv\lib\site-packages\torch\utils\_contextlib.py", line 116, in decorate_context
    return func(*args, **kwargs)
  File "R:\MMAudio_v1\MMAudio\gradio_demo.py", line 60, in video_to_audio
    clip_frames, sync_frames, duration = load_video(video, duration)
  File "R:\MMAudio_v1\MMAudio\mmaudio\eval_utils.py", line 178, in load_video
    reader = StreamingMediaDecoder(video_path)
  File "R:\MMAudio_v1\MMAudio\venv\lib\site-packages\torio\io\_streaming_media_decoder.py", line 526, in __init__
    self._be = ffmpeg_ext.StreamingMediaDecoder(os.path.normpath(src), format, option)
  File "R:\MMAudio_v1\MMAudio\venv\lib\site-packages\torio\_extension\utils.py", line 25, in __getattr__
    self._import_once()
  File "R:\MMAudio_v1\MMAudio\venv\lib\site-packages\torio\_extension\utils.py", line 39, in _import_once
    self.module = self.import_func()
  File "R:\MMAudio_v1\MMAudio\venv\lib\site-packages\torio\_extension\utils.py", line 143, in _init_ffmpeg
    ext = _find_ffmpeg_extension(ffmpeg_vers)
  File "R:\MMAudio_v1\MMAudio\venv\lib\site-packages\torio\_extension\utils.py", line 122, in _find_ffmpeg_extension
    raise ImportError(
ImportError: Failed to intialize FFmpeg extension. Tried versions: ['6', '5', '4', '']. Enable DEBUG logging to see more details about the error.
python ffmpeg pip python-venv torchaudio
1个回答
0
投票

根据我的快速研究,您需要放置 ffmpeg 共享库才能启用扩展。您可以尝试下载Gyan的发布页面并下载“完全共享”的版本。如果 pytorch 不支持最新的 v7.x,您需要寻找 v6 完全共享版本。然后,您需要将文件解压缩到系统路径或 python 路径中的某个位置。

这里有另一种下载方式:你可以使用我的

ffmpeg-downloader

pip install ffmpeg-downloader

然后运行

ffdl list

列出所有可用的 ffmpeg 版本。

安装带有共享 dll 的最新版本(v7.1)

ffdl install --add-path 7@full-shared

--add-path
选项将安装路径添加到您的系统路径。您只需添加一次。安装完成后,您需要在运行Python之前重新启动终端。

如果pytorch不支持v7.1,需要降级运行

ffdl install -U 6@full-shared

这将安装最后一个 v6 完全共享版本。

希望这有帮助

© www.soinside.com 2019 - 2024. All rights reserved.