Video Compression

This is a continuation of the work that I did for my school project.  Read the first post here.

There are a few factors that come into play when video is compressed.  I’ve done my best to describe what’s happening below.

 

Compression

Compression is how the computer saves space when storing data.  Due to its complexity, video contains a particularly large amount of information.  Compression seeks to save space by getting rid of information that is duplicated and/or information that the viewer will not notice is missing.  If too a video file is compressed too heavily, artifacting will appear.

too much compression

Artifacting caused by too heavy compression; [Source (modified): San Dieguito Live (Season 1 Intro)]

 

Spatial (Intra-frame) Compression

This type of compression is applied within a single frame.  Pixels are grouped into blocks, where similarities help reduce the amount of data.  These blocks are usually 4×4 or 16×16 depending on the level of compression.  This type of compression is also used in JPEG images.

 

Temporal (Inter-frame) Compression

This type of compression is applied over multiple frames known as a GOP (Group of Pictures).  The group starts with an I-Frame (also known as the key frame).  This frame can be displayed independent of all of the other frames.  The key frame is following by a series of P-frames and/or B-frames (depending on the codec).  P-frames are predicted frames based on previous frames.  B-frames are even more flexible in that they predict based on previous and future frames.  This makes the resultin   g file more efficient.

group of picturesA group of pictures [Source:https://en.wikipedia.org/wiki/Video_compression_picture_types#/media/File:I_P_and_B_frames.svg]

 

Color Sampling

Color sampling refers to which color information gets stored.  The amount of information available is often reduced because it is not visible to the human eye, or isn’t important to the reproduction of the image.  Color sampling is expressed in the following format: 4:2:2.  Each number represents how many samples of something there are per block of four horizontal pixels.  The first number represents that number of luminance samples.  Luminance is the difference in brightness.  It is most important for the detail in the image, but does not contain color information.  The second and third numbers represent the samples of chrominance on even and odd lines of pixels respectively.  So, the example 4:2:2 means that every pixel will have its own luminance sample, and both even and odd lines will have a chrominance sample for every other pixel.  A lack of chrominance samples can lead to inaccurate representation of the image (see below).  Finally, there is sometimes a fourth number.  This is for the alpha channel, or transparency, where the value represents the number of samples in the same 4 pixel block.

Color Sampling full  420 color sampling

Left: Intended Image (clean lines); Right 4:2:0 Color Sample (rough edges due to absent color information)

 

Bit-Depth

Bit-Depth is the number of bits that represent the value for each pixel.  If the bit depth were only 1-bit, there would be only two possible values, 0 or 1, on or off, black or white.  Most video is 8-bit allowing 256 possible values.  Sometimes 10-bit is used, allowing 1024 values.

 

As always, feel free to leave comments below.  It is possible for me to make errors, and it is important to me that my website is an accurate resource.