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. h264 is the most widely supported video codec (98.2% browser support in June 2021) The successor of h264 was expected to be h265, which features better compression at the same quality settings. However, the h265 codec is highly patent encumbered - resulting in reduced support across devices. The VP8/VP9/AV1 codecs are generational video codecs that are royalty free, and owned by Google. 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.
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.