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 (coder-decoder) is software or hardware that compresses and decompresses digital audio or video. The codec determines how a video or audio file is encoded and how much space it takes up.
Every video file you watch uses a codec. When you play a YouTube video, your device uses a codec (H.264 or VP9) to decode the compressed video data and display it on screen in real time.
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
Video codecs compress footage by finding similarities between adjacent frames. Instead of storing every pixel of every frame, they store only the differences between frames. A talking head video with a static background only needs to store the movement, not the entire background in every frame.
The codec you choose determines the trade-off between file size, quality, and compatibility. H.264 is the most compatible. H.265 is 50% more efficient. AV1 is the most efficient but slowest to encode.
Examples of Codec
H.264 | FileFormer
The most widely used video codec. Supported by every device. Used on YouTube, Netflix, and Blu-ray.
H.265 (HEVC) | FileFormer
50% better compression than H.264. Used for 4K content. Requires modern hardware.
AAC | FileFormer
The standard audio codec for streaming. Used by Apple Music, YouTube, and most platforms.
AV1 | FileFormer
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 FreeFrequently Asked Questions
What is the difference between a codec and a format?
A format (like MP4) is the container that holds the data. A codec (like H.264) is how the video/audio data inside is compressed.
What codec does YouTube use?
YouTube primarily uses H.264 for HD video and is transitioning to AV1 for better compression. Audio is usually AAC.
How do I know what codec my video uses?
Use VLC media player: right-click the playing video > Tools > Media Information > Codec tab.
Can I play a video without the right codec?
Without the correct codec, your device cannot decode the video and it will not play. VLC media player includes most codecs built-in.
What is the best video codec?
H.264 for compatibility. H.265 for efficiency on modern devices. AV1 for the best compression on web platforms.