MC 11
MC 11
MC 11
VIDEO COMPRESSION
1920
HD: 1920 x 1080
2,073,600 Pixels
Encoder
Decoder
Video Compression
Image Compression
36 MB 1.8 MB
Video Compression
Image Compression
Spatial Compression Temporal Compression
(Intra-Frame) (Inter-Frame)
JPEG MPEG, H.264
Video Compression
Image Compression
(JPEG – Spatial Compression)
Video Compression
36 MB 1.8 MB
Video Compression
• I-Frame (Intra Frame)
◦ Every I-frame contains all the data it needs to represent an image. Intra-coded full image,
very similar to the JPEG image, encoded with DCT, quantization, run-length coding and
Huffman coding. I-frames are fully encoded images.
• P-Frame (Predicted Frame)
◦ Uses delta encoding. The P frame refers to preceding I and P-frames. DPCM encoded
macro blocks, motion vectors possible. P-frames are predicted based on how the image
changes from the last I-frame.
• P frames need only store the visual information that is unique to the P-frame.
◦ In the above example, it needs to track how the dots move across the frame, but Pac-Man
can stay where he is.
• The B-frame looks at the P-frame and the next I-frame and “averages” the motion
across those frames.
◦ The algorithm has an idea of where the image “starts” (the first I-frame) and where the
image “ends” (the second I-frame), and it uses partial data to encode a good guess, leaving
out all the redundant static pixels that aren’t necessary to create the image.
Video Compression
• The sequence of I, P
and B frames is not I
standardized but can
B
be chosen according
B
to the requirements P
of the application.
B
• This allows the user to B
chose his/her own
P
compromise between
video quality, I
compression rate, Time Axis
ease of editing, etc.
Video Compression
• I-frames are compressed independently, in the same way still images are saved.
Because I-frames use no predictive data, the compressed image contains all the data
used to display the I-frame.
◦ They are still compressed by an image compression algorithm like JPEG.
◦ This encoding often takes places in the YCbCr color space, which separates luminosity data
from color data, allowing motion and color changes to be encoded separately.
• For non-predictive codecs like DV and Motion JPEG, that’s where we stop.
• Because there are no predictive frames, the only compression that can be achieved is
by compressing the image within a single frame.
◦ It’s less efficient but produces a higher-quality raw image file.
Video Compression
• In codecs that use predictive frames like H.264, I-frames are periodically shown to
“refresh” the data stream by setting a new reference frame.
• The farther apart the I-frames, the smaller the video file can be. However, if I-frames
are too far apart, the accuracy of the video’s predictive frames will slowly degrade into
unintelligibility.
• A bandwidth-optimized application would insert I-frames as infrequently as possible
without breaking the video stream. For consumers, the frequency of I-frames is often
determined indirectly by the “quality” setting in the encoding software.
• Professional-grade video compression software like ffmpeg allows explicit control.
Video Compression
• Video encoders attempt to “predict” change from one frame to the next. The closer
their predictions, the more effective the compression algorithm.
• This is what creates the P-frames and B-frames. The exact amount, frequency, and
order of predictive frames, as well as the specific algorithm used to encode and
reproduce them, is determined by the specific algorithm you use.
Not Identical
Video Compression
Motion Compensation
Video Compression
Current Frame Next Frame
Motion
Compensation
Residual Frame
Highly Compressible
Subtraction Less Information
Video Compression
Inter-Frame
Intra-Frame
(JPEG Compression)
Video Compression
• H.264 MPEG-4 AVC
• H.265 HEVC
• VP9