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

torchcodec not compatible with brew-installed ffmpeg #570

Open
aliberts opened this issue Mar 17, 2025 · 2 comments
Open

torchcodec not compatible with brew-installed ffmpeg #570

aliberts opened this issue Mar 17, 2025 · 2 comments

Comments

@aliberts
Copy link

aliberts commented Mar 17, 2025

🐛 Describe the bug

Torchcodec doesn't work if ffmpeg was installed using brew.

Reproduction (on an ARM Mac):

# Setup
brew install ffmpeg
conda create -y -n torchcodec python=3.10 && conda activate torchcodec
pip install torch torchvision torchaudio torchcodec

# This will fail
python -c "import torchcodec;" 

Traceback

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/homebrew/Caskroom/miniconda/base/envs/torchcodec/lib/python3.10/site-packages/torchcodec/__init__.py", line 10, in <module>
    from . import decoders, samplers  # noqa
  File "/opt/homebrew/Caskroom/miniconda/base/envs/torchcodec/lib/python3.10/site-packages/torchcodec/decoders/__init__.py", line 7, in <module>
    from ._core import VideoStreamMetadata
  File "/opt/homebrew/Caskroom/miniconda/base/envs/torchcodec/lib/python3.10/site-packages/torchcodec/decoders/_core/__init__.py", line 8, in <module>
    from ._metadata import (
  File "/opt/homebrew/Caskroom/miniconda/base/envs/torchcodec/lib/python3.10/site-packages/torchcodec/decoders/_core/_metadata.py", line 15, in <module>
    from torchcodec.decoders._core.video_decoder_ops import (
  File "/opt/homebrew/Caskroom/miniconda/base/envs/torchcodec/lib/python3.10/site-packages/torchcodec/decoders/_core/video_decoder_ops.py", line 59, in <module>
    load_torchcodec_extension()
  File "/opt/homebrew/Caskroom/miniconda/base/envs/torchcodec/lib/python3.10/site-packages/torchcodec/decoders/_core/video_decoder_ops.py", line 44, in load_torchcodec_extension
    raise RuntimeError(
RuntimeError: Could not load libtorchcodec. Likely causes:
          1. FFmpeg is not properly installed in your environment. We support
             versions 4, 5, 6 and 7.
          2. The PyTorch version (2.6.0) is not compatible with
             this version of TorchCodec. Refer to the version compatibility
             table:
             https://github.com/pytorch/torchcodec?tab=readme-ov-file#installing-torchcodec.
          3. Another runtime dependency; see exceptions below.
        The following exceptions were raised as we tried to load libtorchcodec:
        
[start of libtorchcodec loading traceback]
dlopen(/opt/homebrew/Caskroom/miniconda/base/envs/torchcodec/lib/python3.10/site-packages/torchcodec/libtorchcodec7.dylib, 0x0006): Library not loaded: @rpath/libavutil.59.dylib
  Referenced from: <1066133A-B772-3E91-BB2F-2B124F1C5CC6> /opt/homebrew/Caskroom/miniconda/base/envs/torchcodec/lib/python3.10/site-packages/torchcodec/libtorchcodec7.dylib
  Reason: tried: '/opt/homebrew/Caskroom/miniconda/base/envs/torchcodec/lib/python3.10/lib-dynload/../../libavutil.59.dylib' (no such file), '/opt/homebrew/Caskroom/miniconda/base/envs/torchcodec/bin/../lib/libavutil.59.dylib' (no such file)
dlopen(/opt/homebrew/Caskroom/miniconda/base/envs/torchcodec/lib/python3.10/site-packages/torchcodec/libtorchcodec6.dylib, 0x0006): Library not loaded: @rpath/libavutil.58.dylib
  Referenced from: <3DE0F4A5-8F38-3AD7-BB75-7BA53C57F543> /opt/homebrew/Caskroom/miniconda/base/envs/torchcodec/lib/python3.10/site-packages/torchcodec/libtorchcodec6.dylib
  Reason: tried: '/opt/homebrew/Caskroom/miniconda/base/envs/torchcodec/lib/python3.10/lib-dynload/../../libavutil.58.dylib' (no such file), '/opt/homebrew/Caskroom/miniconda/base/envs/torchcodec/bin/../lib/libavutil.58.dylib' (no such file)
dlopen(/opt/homebrew/Caskroom/miniconda/base/envs/torchcodec/lib/python3.10/site-packages/torchcodec/libtorchcodec5.dylib, 0x0006): Library not loaded: @rpath/libavutil.57.dylib
  Referenced from: <E6431CF6-E34F-339E-BDB3-F660A1161AE7> /opt/homebrew/Caskroom/miniconda/base/envs/torchcodec/lib/python3.10/site-packages/torchcodec/libtorchcodec5.dylib
  Reason: tried: '/opt/homebrew/Caskroom/miniconda/base/envs/torchcodec/lib/python3.10/lib-dynload/../../libavutil.57.dylib' (no such file), '/opt/homebrew/Caskroom/miniconda/base/envs/torchcodec/bin/../lib/libavutil.57.dylib' (no such file)
dlopen(/opt/homebrew/Caskroom/miniconda/base/envs/torchcodec/lib/python3.10/site-packages/torchcodec/libtorchcodec4.dylib, 0x0006): Library not loaded: @rpath/libavutil.56.dylib
  Referenced from: <45D49A90-22F9-3CBE-93E1-D1CB8E3E21E1> /opt/homebrew/Caskroom/miniconda/base/envs/torchcodec/lib/python3.10/site-packages/torchcodec/libtorchcodec4.dylib
  Reason: tried: '/opt/homebrew/Caskroom/miniconda/base/envs/torchcodec/lib/python3.10/lib-dynload/../../libavutil.56.dylib' (no such file), '/opt/homebrew/Caskroom/miniconda/base/envs/torchcodec/bin/../lib/libavutil.56.dylib' (no such file)
[end of libtorchcodec loading traceback].

Since it doesn't appear in the specs below, I'll add that the version of ffmpeg installed by brew is 7.1.1.

Could be related to #265. Not super blocking as it does work normally if ffmpeg is installed with conda as instructed in the README.

In any case, thank you for this awesome work! 🙏

Versions

PyTorch version: 2.6.0
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 15.3.1 (arm64)
GCC version: Could not collect
Clang version: 16.0.0 (clang-1600.0.26.6)
CMake version: version 3.31.4
Libc version: N/A

Python version: 3.10.16 (main, Dec 11 2024, 10:22:29) [Clang 14.0.6 ] (64-bit runtime)
Python platform: macOS-15.3.1-arm64-arm-64bit
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Apple M3 Pro

Versions of relevant libraries:
[pip3] numpy==2.2.4
[pip3] torch==2.6.0
[pip3] torchaudio==2.6.0
[pip3] torchvision==0.21.0
[conda] numpy 2.2.4 pypi_0 pypi
[conda] torch 2.6.0 pypi_0 pypi
[conda] torchaudio 2.6.0 pypi_0 pypi
[conda] torchcodec 0.2.1 pypi_0 pypi
[conda] torchvision 0.21.0 pypi_0 pypi

@jrabary
Copy link

jrabary commented Mar 21, 2025

Same here. I'm using uv instead of conda and uv add ffmpeg doesn't solve the issue

@yongjincho
Copy link

Same error here. I'm also using uv.

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

3 participants