Skip to main content

Video Formats and Codecs

Just like with images, choosing your video codec is a crucial performance and quality consideration. 

The main two video codecs to consider

There are two dominant video codecs, an older one and a newer one, with their own pros and cons.

x264/AVC (older)

The x264 codec is fast to encode, but results in comparatively large filesizes for a given quality. 

x265/HEVC (newer)

The x265 codec gives much superior quality for a given filesize, allowing for a video of the same quality as an x264-encoded one to be even 2-3 times smaller. This is a huge improvement, and especially important for the web, where CDN bandwidth for videos can easily get very high indeed.

The only real downside to x265 is that it takes a lot longer to encode; in the past compatibility was also a problem, but most browsers and video players support it now, and compatibility issues are a smaller and smaller problem for it.

Constant Rate Factor (CRF)

This is a quality mechanism, specific to the x264 and x265 codecs. It's an arbitrary number from 0-51 representing the output quality for the processed video; 0 is effectively lossless, and 51 is the lowest quality. Beware: the default CRF settings for x264 and x265 are different, and they are not directly comparable!

The default CRF for x264 is 23, and the default CRF for x265 is 28. These are more or less equivalent in quality, as x265 achieves better quality and lower filesizes than x264, so you have to adjust the CRF you want depending on which one you are using, as a CRF of 23 does not represent the same quality level on x264 vs x265.

I recommend you use x265.x265 in most cases. While x265 is not strictly "better" than x264, at least not yet, hereit is preferably in most cases where you are only going to encode the mainvideo advantagesonce ofand disadvantagesdisplay ofit x265to frommany a website perspective.users.

x264 vs x265: video transcoding tests

I did some brief testing to demonstrate the difference in transcoding time and resulting filesizes that result from using x264 vs x265, and produced a spreadsheet of results, which you can find here