Skip to main content

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

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

patch_torchcodec-0.1.4.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

patch_torchcodec-0.1.4-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file patch_torchcodec-0.1.4.tar.gz.

File metadata

  • Download URL: patch_torchcodec-0.1.4.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for patch_torchcodec-0.1.4.tar.gz
Algorithm Hash digest
SHA256 30e835096a5492357c492ead81a6227ce519626be7696e8ef8689b0e3d113850
MD5 7c75dd798a125e411e69c1410a67c259
BLAKE2b-256 297f3d84b9ea3966e93b6bb5b231455cbfdf0a41a620b392dd12b47bbc4a05ec

See more details on using hashes here.

File details

Details for the file patch_torchcodec-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: patch_torchcodec-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for patch_torchcodec-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9fa0dff6ed2fd7ba1a009b44529f2bb0bdea26665541c5f34a99f5f12c288e24
MD5 c0a389d138410e09099f46a94b851317
BLAKE2b-256 7becc7b11a8c38d44a5183bbb87ba528822c5bad0cb5cb8ac2449a517027edaa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page