In video compression, H.265 (also known as High Efficiency Video Coding, or HEVC) is a widely used standard. It's designed to improve video quality, compression efficiency, and reduce file sizes compared to its predecessor, H.264.
In H.265, like in H.264, there are several types of frames:
- I-Frames (Intra-coded frames): These are complete frames that do not depend on any other frame. They are encoded using spatial redundancy within the frame itself. In other words, an I-frame is a fully independent image, like a standalone photograph. I-frames provide random access points, which means you can start decoding the video from any I-frame without needing any information from previous frames. They are relatively large in size compared to P-frames and B-frames because they don't take advantage of temporal redundancy.
- P-Frames (Predictive-coded frames): These frames are encoded based on the difference (motion vectors) from a previous I-frame or P-frame. They only store the changes that occur since the last reference frame (which could be an I-frame or a previous P-frame). P-frames are more compressed than I-frames because they don't have to store as much raw pixel data.
- B-Frames (Bi-directional frames): These frames are encoded based on the differences from both the preceding and following frames (which can be either I-frames, P-frames, or even other B-frames). B-frames provide the highest compression because they take advantage of both past and future frames. However, they also require more processing power to decode.
Now, let's consider what happens between I-frames:
- P-Frames: These rely on the previous I-frame or P-frame to generate their content. They only store the changes that occur since the last reference frame. This means they require less data to represent changes compared to an entire frame.
- B-Frames: These frames can use information from both preceding and following frames. They are even more efficient in terms of compression because they can take advantage of motion occurring in both directions. This makes B-frames highly efficient in terms of file size but also more computationally intensive to decode.
So, in a video stream encoded with H.265, a sequence typically starts with an I-frame, followed by a series of P-frames and B-frames. This pattern continues throughout the video. The frequency of I-frames and the ratio of P-frames to B-frames can be adjusted based on encoding settings. Having a good balance between I-frames, P-frames, and B-frames is important for achieving a good trade-off between compression efficiency and video quality.