|What is codec, bitrate and key frame?|
A video file consists of audio and video data, and the file needs compressing to reduce its size.
(If not compressed, the file size will get up to 100 times bigger.)
A CODEC refers to the COding and DECoding modules together.
Most commonly used video codecs are MPEG4, XVID, DIVX and WMV and audio codecs MP3, WMV and AAC.
The encoding method used for video files is lossy compression. With lossy compression, data size is reduced.
It does not obtain 100% original data but results in data loss. So, the higher compression ratio, the worse image/sound quality.
A bitrate is the number of bits that is compressed for video/audio data per second.
The higher the bitrate, the lower the compression ratio and the better the image/sound quality.
The lower the bitrate, the smaller the size of the encoded file but the lower the image/sound quality.
The basic unit for bitrate is BITS PER SECOND. As 8 bits are 1 byte, a video file encoded at 800 kbps will be 100 kbytes in size per second.
Early video codecs were designed to compress and save each frame as jpeg.
This method was very easy to implement but not easy to increase the compression ratio because it still needed lots of data for static images.
To improve compression efficiency, mpeg and later codecs were designed to detect motion changes and save their data only.
However, the drawback of this mechanism is that it is hard to process skips and jumps during playback as the data hold information about motion changes only.
A solution to this was placing keyframes along the timeline which contain all the information.
Key frames are typically placed every 5 to 10 seconds or sometimes per second.
(Shorter intervals make it easy to navigate but reduces the image quality to the size.)