If the title of this article no longer gives you a headache, then the rest of the article will definitely be. Well, hopefully I can explain it in a way that is understandable to a non-technical person. I am writing this article about video / audio codecs because I once got confused trying to explain this to a friend.
What is a codec? I know you need them to show movies here and there, but what the hell is it really? What really confused me was all the terms I had heard about but never really understood: H.264, DivX, MP4, AVI, MPEG-2, AVCHD, AAC, OGG, MKV, etc., etc. E. Are these all codecs? After reading and studying for a long time, I realized that the world of audio and video codecs and container formats is very confusing. In fact, I didn’t even know the difference between codec and container format until I started researching.
I will not go into details, simply because the topic becomes very short very quickly. Do you really care that 1 hour of uncompressed 1080p 60fps RAW video eats up almost 500GB of disk space? Probably not.
What is a codec?
So what is a codec and what is it for? Simply put, a codec is an encoder / decoder, or, in its original form, a compressor (co) – a decompressor (dec). This is exactly what a codec does: It takes a digital file and compresses (or encodes) it for storage and unpacks (or decodes) it for viewing or transcoding. I will tell you what transcoding is a little later, let’s not get confused at this stage.
It is important to understand that a codec is a kind of specification of what a bitstream should look like. What is bitstream? Not to go into too much detail, this is how the byte sequence should be organized for that particular codec. Each codec has a specific set of recommendations. For example, you can specify the width, height, aspect ratio, etc. Check out this page, but don’t read too much, or you will have a headache:
http: //vvv.x.sf.as.uk/Dave/Multimedia/node262.html
Since this is a specification, I have many ways to convert the data to this format. Therefore, there can be many encoders for one codec. I’ll explain more about encoders in the Popular Codecs section below.
So why do we need all this compression and decompression at all? As I mentioned above, an uncompressed 1080p RAW file takes up almost a whopping 500GB in just one hour. If everything was recorded in this format, you will need your own data center to store all your family videos. This is where compression comes into play. There are different types of compression that translate to different types of codecs. So what are the popular codecs?
Popular codecs
H.264 (MPEG-4 Part 10 AVC) – Also officially known as MPEG-4 Part 10, but H.264 is what you usually hear. Yes, there are multiple names for the same. H.264 is by far the most popular video encoding format. H.264 offers the best of all worlds: smaller files with higher quality.
Again, remember, H.264 is just a codec, you won’t find files with a .h264 extension. This is what container formats are for, and I’ll explain that in the next section. This codec is used in everything from smartphones to digital camcorders and Blu-ray discs. Today, it is also used to deliver a large amount of web videos as it provides excellent image quality with high compression and low bit rate, which reduces the load on streaming servers.
It is also widely supported and will probably be the most popular codec for a long time to come. It is supported by Apple, YouTube, HTML 5, and even Adobe Flash.
The only drawback of H.264 is that its compression algorithms are so good that it is much slower to encode video into this format. You will learn more about this when we talk about transcoding below.
As I mentioned above, there are multiple encoders for the same codec. For the H.264 codec, one of the most popular encoders is x264 from VideoLAN, the same people who make VLC Media Player. x264 is free and open source, but there are many commercial H.264 encoders available as well. It doesn’t matter how the video stream is converted to this format, any H.264 decoder (like VLC) will be able to view the file.
MPEG-2 – Do you still have a large collection of DVDs? All this is done using the MPEG-2 codec. It’s quite old, but very common. Another place you’ll find MPEG-2 compression is when you’re watching these HD over-the-air channels. It’s all MPEG-2 compression. Interesting to know, right?
Since the compression algorithm using MPEG-2 is significantly inferior to H.264, its advantage is that encoding is much faster. However, this never worked for streaming on the internet, because at a lower bitrate, the quality dropped quickly and you would end up with pixelated video. That’s why they came up with MPEG-4 Part 2.
MPEG-4 Part 2 – You probably remember the days when everyone talked about DivX and Xvid, right? These were encoders for the MPEG-4 Part 2 format, also known as H.263. Many movies you downloaded before were compressed using this codec because it gave you a good file size and maintained acceptable quality. However, the only major issue is that HD content still suffers in terms of image quality, and this is where H.264, which I mentioned above, took over.
Windows Media Video is essentially Microsoft’s version of the MPEG-4 codecs. WMV 7 was introduced in 1999 and was a copy of MPEG-4 Part 2. Later came WMV 8 and 9 and then VC-1, a codec that basically copies MPEG-4 Part 10 and is currently used in Blu-ray. disks too. The only other places you see WMV and VC-1 are mostly Microsoft related products like Windows Movie Maker, Silverlight, HD DVD, Microsoft Expression Encoder, etc.
These are just popular video codecs, you also have your own audio codecs that come into play when we talk about containers below. Popular audio codecs include FLAC, AC3, Dolby Digital Plus, DTS-HD, ALAC, etc. As with video, audio codecs have their own container formats like AIFF, WAV, etc.
These are not all codecs, this is just a list of some of the most popular ones. Now let’s talk about container formats.
Container formats
When you play a file in Windows Media Player, VLC, Quicktime, or another media player of your choice, you usually open the container format. A container format or wrapper is basically a package of one or more codecs, video or audio, or both. The container is used to add audio along with video and to ensure perfect synchronization of audio and video. The container will also contain other information needed by the streaming server or media player. The video and audio bitstreams are simply enclosed in another bitstream.
In container formats, you can see common file extensions that we all use too, like MP4, MOV, WMV, AVI, etc. Let’s take a look at some of the more common containers:
MP4. You probably downloaded the song with the .MP4 extension, which is a wrapper for many video and audio codecs. It is most commonly used to wrap H.264 video and AAC audio. It also supports MPEG-4 Part 2 and MPEG-2 video codecs. In addition, audio can be encoded using codecs other than AAC.
AVI has been a Microsoft container format since 1992. It was very popular in my day and is still used quite often. If you are doing any kind of encoding, you should never use the AVI container format again. First, it doesn’t support newer codecs like H.264. It also has several other major problems, so it is no longer used.
ASF – Microsoft’s Extended System Format usually does not use the .ASF file extension. Instead, you will see that most ASF containers use .WMA or .WMV. You will see these files if you are using all Microsoft products. After leaving the world of Microsoft, you will run into problems playing files, especially if you are using the H.264 codec.
AVCHD – AVCHD is the most common container format for HD camcorders. The video will usually be H.264 with AC3 (Dolby Digital) or Linear PCM audio.
MKV – Download a movie recently? It is likely in MKV container format that stores H.264 video files. Many tools support MKV like Boxee, PS3 Media Server, XMBC, VLC, etc., but so far it is not as widely supported as other container formats.
FLV is Adobe Flash that supports many different codecs, the most common of which are H.264 and AAC. Flash video is one of the most popular ways to stream video over the Internet. It is losing ground due to HTML 5 and the fact that Apple does not allow flash to run on any of its iDevice, but this is still very common.
There are other container formats like QuickTime File Format, OGG, WebM, etc., but now you kind of get it.
The blade
The last thing to understand about all of this is that you may have to convert that AVCHD video that you downloaded from your camcorder to another format, which you can then import into iTunes and play on your iPhone. Since there are so many codecs and container formats, and each container format can have a different combination of video and audio codecs, you will need a transcoder to get the file type you want for your specific device.
There are many transcoders known as video converters: HandBrake, FFmpeg, SUPER, VirtualDub, etc. Some are paid and some are free open source tools. Some tools, such as HandBrake, provide you with presets, so you can simply select the source file, select the output format, such as iPod or iPhone, and hit Start. It will choose all settings, container, codec, etc. However, I hope after reading this post, you now understand a little more and can move on to converting videos between formats and understand the basic process a little better. Enjoy!
–