Video Codecs: What They Are and How to Choose One

Codecs header

Key takeaways

  • A codec (coder-decoder) compresses media for storage and delivery and decompresses it for playback.
  • A codec is not a file format. MP4, WebM and MKV are containers that hold codec-encoded streams.
  • H.264 is the compatibility baseline. HEVC suits Apple devices and TVs. VP9 and AV1 are royalty-free options for web delivery.
  • AV1 carries about 30% of Netflix viewing (Dec 2025), yet a 2026 device dataset shows 91.3% decode support for AV1 against 99.8% for H.264 Baseline.

A codec (short for coder-decoder) is the technology that compresses digital audio, image or video for storage and transmission, and decompresses it for playback. It can run as software or on dedicated hardware in a phone, computer or TV.

What Is a Codec?

A codec is a type of technology used to compress or decompress digital media, including image, video, and audio signals for transmission, storage, or recording. Typically this is implemented as a software solution that can compress (encode) the video and send it to the user to be decompressed (decoded) through software or hardware for viewing. The term ‘codec’ is a combination of the words “coder” and “decoder”, as well as “compression” and “decompression”. In essence, a codec can be a device or a software program that serves both of these functions.

Codecs are crucial in applications for creating and playing media files, and they play a vital role in sending media files over a network. They are also central to live streaming services like Twitch, where the chosen codec can dramatically affect video quality.

Lossy codecs compress by removing information the human eye or ear will not notice, like tiny colour variations between pixels. The more you compress something, the smaller its file size becomes–but this can lead to artifacts such as blockiness in images or ‘underwater’ audio when played back on low-quality devices. For example, a 4K movie might originally equal five terabytes of data per hour, but a codec can compress it into the gigabyte range, making it manageable for storage and transmission. Using the proper codec with proper compression settings will not cause problematic artifacts.

What is the difference between a codec and a container?

Term What it is Examples
Codec The algorithm that compresses and decompresses a media stream H.264, HEVC (H.265), VP9, AV1, AAC, Opus
Container The file wrapper that holds one or more streams plus metadata MP4, WebM, MKV, MOV

One container can hold several codecs. An MP4 file can carry H.264, HEVC or AV1 video, and a WebM file typically carries VP9 or AV1 video.

How do the main video codecs compare?

Codec Strength Decode support in 2026 dataset Licensing Typical use
H.264 (AVC) Plays almost everywhere 99.80% (Baseline profile) Patent pool licence fees apply Compatibility fallback
HEVC (H.265) Efficient, strong on Apple devices and TVs 86.7% Multiple patent pools, the most complex to licence Premium video on demand, Apple audiences
VP9 Royalty-free, efficient, broad browser support 99.87% Royalty-free Web video
AV1 Highest compression efficiency of the four 91.3% Royalty-free Large catalogs and bandwidth-sensitive delivery

Source: the WebCodecs Fundamentals codec support dataset (2026), built from millions of real user sessions. It describes decoding in that sample, not the whole web. Support varies by browser, operating system and hardware.

What are image and audio codecs?

  • Image codecs: JPEG, WebP, AVIF (built on AV1), HEIC (built on HEVC) and JPEG XL.
  • Audio codecs: AAC for broad compatibility, MP3 for legacy playback and Opus for efficient web audio.

How do you choose a video codec?

  1. Need playback on every device? Deliver H.264 in an MP4 container.
  2. Audience on Apple devices or smart TVs? Add HEVC.
  3. Web-first delivery? Add VP9 or AV1 in WebM or MP4.
  4. Large catalog with high bandwidth costs? Encode AV1 for devices that decode it. Netflix reports that AV1 sessions use about one third less bandwidth than AVC or HEVC sessions.
  5. Live streaming? Check real-time encoder speed. Software AV1 encoding costs more compute than H.264.
  6. Always keep a fallback. Serve the most efficient codec the viewer can play and fall back to H.264.

Common mistakes when choosing a codec

  • Treating the container as the codec. “We deliver MP4” says nothing about compression. Two MP4 files can differ by 40% in size depending on the codec inside.
  • Shipping one codec to everyone. Serving only H.264 wastes bandwidth on modern devices; serving only AV1 breaks playback for roughly 9% of sessions.
  • Ignoring hardware decode. A codec that decodes in software drains battery and can stutter on older phones even when it technically plays.
  • Forgetting the audio codec. An efficient video codec paired with an oversized audio track gives back much of the saving.
  • Re-encoding an already lossy file. Each generation compounds artifacts. Encode from the highest quality master you have.

Which platforms choose the codec for you?

Most teams do not manage codec matrices by hand. The practical question is which platform negotiates the codec per request.

Platform How the codec is chosen Notable for
Cloudinary f_auto resolves format and codec per request, with q_auto for quality One API covering images and video, with the same automatic selection for both
Mux Automatic encoding on ingest with adaptive delivery Developer-first video infrastructure and playback analytics
Cloudflare Stream Automatic renditions delivered over Cloudflare’s network Bundled delivery and per-minute pricing
Bitmovin Configurable per-title encoding Fine-grained control for broadcast-grade workflows
api.video Automatic transcoding into an adaptive ladder Lightweight API for embedding video quickly

How does Cloudinary pick a codec?

With automatic format selection (f_auto), Cloudinary delivers each video in the optimal format and codec for the requesting browser. For most modern browsers that is a VP9 WebM or an AV1 MP4. Safari browsers may receive an HEVC MP4, and browsers without support for those receive an H.264 MP4. AV1 is available to f_auto automatically on plans that use the video seconds metric.

https://res.cloudinary.com/<cloud_name>/video/upload/q_auto/f_auto/<public_id>

Where not to use f_auto. Do not use f_auto in an incoming transformation or a named transformation. Cloudinary resolves the format for each request at delivery time, so it cannot be fixed at upload.

The selected rendition is then served over multi-CDN delivery, so viewers reach a nearby edge, and protected media can be restricted with signed URLs carrying an expiry and with token-based access. Assets are encrypted with AES-256 at rest and TLS in transit.

Frequently asked questions

What is a codec?

A codec is the technology that compresses and decompresses digital media. The name combines coder and decoder, or compression and decompression.

Is H.264 a codec or a file format?

H.264 is a codec. The video it encodes is usually stored in an MP4 container.

What is the best video codec for the web?

H.264 gives the widest compatibility. VP9 and AV1 give better compression. The best choice depends on your audience devices, so most teams serve the most efficient codec each viewer supports and keep H.264 as the fallback.

Will AV1 replace H.264?

AV1 is growing, with about 30% of Netflix viewing in December 2025. About 9% of sessions in the 2026 dataset could not decode AV1 Profile 0 8-bit, so a fallback codec is still needed.

What is the difference between a codec and a container?

The codec compresses the audio or video. The container, such as MP4 or WebM, packages the compressed streams and metadata into one file.

Which codec should I use for live streaming?

H.264 remains the default for live because encoders reach real-time speed reliably. HEVC and AV1 are possible with hardware encoders, but check encode speed before committing.

Last updated: Oct 27, 2026
★★★★★
4.8 (21 reviews)
Talk to Sales Talk to Sales