A video codec is a technology that compresses video into a much smaller size for storage and streaming, then decompresses it for playback — the word is short for "coder-decoder." Without codecs, video files would be far too large to stream over the internet or store practically. Every time you watch something online, a codec is quietly shrinking the video before it reaches you and reconstructing it on your device.

Why is compression necessary?

Raw, uncompressed video is enormous. Each frame is a full grid of pixels, and video plays many frames per second, so even a short clip in raw form would run to a size that is impractical to store or send. Compression solves this by removing redundancy — information the eye will not miss and data that repeats. A codec finds patterns within a frame and between frames (since one frame is usually very similar to the next) and encodes only what changes, dramatically reducing the amount of data needed. This is what makes streaming a high-quality picture over an ordinary connection possible at all.

How does a codec work?

At a high level, the encoder analyzes the video and throws away or condenses information that contributes little to what you perceive. It looks for spatial redundancy (smooth areas within a single frame) and temporal redundancy (parts of the image that stay the same from frame to frame), storing differences rather than repeating full frames. Most consumer video codecs are lossy, meaning they discard some detail permanently to achieve much smaller files; the art of a good codec is discarding data you are least likely to notice. On playback, the decoder reverses the process, reconstructing each frame for your screen. The better the codec, the more quality it preserves at a given file size.

What are the main video codecs?

A handful of codecs dominate today's video, each representing a step in efficiency:

Codec Also known as Notes
H.264 AVC (Advanced Video Coding) The most widely supported codec; plays on nearly every device.
H.265 HEVC (High Efficiency Video Coding) Successor to H.264; better compression, often used for 4K, but carries licensing costs.
VP9 An open, royalty-free codec developed by Google; used widely for web streaming.
AV1 A newer royalty-free codec from the Alliance for Open Media; strong efficiency, growing support.

H.264 remains the safe default because almost everything can play it. HEVC and VP9 improve compression, letting you deliver the same quality in less data. AV1 pushes efficiency further still and is royalty-free, which is a major reason streaming services and browsers have been adopting it, though it demands more processing power to encode and decode.

What is the difference between a codec and a container?

This is the most common source of confusion, so it is worth being precise. A codec is the method used to compress the video itself. A container — a file format such as MP4, MKV, or WebM — is the wrapper that holds the compressed video stream together with the audio stream, subtitles, and metadata. In other words, the container is the box; the codec is how the contents of the box were compressed. An MP4 file, for example, might contain video encoded with H.264 or with AV1. That is why two files with the same .mp4 extension can behave differently: the container is the same, but the codec inside may not be.

Why does codec choice matter for streaming?

Codec choice is a balancing act between three things: file size, video quality, and compatibility. A more efficient codec like AV1 can deliver the same quality at a smaller size, which saves bandwidth and reduces buffering — a real benefit for streaming services and viewers alike. But efficiency comes at a cost: newer codecs require more processing power, and not every device can decode them, especially older hardware. H.264 is less efficient but plays almost everywhere, so it is often used as a reliable fallback. Streaming platforms typically prepare video in several codecs and resolutions and send whichever combination best fits your device and connection. This is the same adaptive process that decides which quality you get when your connection dips, which is why efficient codecs help reduce buffering and make higher resolutions like 4K practical to stream at all. It also ties into how audio and subtitle streams are packaged inside the same container.

Is a newer codec always better?

Not necessarily. Newer codecs such as HEVC and AV1 offer better compression, but "better" depends on your situation. They need more computing power to encode and decode, so a low-powered or older device may struggle or fall back to software decoding that drains the battery. Support is also uneven: a codec is only useful if the device on the other end can actually play it. HEVC additionally involves licensing fees that have slowed its adoption, which is part of why royalty-free options like VP9 and AV1 gained traction. The right codec is the one that balances efficiency against the reality of where your video needs to play.

The takeaway on video codecs

A video codec is the invisible engine of modern video: it compresses footage into a size that can be streamed and stored, then decompresses it for your screen. From the near-universal H.264 to the highly efficient, royalty-free AV1, each codec trades compression, quality, and compatibility differently. Remember that the codec is separate from the container that holds it, and you will understand why the same file format can hide very different technology inside. As newer codecs spread and more devices gain hardware support for them, the same connection will carry ever sharper video — which is why codecs, quiet and invisible as they are, sit at the very heart of how modern streaming keeps improving.