top of page

Video Compression Explained

Ever wondered how such high-quality videos are so small in size?

Well, Tech Aficionado brings you an article on how video compression works.


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. 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 but even we can only download like two and a half gigabytes in five minutes, that's a long way 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. That's the magic of video compression which works mostly by minimizing redundancy in the video data. 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. There are two ways to compress:-


  • Video spatial compression (Intraframe)

  • Temporal compression (Interframe)


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 macroblocks then discrete cosign, transformation, quantizing, encoding and whatnot 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 in some images. This red rectangle can be compressed more than others like this complicated photograph because the red rectangle is very simple with a lot more redundancy but that's how a JPEG uses spatial compression.


video compression explained, how is video compressed, video compression technique, how are such high quality videos uploaded online, how are videos compressed, tech aficionado, tech tricks, tech tips, harshal Srivastava, tech news, tech blog, interesting tech facts

Now for a 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 frame by frame you'll notice that many frames are almost completely identical, that's redundancy that can be easily compressed. For example for all the parts of the video that don't need to change from one frame to the next. 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 macroblocks and each macroblock 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 I frame which is pretty much just a JPEG.


video compression explained, how is video compressed, video compression technique, how are such high quality videos uploaded online, how are videos compressed, tech aficionado, tech tricks, tech tips, harshal Srivastava, tech news, tech blog, interesting tech facts

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 I frame 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. The pixelated videos have square pixels and they’re 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.


video compression explained, how is video compressed, video compression technique, how are such high quality videos uploaded online, how are videos compressed, tech aficionado, tech tricks, tech tips, harshal Srivastava, tech news, tech blog, interesting tech facts

Without the I frame 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 and 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.


Hope you liked the post and if you did, make sure to hit the like button and comment on the post if you like it. Do share it with your friends and family.

Easy up Tech - Tech Aficionado



31 views0 comments

Recent Posts

See All

Comments


bottom of page