Gadgetory


All Cool Mind-blowing Gadgets You Love in One Place

Video Compression as Fast As Possible

2014-08-10
video compression is a very important aspect of how video streaming websites like YouTube Netflix and Hulu work without it you wouldn't be able to stream such high quality high frame videos like this one first some math let's say you're watching a video with a resolution of 1920 by 1080 pixels that's like 2 million pixels per frame and in this case you've got 30 frames per second that's a whopping 62 million pixels per second if each pixel needs 24 bits or 3 bytes of information you're looking at 178 megabytes of data per second completely uncompressed that would be 51 gigabytes of information for a single 5-minute video we've got pretty fast internet here the office but even we can only download like two and a half gigabytes in five minutes that's a long ways away from 51 fortunately a five minute high-definition YouTube video is not 51 gigabytes it's in fact more like 72 megabytes that's like 700 times smaller how did they do that that's the magic of video compression which works mostly by minimizing redundancy in the video data now there are all sorts of different ways to compress video and lots of different video containers and codecs but I won't go into detail about that because lattice already covered it in this episode and frankly I still don't really understand at all even though I am employed as a video editor so don't tell Linus so here's what you need to know there are two ways to compress video spatial compression and temporal compression also known as intra frame and inter frame respectively seriously who names this stuff anyway I'm going to describe each of these in terms of the JPEG image format and the MPEG video format spatial or interframe compression is applied only to individual video frames to compress a video frame you can use the same process that's used to compress a still image like a JPEG when a JPEG is created color information of the image is reduced in a process called chroma subsampling and then the image is split into sections of 8 by 8 pixels called macro blocks then all of this fancy stuff is done to these blocks to further reduce the file size it's easy to see this effect on an image that has been saved with a high amount of compression all those ugly looking squares are known as compression artifacts some images like this red square can be compressed more than others like this complicated photograph because the red square is very simple with a lot more redundancy but that's how a JPEG uses spatial compression now for an MPEG sometimes called a motion JPEG things are a bit more complicated than just lining up a whole bunch of JPEGs one after the other to be used as video frames doing it that way would not allow for inter frame or temporal compression temporal compression works again by reducing redundancy if you go through a video like this one frame by frame you'll notice that many frames are almost completely identical that's redundancy which can be easily compressed for example for all the parts of this video that don't need to change from one frame to the next like all this whiteness around me all we need is an instruction for those parts of the frame which says don't change anything like JPEG the MPEG standard breaks a video frame into 8x8 pixel macro blocks and each macro block receives instructions on what to do with pixels they already have there are instructions for staying exactly the same for moving rotating changing color changing completely and so on video frames with instructions like this are called keyframes and they use about half as much data as an iframe which is pretty much just a JPEG there are also B frames which are predictions or interpolations between I and P frames B frames use a quarter as much data as an iframe so they really save a lot of space this is all pretty easy to see on a video file that has been saved in an extremely low quality setting like what you're seeing right now again all these awful square thingies are called compression artifacts furthermore sometimes a video file will be corrupted or missing some data when that happens you get an effect like this one this particular effect is caused by a missing iframe which would have cleared away the old image to make room for a new one without the iframe the list of changes in the following B and P frames are applied to the wrong image so now you know why a video sometimes looks weird it gets all blocky those artifacts are a result of the video compression being either too high or else some kind of error in the coding or transmission of the video data now listen if none of that made any sense everything I've said can be broken down to one thing bitrate the bitrate is the amount of data or bits that are being used every second if a video has a low bitrate it will be low resolution and/or low quality with lots of compression artifacts if a video has a high bitrate it will be high quality and/or high resolution so the more bits you have to work with the better the video will look there's just no getting around that even with the best compression methods video compression is a balancing act between a good-looking video or a small file size you can't have both but if compromise is not your style maybe you'll like fractal design now I'm sure you've all grown accustomed to embarrassing torturous events happening to line us in these spots let's look at them now behind in this manner blinking of moon fractal design is back buying up all of my advertising inventory where I was a little nervous about doing this ad I am however relieved to say that josh has granted me a reprieve I guess Linus is the one he wants to torture so we're using this spot to thank all of you the viewers who went to the survey page and responded so positively to our previous fractal design as on fast as possible that they've decided to continue sponsoring this show so thanks to you guys and thanks to fractal design the company whose cases power supplies and fans bring all of the boys to all of the yards be sure to check back over the next few weeks to learn just what that reference might mean thanks for watching this episode of fast as possible give us a like or a dislike leave a comment subscribe do it subscribe and we'll see you next time
We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites.