More often than not, beginners exploring digital video tend to be confused with the difference between a video container and video codec
Here’s a quick explanation to clear the air.
Video Container is a Codec Storage House
A video container is also called a video wrapper. And inside the wrapper is stored a codec.
Imagine a suitcase. Within it, you can place as many things as you wish. The suitcase is only one item (container) but it can contain within it as many things as it can accommodate (codec).
In other words a container (suitcase) allows the different components of a video (video, audio, images, subtitles etc) to be stored there through a codec. From the image above the area in blue is the video container.
A video container is just like a house or a store that’s used to store various components of a video there.
For example if a container allows it, multiple soundtracks, subtitles and so on could be stored in it through a single video file. So, you can imagine these video components being stored in different rooms but in one house.
Examples of containers are OGG, Matroska, AVI, MOV and MPEG, which includes MP4. They are popularly referred to as file formats.
Codec Carries Different Video Components
Codec is the short form for coding and decoding (code/decode) or compressing and decompressing (compress/decompress)
A large video file size is compressed according to the quality needed and the storage space available. When the video file is played back, it’s decompressed (opened up) by the application playing it, allowing the viewer to enjoy the quality intended by the creator.
This is useful when you wish to share a high quality video with others but there’s a file size limit imposed. An example is a smartphone video shot in HD (High Definition) which you would like to share over WhatsApp.
WhatsApp imposes a file size limit of 16MB. If you’ve a long video with a larger file size you would want to compress it with a codec. The codec you choose will reduce the file size and provide you with the best video quality possible to enable easy uploading. The recipient, too, especially those with slower Internet connections would be able to download and view it quickly.
Examples of video codecs are H.264, Xvid, Divx, DV, WMV, MPEG-1, MPEG-2 and many more.
Examples of audio codecs are MP3, FLAC, AAC and many others.
To recap a video container is a house and a codec comprises of bundled video components stored in the house.