Video compressing normally happens directly by the codec itself. It is realized based on two main strategies. They are called Intraframe and Interframe. If you compress too much, you will see artifacts.
Intraframe (Spatial)
The Intraframe compression gets handled witin every frames itself. It looks for redundancy and creates blocks out of it. It works a little bit like JPEG.
Interframe (Temporal)
The Interframe compression gets handled over serveral frames. The trick is the usage of different types of frames. Most frames just contain the delta to remove redundancy.
Typical structure
/------------------ ----\ /------ ----\ | /-----\/------------\ | /-----\/------------\ | /---- ↓ ↓ ↓ | ↓ | ↓ | ↓ ↓ ↓ ... I-Frame B-Frame B-Frame P-Frame B-Frame B-Frame I-Frame ... ↑ ↑ | ↑ ↑ | ↑ ↑ -----/ \--------------/\-----/ \--------------/\-----/ \-----
Frame type | Contains |
---|---|
I (Intra) | The whole information of the frame |
P (Predicted) | Delta towards the I-/P-Frame in front of it |
B (Bi-directional predicted) | Delta towards the I-/P-Frame in front and behind of it |