The Best Codec For Streaming Games

The Best Codec For Streaming Games

We all want high-quality streams when we're streaming or watching games online. When thinking about adjusting the quality, we often consider aspects such as the encoder and bitrate. But another element that can be tweaked is the codec.

Codecs, also known as video coding formats, are compression algorithms that are used to adjust the size and quality of video as we stream. But which codec is the best to use? We'll need to experiment to figure that out.

We're going to run a short experiment using Twitch as the streaming platform and Glitch as the tool to test out which codec performs the best. If you want to see the results, skip to the bottom. But this article will cover the ins and outs of codecs.

What Is a Codec?

First, let's break down the word 'codec'. The word codec is a combination of two words:  'compressor' and 'decompressor'. It describes what we will be doing to video files as we make them smaller and larger. Why are these two functions important in live streaming?

When you are streaming your game play online, the data is transmitted to your viewers computer or phone. Sending the entire video in its original, high-quality form would be time-consuming, slow, and it might even "crash" their internet connection.

We want to make the video file as small as possible. That's where the 'compressor' part of the codec comes in. It reduces the video size, making it easier to send over the internet. So the first step is to compress the video file.

Even after compression, the video is still too large to be sent as one piece. So it's broken into separate pieces, often referred to as chunks. This "streaming data" consists of chunks that are quickly sent from the server to the viewer's computer.

Once the chunks arrive at the viewer's device, we need to reconstruct the high-quality video. That's where the 'decompressor' comes into play. It expands the compressed chunks back into a high quality video.

A codec manages this entire process compressing and decompressing a video.

What Codecs Are Used

There are many different methods of compressing and decompressing video, with various algorithms, metadata storage, and speeds. Let's review several codecs:

1. H.264 (also known as AVC):

  • What it is: H.264 or "Advanced Video Coding" is a widely-used video compression standard.
  • Importance for live streaming: It's known for efficient compression, allowing high-quality video at relatively low bitrates. H.264's support across various devices makes it versatile for live streaming.

2. AVC1:

  • What it is: Many think AVC1 is different from H.264, but it's actually the same! Sometimes it's labeled AVC1 in technical specifications.
  • Importance for live streaming: Like H.264, AVC1 ensures smooth live streaming across different platforms and devices.

3. VP8:

  • What it is: Developed by On2 Technologies and later acquired by Google, VP8 is an open and royalty-free codec.
  • Importance for live streaming: VP8 offers competitive compression efficiency and is popular in web applications like WebRTC.

4. VP9:

  • What it is: As the successor to VP8, developed by Google, VP9 offers better compression efficiency.
  • Importance for live streaming: It allows for high-definition content delivery with less data, beneficial for live streaming.

5. AV1:

  • What it is: The newest codec by the Alliance for Open Media, aiming for more efficiency than H.264, VP9, and H.265.
  • Importance for live streaming: It promises high-quality streams with less data and is royalty-free.

What Codec Works Best for Streaming to Twitch?

To determine the best codec for Twitch, we set up an experiment with these variables:

  • Streaming Destination: Twitch
  • Tool: Glitch Streaming platform due to its user-friendly codec adjustments.
  • Game: Valorant
  • FPS: 60
  • GPU: Nvidia GeForce RTX 3080
  • Bitrate: 4500
  • Chunk Size: 20
  • Encoder: Libx264

The variable that changed between each stream was the codec. Below are the results of each test. In Glitch, we can simply change the codec as shown in the image below.

Forewarning:

For this experiment, the bitrate should be at least 6k, and maybe even upwards of 7k or 8k. We are keeping it at 4500 to push the upper limits of the codec and visualize the differences in quality.

And the results of each test are as follows:

  • AV1:
  • VP9:
  • VP8:
  • AVC1:
  • H.264:

The Winner Is…

The winner in this scenario is VP8! But why? It's complicated and involves many factors, from my GPU to the game being played, to Twitch's processing. This means different services could yield different results, and someone else's computer might perform differently with another codec.

Also to re-iterate, we purposely set a low video bitrate for this experiment to better highlight the difference in the codecs compression and decompression.

If you want high-quality streams for your game, you'll have to test each codec on your computer with your game to see what yields the best quality. After this article, you have an understanding of how codecs can affect the quality of your streams.