--- id: torchcodec version: "0.16.0" license: unclear license_treatment: unclear maintenance: active --- # torchcodec — A video decoder for PyTorch License: unclear · Maintenance: active · Downloads: 4.2M/mo ## What it is and what it does TorchCodec is a library that converts video, audio, and image files into tensors and back. It wraps FFmpeg for video and audio decoding/encoding, providing Pythonic APIs that abstract FFmpeg's complexity while supporting both CPU and CUDA GPU acceleration. The library returns data as tensors ready for transforms or model training, with metadata like frame counts, timestamps, and codec information. The package handles video frame indexing by frame number or playback time, batch frame extraction with timing metadata, and image decoding/encoding in multiple formats (JPEG, PNG, WebP, GIF, AVIF, HEIC). FFmpeg is optional—image codecs work without it—but video and audio work requires FFmpeg 4–9 installed on your system. CUDA support depends on GPU hardware with NVDEC/NVENC capabilities. Use it for: - Extract video frames as tensors for training models on video datasets - Decode audio to tensors for speech or music processing in pipelines - Batch-load images in multiple formats (JPEG, PNG, WebP) directly to GPU - Encode outputs back to video or audio files with precise frame/sample timing - Build data loaders that stream video frames with accurate presentation timestamps ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. TorchCodec decodes and encodes videos, audio, and images to and from tensors on CPU and CUDA GPUs, wrapping FFmpeg for video/audio and providing native image codecs. Yes, if you need to work with video, audio, or images in a media pipeline. TorchCodec is actively maintained (release 1 day old), has no known vulnerabilities, and integrates cleanly into workflows. Install friction is moderate due to compiled wheels and optional FFmpeg dependency, but both are straightforward. License status is unclear, so verify licensing terms before use in proprietary projects. ## Install pip install torchcodec uv add torchcodec poetry add torchcodec ## Installing torchcodec Before you install: Medium install friction due to compiled wheels for multiple Python versions (3.10–3.14) and platforms, plus an optional FFmpeg system dependency for video/audio work. Actively maintained with a release 1 day old and 1156 repository stars. Quickstart: pip install torchcodec from torchcodec.decoders import VideoDecoder decoder = VideoDecoder("path/to/video.mp4", device="cpu") frame = decoder[0] # uint8 tensor [C, H, W] FFmpeg (optional but required for video/audio; image decoders work without it). Requires Python >=3.10. Verify before relying: - Whether CUDA wheels are available for Windows by default or require explicit --index-url configuration - Performance characteristics (speed, memory efficiency) compared to direct FFmpeg usage - Stability and maturity of the 0.16.0 release relative to earlier versions ## Package facts - License: not declared (unclear) - Python support: supports_current - Install friction: medium - Maintenance: active - Downloads: 4.2M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags video decoding pytorch, audio encoding tensors, image codec gpu, ffmpeg wrapper, media to tensor conversion, video frame extraction, cuda video decoding, media-processing, gpu-accelerated [View on SkillFed](https://skillfed.io/packages/torchcodec) · [View on PyPI](https://pypi.org/project/torchcodec/)