MC 11

Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

Multimedia Communication (SW-416)

VIDEO COMPRESSION

Dr. Areej Fatemah email: [email protected]


Video Compression

1920
HD: 1920 x 1080
2,073,600 Pixels

1080 If transmission of 30fps


62 Million Pixels Per Second

Add 24 bits of color information


1920 x 1080 x 24bits x 30fps
= 1.5Gbps
Goal: Minimize Redundancy in the Video
Video Compression
• Video compression algorithms look for spatial and temporal redundancies.
◦ By encoding redundant data a minimum number of times, file size can be reduced.
• Imagine, for example, a one-minute shot of a character’s face slowly changing
expression. It doesn’t make sense to encode the background image for every frame:
instead, you can encode it once, then refer back to it until you know the video
changes.
Video Compression

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

Spatial (intra-frame) coding

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.

• B-Frame (bidirectionally predictive Interpolated Frame)


◦ B-frames are bi-directionally predicted, using data from both the last P-frame and the next
I-frame. The B-frame refers to preceding and succeeding frames, interpolated the data and
encodes the differences.
Video Compression

• 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.

I Frame P Frame B Frame


Video Compression
• Let’s consider how H.264 works, as a generalized example. The frame is divided into
sections called macroblocks, typically consisting of 16 x 16 samples.
• The algorithm does not encode the raw pixel values for each block. Instead, the
encoder searches for a similar block in an older frame, called the reference frame.
• If a valid reference frame is found, the block will be encoded by a mathematical
expression called a motion vector, which describes the exact nature of the change
from the reference block to the current block.
• When the video is played back, the video player will interpret those motion vectors
correctly to “retranslate” the video.
• If the block doesn’t change at all, no vector is needed.
Video Compression
Temporal (intra-frame) coding

Extreme Case – Stationary video Repeat (frame,4)


Video Compression
Temporal (intra-frame) coding

Some parts change

Doesn’t change (much)


Video Compression
Divide frame into blocks

Repeat only blocks that don’t change


Video Compression

Not Identical
Video Compression

Block Motion Estimation


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

You might also like