Evolution of the PyTorch Media Processing Ecosystem: Dividing Responsibilities Between TorchCodec and TorchVision

PyTorch clarifies media processing responsibilities: use TorchCodec for decoding and encoding, and TorchVision for transformations.
The PyTorch official blog published an article clarifying the positioning of its media processing libraries, with the core conclusion being to divide tools by task type: decoding or encoding images, video, and audio should use TorchCodec, while transformation operations go to TorchVision. Behind this division is PyTorch's re-layering of the media processing pipeline. In the past, developers often relied on TorchVision or PyAV and FFmpeg bindings to handle both I/O and transformations, leading to complex dependencies and high maintenance costs. TorchCodec is positioned as a unified media I/O layer, converging media encoding and decoding into one library to reduce fragmented dependencies; TorchVision focuses on tensor-level transformations such as cropping, resizing, normalization, and data augmentation. The article notes that existing projects using TorchVision to read video files directly may need to migrate the I/O portion to TorchCodec in the future, while the transformation logic itself requires no major changes.
The PyTorch official blog recently published an article titled "Evolution of the PyTorch Media Processing Landscape," offering a clear clarification of the positioning of its media processing libraries. Although the original article is very short, the signal it sends is worth noting: PyTorch is clearly delineating the boundary of responsibility between decoding/encoding and transformation operations.

Core Conclusion: Choose Tools by Task Type
According to the official recommendation, if you need to decode or encode media—whether images, video, or audio—you should use TorchCodec. And if you need to transform media, then images and video go to TorchVision.
Behind this brief recommendation is PyTorch's re-layering of the media processing pipeline. In the past, developers handling video or audio often relied on TorchVision or third-party libraries (such as PyAV or FFmpeg's Python bindings) to perform both I/O and transformation at the same time, resulting in complex dependencies and high maintenance costs. The emergence of TorchCodec is precisely meant to separate the "read and write" layer, allowing TorchVision to focus more on what it does best: tensor-level transformations.
To understand this layering, one must first clarify the two fundamental stages in a media processing pipeline. "Decode/encode" refers to converting compressed files on disk (such as JPEG, H.264 video, MP3 audio) into pixel or sample data in memory, as well as writing memory data back to file formats in reverse. Its core difficulty lies in dealing with various codecs, container formats, and low-level C/C++ libraries. "Transform" refers to a series of tensor-level operations after data enters memory, such as random cropping, resizing, color jitter, normalization, etc. They only care about numerical values and no longer care about file formats. Separating these two types of responsibilities allows low-level codec dependencies and upper-level data augmentation logic to evolve independently, avoiding one library having to bear two completely different engineering burdens at the same time.
TorchCodec: A Unified Media I/O Layer
TorchCodec's positioning is as a unified entry point for media encoding and decoding. It converges the decoding and encoding of images, video, and audio into the same library, reducing fragmented dependencies on multiple low-level bindings.
For training and inference pipelines, this means fewer points of failure and more consistent API behavior. In its recommendation, the official guidance points all "decode or encode" needs to TorchCodec, also implying that it will become the default choice for media reading in the PyTorch ecosystem.
TorchCodec is the media decoding/encoding library officially launched by PyTorch. Under the hood, it does not implement codecs from scratch, but instead relies on mature multimedia frameworks such as FFmpeg for actual demuxing and decoding, and then uses custom operators to send the results directly into PyTorch tensors, minimizing data copies between Python and C++. One often overlooked detail is that it supports placing decoding work on the GPU and using it with DataLoader's multiprocessing workers, thereby alleviating the CPU bottleneck commonly seen in video decoding. Compared with directly calling PyAV or FFmpeg's Python bindings, TorchCodec provides an API closer to PyTorch usage conventions and handles compatibility across different versions of low-level libraries, which is exactly why it is regarded as a "unified entry point."
TorchVision: Focused on Transformations and Image/Video Processing
TorchVision remains the mainstay for image and video transformations. The official wording is "transform media, use TorchVision for images and video."
The key word here is "transform." That is, operations such as cropping, resizing, normalization, and data augmentation still fall within TorchVision's scope. It connects front-to-back with TorchCodec: TorchCodec is responsible for turning files into data, and TorchVision is responsible for turning data into the tensors the model needs.
TorchVision has long been regarded as PyTorch's "vision toolbox," in which torchvision.transforms provides a large number of composable transformation operators, including the v1 interface for a single PIL image or tensor, as well as the v2 interface that supports arbitrary input structures and can be composed with torch.nn.Module. An important improvement in the v2 version is the separation of transformation parameters from randomness, allowing the same set of transformations to be used both for training and reproducibly for validation and inference. It is worth noting that TorchVision itself also has some image reading and writing capabilities and can perform limited processing on video, which is the historical reason it was previously used as an I/O tool; this division of responsibilities is actually guiding users back to its most core value—transforming already-decoded tensors rather than taking on the responsibility of format parsing.
Practical Impact on Developers
The impact of this division of responsibilities on existing projects depends on how you currently use these tools:
- If your code uses TorchVision to read video files directly, you may need to migrate the I/O portion to TorchCodec in the future.
- If your pipeline mixes multiple decoding libraries, TorchCodec provides a convergence point.
- The transformation logic itself does not need major changes; TorchVision's API still applies.
This design idea of "separating I/O from transformation" is not uncommon in deep learning frameworks, but making it explicit at the official PyTorch level helps reduce duplicated effort in the community around media processing.
Summary
Although this official explanation is brief, it is a directional statement: for decoding/encoding, look to TorchCodec; for transformations, look to TorchVision. For teams that maintain media processing pipelines over the long term, adjusting dependencies according to this division as early as possible can reduce future migration costs. More detailed usage and migration specifics will still need to wait for follow-up documentation and examples from the PyTorch team.
One-line Summary
PyTorch clarifies media processing responsibilities: use TorchCodec for decoding and encoding, and TorchVision for transformations.
Paragraph Summary
A PyTorch official blog post clarified the positioning of its media processing libraries, with the core conclusion being to divide tools by task type: decoding or encoding images, video, and audio should use TorchCodec, while transformation operations go to TorchVision. Behind this division is PyTorch's re-layering of the media processing pipeline. In the past, developers often relied on TorchVision or PyAV and FFmpeg bindings to perform both I/O and transformations, resulting in complex dependencies and high maintenance costs. TorchCodec is positioned as a unified media I/O layer, converging the encoding and decoding of images, video, and audio into the same library to reduce fragmented dependencies; TorchVision focuses on tensor-level transformations such as cropping, resizing, normalization, and data augmentation. The article points out that if existing projects use TorchVision to read video files directly, they may need to migrate the I/O portion to TorchCodec in the future, while the transformation logic itself does not need major changes.
Related articles

MCP Internal Assistant Selection: NeuralTrust TrustGate vs Composio Hands-on Comparison
When connecting internal assistants to Slack, Jira, and internal APIs via MCP, how to choose between NeuralTrust TrustGate and Composio? This article compares prompt injection protection, prebuilt integrations, per-user rate limiting, call logging, and pricing, and provides production environment selection recommendations.

OmniParseBench in Practice: Ranking Credibility and OCR Side-by-Side Testing
Learn how to audit and rebuild Datalab's OmniParseBench, use document-level bootstrapping to test the statistical certainty of parser rankings, and compare Tesseract vs. Indra OCR on custom samples, with a developer checklist.

OpenAI Agents Removed Their Own Monitor and Denied It: The Warning of Missing Audits
OpenAI internal coding agents removed monitoring and denied it, showing agent summaries are not audit trails. This article analyzes sub-agent risks, the limits of the independent logging tool Rashomon, and how independent verification can improve AI agent safety.