Compression
Compression means 'reducing the file size'. Without compression video files take a lot of space. Size matters in the web & even otherwise. Thus if you want a smaller video you have to compress your video using any of the various compression codecs available.
Types
Intra-frame compression: In this method each frame is compressed individually. Consider for example, if the color information in a video frame is represented by the following:
After intra-frame compression the same data may be represented by:
Suppose if each character is represented by one byte, the video file before compression takes 8 bytes, & after compression it takes only 4 bytes. While playing this file the video decoder (like QuickTime player or Windows Media player) decodes 5B3C to mean BBBBBCCC.
Inter-frame compression: In this method a key-frame is selected at a regular interval, say, every 5 frames. Every other frame is compared with the key frame & only the difference between them is stored. Consider this example, where 'I' & 'II' represent two different frames:
Both these frames take 16 bytes. Now after compression it looks like:
Frame 'I' is taken as key-frame & it is compared with frame 'II'. Now frame 'II' is altered in such a way that only the difference between both these frames are stored. Thus now these frames take only 9 bytes. There is a saving of 7 bytes. A general rule regarding inter-frame compression:
Higher the frequency of key-frames, better the video quality & more the size of file. That is, if you want to reduce the size of your video, just reduce the frequency of key-frames (ofcourse, at the price of quality!). Eg. If every 3
rd frame is a key frame, reduce the frequency so that every 5
th frame now is the key frame. The size of your animation should have reduced.
Some Well-known Compression Codecs
Inter-frame
- Cinepak
- H.261
- H.263
- Intel Indeo® Video
- Sorenson Video
|
Intra-frame
- Planar RGB
- Photo JPEG
- Motion JPEG A
- Motion JPEG B
- Component Video
|
Which Codec to Choose?
This actually depends on your need:
For Web Pages: You may choose from Cinepak or Photo JPEG for maximum cross platform compatability. Photo JPEG is good for short videos where you don't want any compromise on quality. But the Intel Indeo® Video is a better choice if your audience is PC & Mac users with the latest softwares.
For Video Capture: For video capture it is better to choose from intra-frame compression codec. Among the inter-frame codecs, never choose Cinepak. This takes longer to compress your video.
Video Conference: H.261 was specifically developed for video-conference. H.263 is an improvement over H.261.