Data Compression‎ > ‎

Video Compression

Without video data being compressed it would not be possible to have streaming video over the Internet or even DVD movies. The time and space required, respectively, would be too great. A video can be thought of as a series of still images played in quick succession to give the appearance of motion. The 'moving pictures' part of a video is quite often accompanied by an audio track. The frequency that one image replaces another is called the frame rate. A rate common to many movies is 24 frames per second (fps). Video dimensions, like images, are measured in pixels. Similar to an mp3 audio recording, the quality of a video is measured in the number of kilo bits per second (Kbps) that is played back at. The higher this number the better the quality the video will have.

If no compression was used, a video with dimensions of 640 x 480 pixels (with each pixel using 24bits to store its colour information) would need 640x480x24 = 7,372,800bits of memory storage per frame. If the video was played at a frame rate of 24fps then one second's playback would consume 7,372,800x24 = 176,947,200bits or 22,118,400Bytes or 21,600KB. One minute's playback would need 21,600x60 = 1,296,000KB or 1,265.625MB or 1.27GB. This is about 25% the size of a standard DVD disc. So, a standard DVD disc could hold about 4 minutes of uncompressed 640x480 video. Note: this example video contains no audio track. If it did more storage would be required. So, storing video in an uncompressed format is plainly impractical. 

Compression methods

There are basically two methods used to compress video data. To quote the Wikipedia article mentioned in the links section below
Video data contains spatial and temporal redundancy. Similarities can thus be encoded by merely registering differences within a frame (spatial), and/or between frames (temporal). Spatial encoding is performed by taking advantage of the fact that the human eye is unable to distinguish small differences in color as easily as it can perceive changes in brightness, so that very similar areas of color can be "averaged out" in a similar way to jpeg images... With temporal compression only the changes from one frame to the next are encoded as often a large number of the pixels will be the same on a series of frames.


Also, from Intraframe versus Interframe compression:

One of the most powerful techniques for compressing video is interframe compression. Interframe compression uses one or more earlier or later frames in a sequence to compress the current frame, while intraframe compression uses only the current frame, which is effectively image compression.

The most commonly used method works by comparing each frame in the video with the previous one. If the frame contains areas where nothing has moved, the system simply issues a short command that copies that part of the previous frame, bit-for-bit, into the next one. If sections of the frame move in a simple manner, the compressor emits a (slightly longer) command that tells the decompresser to shift, rotate, lighten, or darken the copy — a longer command, but still much shorter than intraframe compression.


Compression formats

Video compression formats are numerous and it can be a confusing area. Often they are termed as "container formats". This means they are designed to contain multimedia content. In turn various codecs are used to compress the data within the containers. The video and audio components of the complete video will use their own compression formats. For example, in an FLV file the audio track could use MP3 for compression whilst the video could be compressed using Sorenson Spark (an H.263 standard format). The most common formats used on the Internet are: FLV (Flash video), MP4AVISWF and MOV. MP4, AVI, MOV anf FLV are container formats. Note: MP4 is a member of the MPEG family of formats. To quote Dr Tim Bell of Canterbury University:

Most commonly used video compression systems are variations of MPEG (a relation of JPEGs which are  designed for moving images), and there are many variants of MPEG formats that are used for DVDs, BlueRay, online video and digital cameras.

Below is a screenshot of the same video recording saved in different formats and using different optimisation settings. 3GP is a mobile phone format.


When viewed the quality of all but the 3GP clips appears the same. This illustrates that substantial savings can be gained from careful optimisation. As can be seen from the screenshot above the raw AVI is the biggest and the FLV is the smallest.

Below are screenshots of the file information for the AVI videos. Note that the bit rate is much higher for the raw one. This difference is reflected in the Bits/(Pixel*Frame) figures as well. The smaller video could be further optimised by lowering the frame rate (say to 12), bit rate (say to 256Kbps) and bit colour depth (say to 16).

 Raw AVI recording (39MB)
 
 Edited AVI recording (513KB)
 

Below are screenshots of a video editing program's editing settings for saving/converting a video to the AVI format. Note in the second one the number of codecs in the drop down list that can be used.

 
 


The following link points to a table on a Wikipedia page that contains common codecs, such as the MPEG family, and their development over time: codec timeline

Free video converters

  • The above screenshots were taken from the FormatFactory editor program. It is a good program that is freely available on the Internet, but be sure to untick the Google toolbar and Ask search engine options during the install process. Download from CNET
  • This web page has information on free converters; experiment!: Lifehacker
  • MediaCoder - seems worth a try; download from this page
  • Handbrake - Mac as well as Windows versions.
  • There are many online converters, though they usually give limited conversion options. Google around and see what you can find.

Further reading





Comments