YouTube is about connecting individual/group of people with individual/group of people.
According to a story, Hurley and Chen developed the idea for YouTube during the early months of 2005, after they had experienced difficulty sharing videos that had been shot at a dinner party at Chen’s apartment in San Francisco. Karim said the inspiration for YouTube first came from Janet Jackson‘s role in the 2004 Super Bowl incident.
The vast majority of its videos are free to view, but there are exceptions, including subscription-based premium channels, film rentals, as well as YouTube Red (Isn’t available in India yet), a subscription service offering ad-free access to the website and access to exclusive content made in partnership with existing users.
Let’s start our quest
If you want to watch all the videos which were uploaded to YouTube in one day, by the time you finish watching, the year will be 2081. 400 hours of videos uploaded every minute that’s like watching over 184 movies.
There can be any type of video can come up to YouTube to be uploaded by any user and from anywhere from the World. The videos are captured by any devices with different resolutions, types and formats. YouTube should do processing on videos to make sure that all your videos must be playable on YouTube so other users can see it.
Why not just let people watch the original upload?
You might upload a video with a great quality which has great resolution but then it was too big in size. So it is difficult to be distributed on Internet as the video will constantly buffering while watching it and may be drill down your phone/device memory. If large number of people will do that then it will probably break the Internet which is not good at all J.
So to not break down the Internet, YouTube does some processing over the video. Once you just upload a video, the first thing YouTube will do is to figure out how to make it smaller in size.
YouTube checks the video and tries to understand the resolution and frame rate of it and then generate something called ‘Mezzanine’ means another High Quality copy of your video.
Mezzanine helps to make the video in chunks, 5 seconds each. Then pass each chunk off to different machines and how that machine processes just this little piece of video and then it run through some Mathematics to generate compressed version of it. This process happens again and again and again, making smaller version of this 5 seconds chunks [for resolutions like 1080, 720, 480, 360, 240, 144]. After that all of these corresponding chunks get stitched back together.
YouTube generates around 25 different video outputs depending on the resolution of the input coming in. So if user has good bandwidth then he can view High Resolution video on (Internet) TV/Computer and in case you are stuck with slow Internet then there is still smaller version that you can watch.
How does YouTube actually make all these smaller version of original videos?
As we are talking about media files, you might have heard the word ‘Codec’. A Codec, a blend of the words ‘Compression’ and ‘Decompression’, is a computer program that can use compression to shrink a large movie file, or convert between analog and digital sound.
Why Codecs Are Required?
Video and music files are large, which means they are usually difficult to quickly transfer them over the internet. To help speed up downloads, mathematical codecs were built to encode, or shrink a signal for transmission and then decode it for viewing or editing. Without codecs, downloads would take three to five times longer than they do now.
There are hundreds of codecs being used on the internet, and you will need combinations that specifically play your files. There are codecs for audio and video compression, for streaming media over the internet, speech, video conferencing, playing MP3s, or screen capture. Some common codec examples are MP3, WMA, Real Video, Real Audio, DivX and XviD but there are many other obscure codecs as well.
So bunch of cleaver mathematics can shrink a file to make it much smaller. So using Codec, we can get 100’s of times smaller without any visual loss and quality. So Video codecs are all about simplifying a video down in towards most important and what was actually notice. Before you compress a video, you can think about it as just bunch of dots but sometimes these dots are similar. So you can say that this specific pixel is like that pixel and that’s where entire Savings comes in.
In any video, there are some parts which are not changing frequently but there are other parts which are constantly changing. So all the stuff that doesn’t change, doesn’t need to keep getting refresh with each new frame which shrinks the file size. So for example, if you have a dance video of Michael Jackson then probably it will make hard for Codec to make it shrink as frames are constantly changing but if you have speech video of Leonardo Dicaprio then it will not that hard for Codec to work on as the frame change ratio is not that high.[The Highlight area with Yellow border is not moving frequently, so that part doesn’t need to refresh for each new frame.]
YouTube run experiments. Asking people to watch the videos and check which looks best to them (In background, they have implemented various algorithms which gives certain output and they show output to users. The algorithm gets chosen which output like most by the people which also reduces harms like Banding and Blocking. ) While they are experimenting with micro blocks, they keep in mind that while reducing the size, the resolution must not lost as well as the smooth out the differences to make it as clean as possible.
YouTube does more than just uploading a video. It will also generate best ‘Thumbnail’ options for your video and recognizing speech in order to generate automatic captions. Using Machine Learning to figure out what‘s going on in your video, they can make it more searchable.
Mathematics, computer and coding are crazy because this is happening for thousands of videos every single second. So just think about the total size of YouTube…! Stay Amazed!