During video compression, each frame represents a static image. In actual compression, various algorithms are used to reduce the data capacity. IPB is the most common one.
Intra coded frames,Predicted pictures, And
Bi-directional predictive pictures.
An I frame is a key frame and is compressed within a frame. It is the same as AVI compression.
P indicates the forward search. B is a bidirectional search. They all compress data based on I frames.
I frameIt indicates the key frame, which can be understood as the full retention of the frame image; decoding can be completed only by the data of this frame (because it contains the complete frame)
P FrameIt indicates the difference between this frame and a previous key frame (or P frame). During decoding, the difference defined in this frame must be superimposed on the cached image to generate the final image. (That is, the differential frame. P frames do not have full screen data, but only the data that is different from the previous frame)
Frame BIt is a two-way differential frame, that is, B frame records the difference between the current frame and the front and back frames (more complex, there are four situations, but I would like to simply say this, if you are interested, you can refer to the information provided above). In other words, to decode frame B, you must not only obtain the cached image but also the decoded image, the final image is obtained through the superposition of the front and back frames and the data of the current frame. The B-frame compression rate is high, but the CPU will be tired during decoding ~.
From the above explanation, we know that the decoding algorithms of I and P are relatively simple, and the resource usage is relatively small. I only need to complete it myself. What about P, you only need the decoder to cache the previous image and use the previously cached image when P is encountered. If the Video Stream only has I and P, the decoder can ignore the subsequent data, while reading and decoding, linear advances, everyone is very comfortable.
However, many movies on the network use B frames, because B frames record the difference between the front and back frames, which saves more space than P frames, when the file is small, the decoder is in trouble, because not only the previously cached image is used for decoding, but also the next I or P image (that is, pre-read and pre-decoding is required, frame B cannot be simply discarded, because frame B actually contains the image information. If frames B are discarded, they are simply repeated in the previous image, this will cause a frame card (in fact, frame loss), and because movies on the network often use a lot of B frames to save space, a lot of B frames, this will cause more troubles for players that do not support B frames, and the picture gets stuck.
Generally, the I compression rate is 7 (similar to JPG), P is 20, and B can reach 50. It can be seen that using B frame can save a lot of space, the saved space can be used to save more I frames, so as to provide better image quality at the same bit rate.
Of course, when you switch to a digital TV channel, you can see the above for a delay of one or two seconds or a pause.