Codec and container, differences. Explanation


Free Download Mp4Gain
picture

Codec and container

Confusion between codec and container is very common. And even more if we add file extensions. This post aims to clarify these terms and show the relationship between them.

What is a codec?

The codec term comes from the concatenation of the initials of two words: encoder and decoder. Strictly speaking, a codec is a specification on how to encode a type of information and then be able to decode it. For example, a codec determines how video and audio information is compressed and decompressed. Remember that compression is a specific case of coding in which space is reduced, eliminating redundant information or low perceptual impact

What is a container?

Within the multimedia arena, a container is a specification of how different types of encrypted multimedia content are arranged within a file. These different contents are usually mainly video, audio and text.

Consider the case of a film in digital format. This movie is in an archive. When we open that file, a player runs and we can enjoy the movie. Notice that a movie has video, has audio, subtitles, information about its author, information about its duration, etc. For the convenience of the user, all these elements are grouped within a single file. The order in which they are saved in that file is the container specification.

Connection

The video information that is inside a container is usually compressed, that is, it usually follows the specification of a specific codec. The same goes for audio information. The confusion appears when there are containers and codecs with very similar or even the same names.

The most popular codecs

The most popular video codecs currently are Theora, VP8, MPEG-2, h.264, Xvid, and Divx. Regarding audio codecs: AAC, FLAC, MP3, Vorbis (ogg) and WMA are the most abundant.

The most used containers are AVI, Divx, Matroska, Flash video, MP4, MPEG, Ogg, Quicktime, MXF and WebM. Since containers are intrinsically linked to files, each one also specifies one or more possible file extensions:

AVI -> .avi
Divx -> .divx
Matroska -> .mkv, .mk3d, .mka, .mks
Flash video -> .flv, .f4v
MP4 -> .mp4
MPEG -> .mpg, .mpeg
Ogg -> .ogg
Quicktime -> .mov, .qt
MXF -> .mxf
WebM -> .webm

And to open a container and see its contents?

Containers are interpreted through a media player application, such as Windows Media Player, Quicktime (application with the same name as a container), VLC, Plex, RealPlayer or Winamp, etc.

A good option is the VLC player, since it offers compatibility with all formats under almost any platform and even allows you to play incomplete files (useful feature if you want to start playing audiovisual content that has not yet finished downloading, as long as it is be progressive). In addition, it is freely distributed.


Free Download Mp4Gain
picture


Mp4Gain Main Window
picture


Mp4Gain Features
picture


Free Download Mp4Gain
picture

Codecs: How an audio or video codec works

To understand in a simple way what a codec is and how it works, the first thing we have to keep in mind is that the human voice is a continuous (analog) waveform, while the information that circulates through a data network is discrete ( digital). This means that if we want to send packets with data that contain the information needed to reproduce a voice fragment, we will have to digitize the voice beforehand.

codecs

The process of converting an analog signal to a digital signal is done through an element called an encoder. If the encoder is also capable of performing the opposite process, that is, moving from a digital signal to an analog signal even if only approximately, then we will have an encoder-decoder. An encoder-decoder is also called a ‘codec’.

Although it may seem that we would only be interested in selecting one or two codecs taking into account the voice quality (MOS, Mean Opinion Score) and bit-rate parameters that each codec needs, the truth is that we also have to face our network Look closely at the size of the packets that we are going to send since each voice packet is also made up of bits that are used for routing and error correction issues. As they add load, they saturate the network and make the entire system go slower. Do we reduce the number of packages we have to send making them larger? It is not always a good idea because the loss of a large package will have a greater impact on the output, even a cut in communication! What is recommended in these cases is to have a certain compromise between the number of packets that are sent to the network and the protection we want to have. The reference size should be about 20ms of voice per package.

codecs

How codecs work

The codecs reduce the information of the clips to facilitate and enable their publication and viewing through the Internet. There are two methods of compression, the so-called spatial and temporal compression.

In the first one, reduce the information by compressing the existing one inside each frame. Instead of describing the pixel-to-pixel image, pointing out for example the position and color of the pixels, the compression codec generalizes describing similar areas and their light and color characteristics. For example, instead of reproducing a blue sky pixel by pixel, it would be described as an area with similar light and color characteristics. In this sense, the less varied details an image presents, the codec can generalize and compress more easily. Creating videos with simple backgrounds facilitates compression and reduction, just as working with a tripod instead of a camera in hand means stabilizing the backgrounds and therefore facilitating subsequent compression.

The other compression method is temporary, where the information between consecutive frames is compared and only the details that vary are stored. The reference frames from which the differences are analyzed and the subsequent ones are supported are called keyframes and contain the complete image. On the contrary, the frames that reflect the differences are called “delta frames” and only contain the information of the areas that vary with respect to the previous images.

In general, videos that show few changes between frames are compressed better and this necessarily affects the realization. At present, both the television and the cinematographic realization tend to use the camera in motion. However, the compression of dynamic videos is more problematic than the cases of more static images.