What’s the difference between a container and a codec?
You may have heard the terms codec and container within the context of HTML5 discussions, and you’re wondering what exactly the difference between the two things is. Well, here we give a simple explanation of the difference.
Video and audio take up a huge amount of space, and most Internet bandwidth plans would not be able to serve video or audio just in their natural, raw form. That’s why video and audio must be compressed (basically reduced in size), and that is exactly the job of a codec. The term codec came from compressor-decompressor, because it does both the compression – so that the video/audio data can be stored or transferred – and the decompression – so that the data can actually be viewed/listened to, or even transcoded (transcoding is just converting from one encoding to another). Codecs are complex algorithms – some common codecs are VP8, H.264, and Ogg Theora.
Containers are like a box for the codec
Once the codec is used to compress the data, that same data needs to be packaged in a friendly format so that it can be presented to the “outside world”. This is exactly what containers are used for – to act as a sort of a gift box for the video codec. Containers that are well created can handle files that are compressed using many different codecs.
The fundamental difference between containers and codecs
So, the fundamental difference between codecs and containers is that containers are basically like “boxes” which hold files that are compressed by codecs. Some common containers are WEBM, MP4, and OGV – those are often mistakenly referred to as codecs on the Internet, but be aware that there is an important distinction between containers and codecs.