A video codec is an electronic circuit or software that compresses or decompresses digital video. It converts raw (uncompressed) digital video to a compressed format or vice versa. In the context of video compression, "codec" is a concatenation of "encoder" and "decoder"—a device that only compresses is typically called an encoder, and one that only decompresses is a decoder.
Contents
- History
- Applications
- Video codec design
- Commonly used video codecs
- H265MPEG H HEVC codecs
- H264MPEG 4 AVC codecs
- H263MPEG 4 Part 2 codecs
- H262MPEG 2 codecs
- Microsoft codecs
- Google On2 codecs
- Lossless codecs
- Other codecs
- Codec packs
- References
The compressed data format usually conforms to a standard video compression specification. The compression is typically lossy, meaning that the compressed video lacks some information present in the original video. A consequence of this is that decompressed video has lower quality than the original, uncompressed video because there is insufficient information to accurately reconstruct the original video.
There are complex relationships between the video quality, the amount of data used to represent the video (determined by the bit rate), the complexity of the encoding and decoding algorithms, sensitivity to data losses and errors, ease of editing, random access, and end-to-end delay (latency).
History
Historically, video was stored as an analog signal on magnetic tape. Around the time when the compact disc entered the market as a digital-format replacement for analog audio, it became feasible to also store and convey video in digital form. Because of the large amount of storage and bandwidth needed to record and convey raw video, a method was needed to reduce the amount of data used to represent the raw video. Since then, engineers and mathematicians have developed a number of solutions for achieving this goal that involve compressing the digital video data.
Applications
Video codecs are used in DVD and video CD players and recorders, video broadcast systems, personal computers, and a variety of other applications. In particular, they are widely used in applications that record or transmit video, which may not be feasible with the high data volumes and bandwidths of uncompressed video. For example, they are used in operating theaters to record surgical operations, in IP-based security systems, and in remotely operated vehicles such as ROVs and UAVs.
Video codec design
Video codecs seek to represent a fundamentally analog data set in a digital format. Because of the design of analog video signals, which represent luminance ("luma") and color information (chrominance, "chroma") separately, a common first step in image compression in codec design is to represent and store the image in a YCbCr color space. The conversion to YCbCr provides two benefits: first, it improves compressibility by providing decorrelation of the color signals; and second, it separates the luma signal, which is perceptually much more important, from the chroma signal, which is less perceptually important and which can be represented at lower resolution to achieve more efficient data compression. It is common to represent the ratios of information stored in these different channels in the following way Y:Cb:Cr. Refer to the following article for more information: Chroma subsampling.
Different codecs use different chroma subsampling ratios as appropriate to their compression needs. Video compression schemes for Web and DVD make use of a 4:2:1 color sampling pattern, and the DV standard uses 4:1:1 sampling ratios. Professional video codecs designed to function at much higher bitrates and to record a greater amount of color information for post-production manipulation sample in 3:1:1 (uncommon), 4:2:2 and 4:4:4 ratios. Examples of these codecs include Panasonic's DVCPRO50 and DVCPROHD codecs (4:2:2), and then Sony's HDCAM-SR (4:4:4) or Panasonic's HDD5 (4:2:2). Apple's Prores HQ 422 codec also samples in 4:2:2 color space. More codecs that sample in 4:4:4 patterns exist as well, but are less common, and tend to be used internally in post-production houses. It is also worth noting that video codecs can operate in RGB space as well. These codecs tend not to sample the red, green, and blue channels in different ratios, since there is less perceptual motivation for doing so—just the blue channel could be undersampled.
Some amount of spatial and temporal downsampling may also be used to reduce the raw data rate before the basic encoding process. The most popular such transform is the 8x8 discrete cosine transform (DCT). Codecs which make use of a wavelet transform are also entering the market, especially in camera workflows which involve dealing with RAW image formatting in motion sequences. The output of the transform is first quantized, then entropy encoding is applied to the quantized values. When a DCT has been used, the coefficients are typically scanned using a zig-zag scan order, and the entropy coding typically combines a number of consecutive zero-valued quantized coefficients with the value of the next non-zero quantized coefficient into a single symbol, and also has special ways of indicating when all of the remaining quantized coefficient values are equal to zero. The entropy coding method typically uses variable-length coding tables. Some encoders can compress the video in a multiple step process called n-pass encoding (e.g. 2-pass), which performs a slower but potentially better quality compression.
The decoding process consists of performing, to the extent possible, an inversion of each stage of the encoding process. The one stage that cannot be exactly inverted is the quantization stage. There, a best-effort approximation of inversion is performed. This part of the process is often called "inverse quantization" or "dequantization", although quantization is an inherently non-invertible process.
This process involves representing the video image as a set of macroblocks. For more information about this critical facet of video codec design, see B-frames.
Video codec designs are usually standardized or eventually become standardized—i.e., specified precisely in a published document. However, only the decoding process need be standardized to enable interoperability. The encoding process is typically not specified at all in a standard, and implementers are free to design their encoder however they want, as long as the video can be decoded in the specified manner. For this reason, the quality of the video produced by decoding the results of different encoders that use the same video codec standard can vary dramatically from one encoder implementation to another.
Commonly used video codecs
A variety of video compression formats can be implemented on PCs and in consumer electronics equipment. It is therefore possible for multiple codecs to be available in the same product, avoiding the need to choose a single dominant video compression format for compatibility reasons.
Video in most of the publicly documented or standardized video compression formats can be created with multiple encoders made by different people. Many video codecs use common, standard video compression formats, which makes them compatible. For example, video created with a standard MPEG-4 Part 2 codec such as Xvid can be decoded (played back) using any other standard MPEG-4 Part 2 codec such as FFmpeg MPEG-4 or DivX Pro Codec, because they all use the same video format.
Some widely used software codecs are listed below, grouped by which video compression format they implement.
H.265/MPEG-H HEVC codecs
H.264/MPEG-4 AVC codecs
H.263/MPEG-4 Part 2 codecs
H.262/MPEG-2 codecs
Microsoft codecs
Google (On2) codecs
Lossless codecs
See the Audio full list and Video full list.
Other codecs
All of the codecs above have their qualities and drawbacks. Comparisons are frequently published. The trade-off between compression power, speed, and fidelity (including artifacts) is usually considered the most important figure of technical merit.
Codec packs
Online video material is encoded by a variety of codecs, and this has led to the availability of codec packs — a pre-assembled set of commonly used codecs combined with an installer available as a software package for PCs, such as K-Lite Codec Pack.