Skip to main content

patch-torchcodec

Patch TorchCodec to use PyAV's bundled FFmpeg — one command, no system FFmpeg needed.

Problem

TorchCodec requires FFmpeg shared libraries (libavcodec.so.62, etc.), but installing FFmpeg system-wide can be complex and may cause version conflicts.

Solution

PyAV already bundles FFmpeg. patch-torchcodec patches TorchCodec's RPATH to find them — no environment variables needed!

Quick Start

pip install torchcodec          # install torchcodec (with PyTorch)
pip install patch-torchcodec    # install patcher (av & patchelf included)
patch-torchcodec                # patches RPATH — done!

That's it. TorchCodec now works:

from torchcodec.decoders import VideoDecoder  # ✓ just works

Command Line Options

patch-torchcodec               # Patch RPATH (default, recommended)
patch-torchcodec --env-only    # Symlinks only (requires LD_LIBRARY_PATH)
patch-torchcodec --status      # Check current setup status
patch-torchcodec --verify      # Verify TorchCodec works
patch-torchcodec --quiet       # Silent mode

Python API

from patch_torchcodec import setup_with_patchelf, verify_torchcodec, is_rpath_patched

# Patch RPATH (recommended) — persists across sessions
setup_with_patchelf(verbose=True)

# Verify
assert verify_torchcodec(require_env=False)

How It Works

  1. Finds PyAV's bundled FFmpeg in site-packages/av.libs/
  2. Creates symbolic links with standard names (e.g., libavcodec.so.62)
  3. Patches TorchCodec's .so files with patchelf to include PyAV's library path in RPATH

Limitations

  • Linux only (RPATH is Linux-specific)
  • Same virtualenv: PyAV and TorchCodec must be in the same environment
  • Re-run after reinstall: If you reinstall TorchCodec, run patch-torchcodec again

License

MIT

Metadata

Release files for patch-torchcodec 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for patch-torchcodec 0.1.4
File Size Uploaded
patch_torchcodec-0.1.4.tar.gz 8.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for patch-torchcodec 0.1.4
File Interpreter ABI Platform
patch_torchcodec-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 16.9 kB

Release files / patch_torchcodec-0.1.4.tar.gz

Download URL patch_torchcodec-0.1.4.tar.gz
Size 8.4 kB
Tags Source
SHA-256 checksum
How to use checksums
30e835096a5492357c492ead81a6227ce519626be7696e8ef8689b0e3d113850
BLAKE2b-256 checksum
How to use checksums
297f3d84b9ea3966e93b6bb5b231455cbfdf0a41a620b392dd12b47bbc4a05ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / patch_torchcodec-0.1.4-py3-none-any.whl

Download URL patch_torchcodec-0.1.4-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9fa0dff6ed2fd7ba1a009b44529f2bb0bdea26665541c5f34a99f5f12c288e24
BLAKE2b-256 checksum
How to use checksums
7becc7b11a8c38d44a5183bbb87ba528822c5bad0cb5cb8ac2449a517027edaa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page