Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions src/torchcodec/_core/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@

import io
import json
import os
from pathlib import Path
import shutil
import sys
import warnings
from types import ModuleType
from types import ModuleType, Tuple

import torch
from torch.library import get_ctx, register_fake
Expand All @@ -22,7 +26,7 @@
_pybind_ops: ModuleType | None = None


def load_torchcodec_shared_libraries():
def load_torchcodec_shared_libraries() -> Tuple[int, str]:
# Successively try to load the shared libraries for each version of FFmpeg
# that we support. We always start with the highest version, working our way
# down to the lowest version. Once we can load ALL shared libraries for a
Expand Down Expand Up @@ -70,7 +74,8 @@ def load_torchcodec_shared_libraries():
raise RuntimeError(
f"""Could not load libtorchcodec. Likely causes:
1. FFmpeg is not properly installed in your environment. We support
versions 4, 5, 6, 7, and 8.
versions 4, 5, 6, 7, and 8. On Windows, ensure you've installed
the "full-shared" version.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a quick search and I wasn't able to find an authoritative source on what a full-shared version is. I assume it's an version that ships dll instead of statically linking all libraries.

My concern is that this error message may not be directly actionable for users, unless we add more details on how they can install such a "full-shared" version. These details aren't really in scope here, so maybe we can leave this error message as it was?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. "full-shared" is the version that ships DLLs instead of statically linking them. "full-shared" is the term used in the download page.

Screenshot_20251209-145038_Brave
Screenshot_20251209-145314_Brave

Personally, I did not know the shared version is the one that has all DLLs until I started digging enough, so I figured this information would be helpful.

If you still would like me to reverse the change to the message, please let me know.

2. The PyTorch version ({torch.__version__}) is not compatible with
this version of TorchCodec. Refer to the version compatibility
table:
Expand All @@ -82,7 +87,16 @@ def load_torchcodec_shared_libraries():
)


ffmpeg_major_version, core_library_path = load_torchcodec_shared_libraries()
if sys.platform == "win32" and hasattr(os, 'add_dll_directory'): # If on Windows and Python 3.8+
# We need to locate the directory containing FFmpeg DLLs
ffmpeg_path = shutil.which("ffmpeg")
if not ffmpeg_path:
raise RuntimeError("Could not locate FFmpeg. Ensure FFmpeg is properly installed and added to PATH.")
# Temporarily add that path
with os.add_dll_directory(str(Path(ffmpeg_path).parent.resolve())):
ffmpeg_major_version, core_library_path = load_torchcodec_shared_libraries()
else:
ffmpeg_major_version, core_library_path = load_torchcodec_shared_libraries()


# Note: We use disallow_in_graph because PyTorch does constant propagation of
Expand Down
Loading