Want to wach a video? Go to YouTube. No questions asked. If you’re a rebel, LiveLeak or Vimeo. YouTube serves more than 1 billion unique visits every month. 80% of their internet traffic is outside the U.S. while 100 hours worth of videos are uploaded every minute. Crazy, right? How is YouTube optimized?
MPEG-DASH
A few years ago, YouTube switched to a streaming protocol called MPEG-DASH (Dynamic Adaptive Streaming over HTTP). MPEG-DASH is a standard on how to handle streaming content. Back in the old days when you experienced buffering issues, the best practice was to pause the video for a minute, allowing the video to completely buffer. These days, videos will buffer only so much before the buffering stops altogether. Why? Because users weren’t watching videos all the way through.
YouTube didn’t find buffering an entire video necessary when users were leaving before finishing a full video. Adopting the DASH technique allowed YouTube to cut down on resources and to save themselves from stalling out at certain times. The Dash playback method can also be called Just In Time stream. Again, videos are buffered 5-10 seconds at a time then stops. In addition to their optimization, when users are streaming from YouTube, they are automatically presented a specific resolution and bitrate (e.g. 360p).
YouTube vs Netflix
According to a 2013 report from internet monitoring firm Sandvine, YouTube and Netflix accounted for more than half of downstream internet traffic in North America. Netflix’s shared 31.6%. YouTube behind with 18.7%. Although these two giants reached a large population for their streaming media, how Netflix and YouTube provides their service is different:
- Netflix can’t be shared or viewed outside of Netflix.
- Netflix has no uploads or user submissions to worry about.
- Netflix uses adaptive bitrate streaming.
- In addition to their massive unique monthly views, YouTube has to upload, convert, compress, and store just as many videos.
- YouTube has to support code for legacy implementations to social networking and websites.
- YouTube uses constant bitrate streaming.
These two large streaming service providers are are heavily dependent on their server and technology. To continue optimizing their server and technology,they also focus on video compression and codecs.
Compression
Digital images are all made up of tiny squares of solid color called pixels. The number of pixels used in an image is called resolution. H.264 is a video compression codec that is widely used to compress video format. Here’s a few examples of it being implemented:
Imagine you’re watching a TV show or an action movie. If you have two characters in a video talking to each other, the background isn’t going to change compared to an action scene. Instead of storing the picture of the background multiple times, the compression only includes the pieces that changed, allowing the file to throw out the rest of the data.
An uncompressed video, which doesn’t use a codec, will detail every piece of the scene 24 times per second (24fps is most commonly used). By using a codec, it will see that Ned and Todd are moving while the background stays the same. Therefore, the codec paints the background in the living room once with the ability to keep the background on screen for 8 seconds. This saves time and space because so the data is in no need of repeating the steps.
An uncompressed video will describe most Simpson’s character as 1.yellow pixel 2.yellow pixel 3.yellow pixel 4.yellow pixel 5.yellow piexel, at least one million times. By compressing and utilizing a codec, the pattern would simply input “Yellow Pixel x 1000”. Assuming the background has 120 shades of red, the codec will cut it down to 40 shades because the difference isn’t too significant. Repeat the process multiple times and a 20GB digital video will boil down to 1GB.
Codec
How exactly are the files being compressed? That’s where codec comes in. Codecs are the method for compressing the video size. Here’s a simplified example from /u/ sje46 on Reddit:
Uncompressed That Sam-I-Am! That Sam-I-Am! I do not like that Sam-I-Am! Do you like green eggs and ham? I do not like them, Sam-I-Am! I do not like green eggs and ham! Would you like them here or there? I would not like them here or there. I would not like them anywhere. I do not like green eggs and ham. I do not like them, Sam-I-Am.
Total Characters = 322