What is Codec?

A codec encodes and decodes audio and video files, affecting quality and file size. Learn what a codec is and how it works in this complete beginner's guide.

Free online file converter tool. Works in Chrome Firefox Safari Edge Opera and other modern browsers on Windows macOS Linux Android and iOS. No software installation or sign-up required. All conversions run directly in your browser, so your files never leave your device. Free to use with no account needed.

What is Codec?

A codec encodes and decodes audio and video files - it determines quality and file size

Last updated:

Codec: Simple Definition

A codec is the pair of algorithms that encodes media into a compressed form and decodes it back for playback. The word is a contraction of coder and decoder, and it names a process rather than a file: H.264, AAC, and VP9 are codecs, not formats.

The distinction that trips everyone up is codec versus container. MP4 is a container, a wrapper describing how tracks are packaged. H.264 is the codec that compressed the video inside it. Two MP4 files can hold entirely different codecs, which is exactly why one plays and the other does not.

Hardware decides more than the specification does. A phone decodes H.264 in dedicated silicon, using almost no battery, and may fall back to slow software decoding for AV1, or refuse it entirely. This is why the technically superior codec is not automatically the right choice for delivery.

Encoding and Decoding

The word codec is a portmanteau of coder and decoder: the encoder converts raw samples into a compressed bitstream, and the decoder reverses the process for playback.[2] A codec defines an algorithm and bitstream syntax, not a file on disk; the encoded stream is normally wrapped inside a container format that also carries timing and synchronization data.[1]

Codecs versus Containers

A common misconception is that a file extension identifies the codec. In reality an .mp4 or .webm container can hold streams produced by several different codecs, so two files with the same extension may not play on the same device.[3] Playback succeeds only when the device has the matching decoder, which is why widely licensed codecs such as H.264 enjoy near-universal support while newer ones may not.[3] The practical lesson is that "this video will not play" is usually a missing-codec problem, not a problem with the container, and re-encoding the video to a common codec like H.264 fixes it.

Video Codecs You Meet Most

A handful of codecs dominate. H.264 (AVC) is the universal default, hardware-accelerated almost everywhere and the safe choice for compatibility. H.265 (HEVC) roughly halves the size at equal quality but carries patent-licensing baggage that limits its support on the open web. AV1 and VP9 are royalty-free codecs used heavily by YouTube and Netflix for their efficiency. On the audio side, AAC and Opus play the equivalent roles. Knowing which codec a file uses explains both its size and where it will play.

Trade-offs in Codec Design

Choosing a codec balances compression efficiency, computational cost and compatibility. Newer codecs like AV1 or HEVC achieve smaller files at equal quality but demand far more processing power to encode and may require hardware acceleration to decode smoothly.[3] Licensing and patent considerations also influence which codecs platforms adopt.[2] There is no single best codec, only the best fit for a goal: maximum compatibility points to H.264, minimum file size to AV1 or HEVC, and live low-latency streaming to whichever codec the target platform decodes in hardware.

How Codecs Work

A video codec exploits the fact that consecutive frames are nearly identical. Rather than storing each frame whole, it stores occasional complete keyframes and, in between, only the differences: what moved and where. This is why fast-moving footage needs far more data than a static shot.

This structure explains everyday behaviour. Seeking jumps to a keyframe because intermediate frames are meaningless without their reference. Support is a hardware question too: a device decodes H.264 in dedicated silicon and may fall back to slow software decoding, or refuse entirely, for a newer codec like AV1.

Remuxing versus re-encoding is the distinction worth knowing. Moving streams into a different container without touching them takes seconds and loses nothing. Re-encoding decompresses and recompresses, which takes real time and always costs quality. When MKV to MP4 finishes suspiciously fast, the streams were simply rewrapped.

Examples of Codec

H.264

The most widely used video codec. Supported by every device. Used on YouTube, Netflix, and Blu-ray.

H.265 (HEVC)

50% better compression than H.264. Used for 4K content. Requires modern hardware.

AAC

The standard audio codec for streaming. Used by Apple Music, YouTube, and most platforms.

AV1

The newest royalty-free video codec with excellent compression. Growing in adoption.

Work With Your Files

Now that you understand the concept, use our free tools to convert, compress, and optimize your files.

Try Video Converter Free

References

  1. Codec - Glossary - MDN Web Docs
  2. Codec - Wikipedia
  3. Web video codec guide - MDN Web Docs