Welcome to the TorchCodec documentation!¶
TorchCodec is a Python library for decoding videos into PyTorch tensors, on CPU and CUDA GPU. It aims to be fast, easy to use, and well integrated into the PyTorch ecosystem. If you want to use PyTorch to train ML models on videos, TorchCodec is how you turn those videos into data.
We achieve these capabilities through:
Pythonic APIs that mirror Python and PyTorch conventions.
Relying on FFmpeg to do the decoding. TorchCodec uses the version of FFmpeg you already have installed. FMPEG is a mature library with broad coverage available on most systems. It is, however, not easy to use. TorchCodec abstracts FFmpeg’s complexity to ensure it is used correctly and efficiently.
Returning data as PyTorch tensors, ready to be fed into PyTorch transforms or used directly to train models.
How to install TorchCodec
A simple video decoding example
How to sample regular and random clips from a video
A simple example demonstrating CUDA GPU decoding
Note
TorchCodec is still in development stage and we are actively seeking feedback. If you have any suggestions or issues, please let us know by opening an issue on our GitHub repository.