What is a video codec?
A codec is a hardware or software tool that is used to compress (and decompress) video files. Common video codecs include h.264, h.265, V8, VP9 and AV1.
Video codecs typically utilize lossy compression meaning that data is lost as the video is compressed. When choosing a video codec, a few trade offs nust be considered:
- Time required to compress the file
- Codec support in playback devices
- Compression efficiency (how small are the new video files)
- Compression quality (how lossy is the compression)
There are often settings in the compression tooling that allows for modification of the compression/quality metrics - generally speaking, increasing the compression lowers the file size (and the video quality).
Obviously, codec support in browsers and devices is important. There are many many video codecs, but here are the most common:
- h264 is the most widely supported video codec (98.2% browser support in June 2021) It is often help in an .mp4 container, and today most videos on the web utilize the h.264 codec.
- h.265: The successor of h264, which features better compression at the same quality settings. Unfortunately, the h265 codec is highly patent encumbered - resulting in reduced support across devices due to its high cost.
- h.266 (Versitile Video Codec) is the next generation of the line, but is not yet supported in any browsers.
- VP8/VP9/AV1 codecs are generational video codecs that are royalty free. Much like the h26x generations of videos, each subseqent codec features improved compression and quality. The AV1 format is 25-35% smaller than the VP9 format, and has had some limited success. The current limitation with the AV1 codec is that the compression step is significantly slower than other formats. It is expected that as compression time improves, AV1 usage will increase.
** VP8 and VP9 videos ship in a webm container that is supported on 78% of browsers (98% in a webRTC context). ** AV1 will also likely ship in the webm conatiner, and is supported by 78% of all browsers for playback.
Mobile devices often have hardware video decoders to speed decoding, and to use less battery.
Each video container typically contains a video file (compressed with a video codec), and audio file (compressed with an audio codec.