Which Codecs Does YouTube Use?

This article reviews which codecs YouTube uses for the unrelenting torrent of videos that it ingests and encodes. The data suggest that AV1 is only worthwhile for videos with view counts in the mid-to-high millions, but VP9 is worth considering for view counts in excess of a few thousand. 

As a general rule, if YouTube can’t afford to use a particular codec, chances are you can’t afford to use it either. On the other hand, if YouTube is starting to use a codec for videos with moderate view counts, perhaps it’s interesting for you as well.

This article explores which codecs YouTube uses for the different videos uploaded to the service and their respective view counts. By way of background, I was trolling YouTube and the fabulous Stats for Nerds feature for a lesson that I’m producing for a new course. The object of the exercise was to ascertain the breakeven points that seem to dictate codec usage.

Encoding Cost and Bandwidth Savings

In terms of cost/quality tradeoffs, the last time I looked, AV1 (libaom-AV1) took about 18 times longer to encode than H.264 (x264), which translates directly into 18 times the encoding cost if you’re running your own encoding farm, which YouTube does. In contrast, VP9 (libvpx-VP9) took only twice as long as H.264. At best, I found that VP9 saved about 15% over x264 while AV1 shaved 45% at the same quality level.

How do these quality/bandwidth savings numbers translate to codec usage for YouTube, which ingests a mind-boggling 500 hours of video per minute?  The TL/DR is that YouTube uses H.264 for the vast majority of videos that might get watched a few hundred times, or even lower. Starting in the 3-5,000 range, YouTube starts to use VP9, with AV1 reserved only for videos that will likely exceed more than five million views or so.

Of course, perhaps Google’s Argos Video Coding Unit, which Google developed specifically to process video, is responsible for what appears to be a dramatic change of behavior relating to VP9 usage. AFAIK, there’s only one other VP9 hardware accelerator (from Xilinx by way of NGCodec) and it’s for live video and isn’t commercially available. So, even if YouTube uses VP9 for comparatively low view counts, it might not make sense for others without hardware-accelerated VP9 encoding.

AV1 for Multiple Million View Counts

Let’s start at the top. Clicking Explore then Music, I checked the top ten “hottest videos of the week” in the music section. Most of these videos were newly released, yet many had over 5 million views. Eight of the ten videos were encoded using the AV1 codec; the rest were VP9. Interestingly, YouTube whiffed on the fabulous Olivia Rodrigo video (it is brutal out there), which was top of the list and had over 9.6 million views and counting.

YouTube uses the AV1 codec when views exceed several million
1. Codec usage for music videos.

VP9 for Multiple Thousand View Counts

Next, I checked the top 10 news videos, all with much lower view count, and with much shorter legs than other categories that I checked (news being topical and all that). Though the view count ranged from 4,582 to 673,454, YouTube encoded all videos using the VP9 codec.

YouTube uses the VP9 codec when views are between a few thousand and a few hundred thousand.
2. Codec usage for news clips.

Next, I checked gaming videos, which enjoy greater view counts than news and presumably longer tails. Here we saw an even split between AV1 and VP9. The choice of codec sometimes made sense (see the bottom three) though using VP9 for Call of Duty and LEGO had me shaking my head.

YouTube used a mix of VP9 and AV1 for gaming clips.
3. Codec usage for gaming clips.

Next, I hunted around for an entertainment site with moderate to high views and settled on Late Night with Seth Meyers, apparently the new home for Mr. Meyers who I’m sure we all remember from Saturday Night Live. A line of videos entitled A Closer Look enjoyed very solid view counts in the low millions, yet YouTube encoded them all in VP9.

YouTube eschewed AV1 even when view counts were in the low millions.
4. Codec usage for A Closer Look.

My favorite website for sports clips while working out is the Dan Patrick show; Numbers here were modest but VP9 was again used for all videos.

YouTube used VP9 even when view counts were relatively low.
5. View counts and codec usage for the Dan Patrick show.

H.264 For the Great Unwashed

Finally, I looked at the videos that I produced, all with pathetic view counts (note to self: fire marketing director). As you can see below, it was all H.264. I checked Streaming Media’s YouTube videos which enjoyed counts into the low several hundred and they were all H.264 as well.

YouTube encoded with H.264 when view counts were in the three figures
6. Codec usage for the Streaming Learning Center.

The Bottom Line

The bottom line appears to be:

  • View counts below a few thousand – use H.264.
  • View counts reaching into the mid-five figures, say over 3,000 or so – consider VP9. Again, since Google’s use of VP9 may be triggered by the Argos VCU, you should do your own testing with your encoding setup to confirm this result.
  • Don’t consider AV1 until view counts exceed multiple millions.

The big surprise for me wasn’t the AV1 findings, but that YouTube uses VP9 so extensively. When I analyzed VP9, the results were meh (see here). It may be that YouTube is using a different VP9 codec than I tested, or that YouTube is simply better at encoding VP9. Whatever the cause, given that YouTube’s bandwidth costs are probably a lot lower than yours (per GB), it should take you fewer viewing hours to achieve breakeven, meaning that it might be time to rethink VP9.

Resources

Real-World Bandwidth Savings from VP9, HEVC, and AV1

Computing Breakeven on New Codec Deployments

How to predict codec success – Techradar Pro, December 2020.

 

 

 

 

About Jan Ozer

I help companies train new technical hires in streaming media-related positions; I also help companies optimize their codec selections and encoding stacks, and evaluate new encoders and codecs.

Check Also

Basic YouTube-DL Commands to Download Files from YouTube

This article describes what youtube-dl is, and outlines several basic youtube-dl commands for audio/video/subtitle downloads. …

4 comments

  1. If you look at this video.
    https://www.youtube.com/watch?v=0yk4SPRisPA
    min 10:54
    You can see that there is VP9 hardware accelerator from Broadcom on top of the Google and NGCodec that you mentioned.

  2. Hey Jan,

    Thanks for the info. What if my device does not support AV1, and I click on a video with millions view counts (suppose it is encoded with AV1)? Then my request will be redirected to the same video encoded with VP9? And if my device does not support VP9 either, the request is redirected to the same video with H264?

Leave a Reply

Your email address will not be published. Required fields are marked *