Skip to content
Merged
Changes from all commits
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
7 changes: 3 additions & 4 deletions src/torchcodec/_core/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,19 @@ def load_torchcodec_shared_libraries() -> tuple[int, str]:
)


expose_ffmpeg_dlls = nullcontext
if sys.platform == "win32" and hasattr(os, "add_dll_directory"):
# On windows we try to locate the FFmpeg DLLs and temporarily add them to
# the DLL search path. This seems to be needed on some users machine, but
# not on our CI. We don't know why.
if ffmpeg_path := shutil.which("ffmpeg"):

def cm(): # noqa: F811
def expose_ffmpeg_dlls(): # noqa: F811
ffmpeg_dir = Path(ffmpeg_path).parent
return os.add_dll_directory(str(ffmpeg_dir)) # that's the actual CM

else:
cm = nullcontext

with cm():
with expose_ffmpeg_dlls():
ffmpeg_major_version, core_library_path = load_torchcodec_shared_libraries()


Expand Down
Loading