News & Views - a blog from Dataton

What is the difference between a codec and a container?

Written by David Aleksandersen | 4. April 2018

Are you finding containers and codecs and the difference between them a tad challenging? You are not the only one! 

CONTAINERS VS CODECS

As the range of digital audio, video and photo formats continues to grow, it can sometimes be hard to make a clear-cut distinction between containers and codecs. A lot of that uncertainty can be traced to the lack of hard and fast standards, confusing filename extensions and poorly used marketing terms. This article will – hopefully – make the difference between a codec and a container a little easier to understand.

What is a container?

A container is what most of us talk about when it comes to file format. The container defines the structure and content of the file, which can be audio, video and other metadata such as subtitles, or menus and menu structure. Some containers are limited to audio, photo or video only, or you can have containers that combine audio and video.

Among the most well-known containers you’ll find AIFF (audio only), TIFF (photo only), QuickTime (audio and video), MP4 (audio and video) and Matroska (audio and video).

A QuickTime container can, according to the Wikipedia site, support the following codecs:

Video: MPEG-2 (OS X Lion or later), MPEG-4 Part 2, H.264, H.263, H.261, Apple ProRes, Apple Pixlet, Cinepak, Component Video, DV, DVC Pro 50, Graphics, Motion JPEG, Photo JPEG, QuickTime Animation, Sorenson Video 2 and Sorenson Video 3.

Audio: AAC (MPEG-4 Audio),HE-AAC, Apple Lossless, MP3, AMR Narrowband, MS ADPCM, QDesign Music 2, Qualcomm PureVoice (QCELP), IMA 4:1, MACE 3:1 (Mac OS X v10.6.x only), MACE 6:1 (Mac OS X v10.6.x only), ALaw 2:1, ULaw 2:1

Which then leads us on to the next question – what is a codec?

What is a codec?

A codec is a way to code (encode) and decode streams of digital data, such as a video film. Basically, it's the algorithm used to compress the media. The purpose of the codec can typically be to compress the stream to reduce file size before it is stored or transmitted, or to make the video playable on devices other than the one on which it was created. To play a video inside a web page typically requires a different codec than if you had played the file directly in your video player application. Some examples of codecs are HAP (video), H.264 (video), MP3 (audio) and FLAC (audio). 

There are a vast number of codecs available and each of them has its own set of strengths and weaknesses. Understanding which codec to use can be a challenge because of this – and so can licensing rights. But that's a whole other blog…