If you’re new to the wide and wonderful world of YouTube—or working with any kind of video for that matter—you might have heard of video codecs.
Or perhaps you’re not so new, and you’ve heard of them, but you don’t really understand what they are or what they do. If you are either of these people, this post is for you.
Video codecs are the software and method that is used to compress video. In the case of YouTube, codecs are employed to reduce the size of the video before it is streamed by millions of people across the globe.
It is an essential part of transmitting video, and there are a variety of different flavours available. But what are they? And why are they so important? Read on to have YouTube codecs explained in full.
What is a Codec?
In short, codecs are compression. They are the software and method used to compress a large video file into a smaller video file using clever algorithms that strive to achieve the most significant reduction in size at the expense of as little loss of detail as possible.
Video is an incredibly large medium in terms of raw data—which we’ll get to shortly—and few people who don’t work with video appreciate just how much information is involved. Of course, anyone who edits video in any capacity will be fully aware, and anyone who has ever attempted to edit 4K video on a computer that, while powerful, was nevertheless not up to the task, will appreciate the struggle that video can present.
If you need help in deciding between 1080p and 4K – maybe you are lost and don’t know the difference – check out my deep dive blog on 4K and it could take YouTube by storm!
Codecs don’t typically help with editing, however, but they make life a lot easier on your Internet connection, and given how far our Internet speeds have come in recent years, the fact that there are still effort to improve compression and shrink video files further should serve to highlight how big video can be.
How do Codecs Work?
In the simplest terms, codecs compress information into a smaller size by replacing it with a different set of data that represents the original information.
To give a very simplified example of this, imagine you have a still frame of 1080p video where the top half of the screen is entirely black. Each pixel on the screen has to be accounted for in the data for that still frame, which means there are 1920×540, or 1,036,800 pixels. That’s a lot of data.
However, we don’t need to store every single pixel in our data. Knowing that the next million pixels are the same, we can just say that and be done. Saving the data equivalent of “Black: 1,036,800 times” is a lot more efficient than actually listing black over a million times.
Of course, there is much more to it than that, but it should serve to give you a basic grounding in how codecs do their job. Compression can be taken to extreme levels, of course. Video can be compressed until it is little more than a pixellated blur of what it once was—albeit is a pixellated blur that takes up considerably less space than it once did. Many ingenious techniques are employed to preserve information, but as a general rule, the more compressed a video is, the more of that original information you lose.
“Why is information lost?” we hear you asking. In the above example of a frame that is half black, no information would be lost. The entirety of that black half of the screen would be stored fully intact in the dramatically reduced space we outlined. Real-world applications of compression are not so simple, however.
There are very rarely large portions of a frame that are the same colour in a frame of video, especially a film or TV show. Furthermore, there may not be any smaller areas that are identical. When you consider the depth of colours available and things like film grain, it is entirely possible to have frames of video where there isn’t a single collection of pixels adjacent to each other that are identical. In those cases, the simple compression method we detailed above would be useless.
This is where the information loss comes in. Codecs employ algorithms to decide what is compressible. If you have two pixels that are ever so slightly different shades of blue, they would technically be different but probably not different enough that the human eye could distinguish between the two.
The compression algorithm may count both of these pixels as the same colour, allowing it to reduce the size of the frame slightly.
And, when the video is decoded, it will still look good to our human eyes, but the information of that slightly differently shaded blue pixel is lost, and cannot be recovered from the encoded video.
This is why high-resolution footage with a lot of film grain is hard to compress, because you either can’t get much of a size reduction from the compression, or you lose a lot of that fine detail.
This should hopefully also go some way to explaining why there are so many codecs available. It is not a simple matter of which codec reduces the video size the most, there are preferences to take into account.
Some codecs are more aggressive, others don’t achieve the same degree of size-reduction. Depending on what you are doing with your video, different codecs may be suitable.
Why do we Need Codecs?
Computers are getting more powerful, and Internet speeds are getting faster, but at the same time, media is growing in fidelity.
There was a time not too long ago when our only means of watching video was the equivalent of a 640×480 screen, in what would retroactively be called 480i. For comparison, 1080p—which is considered the bare minimum these days and is even drifting slowly into obsolesce—is 1920×1080. That’s three times more information than the standard definition video we used to watch.
In keeping with this trend, 4K—which is well on its way to replacing 1080p as the defacto standard—is four times larger again. It should be noted that the “4” in 4K is not down to the fact that it is four times the size of 1080p, but rather the fact that the horizontal resolution is nearly 4,000 pixels across.
But 4K itself already has a replacement on the horizon, with 8K screens creeping onto the market. As you might have guessed, 8K is four times larger again than 4K, though we are far from 8K being commonplace in our homes, so we wouldn’t hold off on purchasing that 4K television just yet.
So what does all this mean? It means that despite computers getting more powerful and Internet speeds getting faster, the size of the media we are trying to play is getting similarly more substantial. Exponentially so, in fact. And this is just taking video files into account; there is also game streaming to consider, which Google is getting into in the form of their Stadia service.
And, while this is a gaming platform, it ultimately boils down to streaming live video to your screen, and will likely be a big part of YouTube if it succeeds.