Technology Explained

All You Need to Know about Video Codecs, Containers, and Compression

Bryan Clark 13-03-2015

Explaining the difference between codecs and containers is relatively simple, but hard part is attempting to understand each format. The lines start to get blurred when you realize that most common codecs aren’t exclusive, and can make use of multiple compression technologies in order to get the job done. The blurred line becomes nearly invisible when you start to talk about formats like MPEG-4 which could be classified as a bit of a container and a bit of a codec, but that’s a rather complicated classification that’s best left for another time.


So, how do you teach yourself the difference between dozens of codec and container options? Don’t. There is only a handful of technologies that are used for online video, and the bulk of your effort will be spent understanding how these work, as well as understanding the trade-offs you’re faced with when deciding on what to use.

You could spend weeks studying technologies that are only used for a relatively small number of applications, so instead we’re going to focus our attention on what technologies you’ll use for most of your video encoding and playback needs.


What Is a Codec?

A codec – or coder/decoder – is an encoding tool that processes video and stores it in a stream of bytes. Codecs use algorithms to effectively shrink the size of the audio or video file, and then decompress it when needed. There are dozens of different types of codecs, and each uses a different technology in order to encode and shrink your video file for the intended application.

Depending on the codec, this encoding occurs in one of two ways: lossy or a lossless compression How Does File Compression Work? How does file compression work? Learn the basics of file compression and the difference between lossy versus lossless compression. Read More .


Lossy Compression

When looking for manageable file sizes, lossy compression is the most viable method available. While you certainly lose quality in audio, video, or both, the compression is a necessary evil (currently) in a world dominated by the need to share and store what would otherwise amount to impractical file sizes. Your average Blu-ray, for example, can exceed 40 gigabytes, and that sort of storage space would not only be expensive, but it’d make digital downloads and purchases inconvenient, if not an outright waste of time. The key when using lossy compression is to settle on the highest quality compression format for your intended use, so that you walk the fine line between loss of quality, and file size.


Lossless Compression

Lossless compression works much like a ZIP or RAR file in that after compressing and decompressing, the file is essentially the same. Through use of smart algorithms, the file doesn’t lose much quality, but it’s not an efficient way to store large files because there isn’t much compression that actually takes place. In addition, online transmission of large video files uses far too much bandwidth (although H.265 encoding may change that) to make it a viable compression option.

Unless you work in the film industry, or in video editing, it’s unlikely you’ll ever share video files in a lossless format (if even then). To put it into perspective, even a 4k television doesn’t contain the resolution needed to display a film shot on a modern camera and delivered without some sort of compression. In fact, it’s not even close (yet). While 4k video is beautiful The Best 4K YouTube Videos to Watch on Your New TV or Monitor Here are the best 4K videos on YouTube you can watch on your new ultra high-definition television or monitor. Read More , it’s not even close to the size of an uncompressed video format.


While a Blu-ray film is less than 50 gigabytes (if it has to fit on one disc), the first downloadable 4k movie (available to consumers – trailer below) is a whopping 160 gigabytes! Completely uncompressed 1080p video is a mind-boggling 410 gigabytes per hour, and that doesn’t include the audio file, which could add an additional 7 gigabytes per hour depending on how it was recorded. All-in-all, these files are all but useless for a consumer market with current technology.

It’s also important to note that codecs aren’t just for compression of audio The 10 Most Common Audio Formats: Which One Should You Use? You know about MP3, but what about AAC, FLAC, OGG, or WMA? Why do so many audio file formats exist and is there a best audio format? Read More and video files. Once a file has been encoded using a specific codec, that same codec must be used to decode the file in order for it to play on your device. Not using the correct codec is what leads to the majority of device compatibility or playback issues. This issue is becoming less common as modern containers often include the required audio and video codecs needed to play the file.

Popular Codecs


DivX is a commercially sold codec, while XviD is an open source utility meant to function as an alternative to its commercial cousin. Both codecs can decode the output of the other, as they are both built on the implementation of MPEG-4. While still widely used, its often strictly for video encoding and in conjunction with one of the more popular packs mentioned below.


MPEG-4 is the most common streaming format and it consists of many parts, of which only MPEG-4 Part II is used for video coding. MPEG-4 Part II calls on video encoders such as DivX or XviD in order to encode the video, while audio is typically carried in MP3 format. Modern updates to MPEG-4 are now using H.264 as well.



This is the most popular choice for high definition material. H.264 is also a relative Swiss Army knife of the codec world as it can utilize both lossy and lossless compression depending on the settings you choose when encoding, such as frame rate, quality, and target file size. H.264 relies on x264 for encoded video (as well as others, such as DivX or XviD), and audio is often encoded using AAC or MP3 audio codecs depending on the size and quality you’re targeting.

H.264 is touted as 1.5 to 2 times as efficient as basic MPEG-4 compression, which leads to smaller file sizes and seamless playback on more devices. That said, H.264 is now included in the MPEG-4 codec (part 10, known as AVC), so it could become a moot point in the near future as the codecs become less reliant on a single encoding technology, and instead take on the role of a codec pack which includes multiple encoding methods in a single package.


What is a Container?

A container exists solely for the purpose of bundling all of the audio, video, and codec files into one organized package. In addition, the container often contains chapter information for DVD or Blu-ray movies, metadata, subtitles, and/or additional audio files such as different spoken languages. The typical container runs like an executable (.exe) file on Windows. It uses a .bat file to tell the operating system that there are executable commands that need to be run together in order to achieve the intended result.


Popular Containers

Flash Video (.flv, .swf)

Macromedia originally created Flash before they were ultimately acquired by Adobe in 2005. Flash is an aging container that is being phased out due to limitations in the technology, creating what Steve Jobs used to refer to as “buggy” file handling. This led to a very public omission from iOS devices for Adobe and it appears that this was the beginning of the end for the format. As HTML5 standardization takes hold Get Started With HTML5 You’ve heard of HTML5. Everybody is using it. It's being heralded as the savior of the Internet, allowing people to create rich, engaging web pages without resorting to using Flash and Shockwave. Read More , we should see less Flash videos online, and the container is most likely going to disappear with it.



MKV is a rapidly growing format that was designed to be future-proof. The container itself supports almost any audio or video format which makes it adaptable, efficient, and highly regarded as one of the best – if not the best – ways to store audio and video files. In addition, it even supports multiple audio, video and subtitle files even if they are encoded in different formats. Due to the options the container offers, as well as its handling of error recovery (which allows you to play back corrupted files), it has quickly become one of the best containers currently available.


MP4 is the recommended format for uploading video to the web Everything You Need To Know About Uploading Videos To YouTube Currently, there are three ways to upload videos to YouTube. Here's an in-depth look at how to use your computer, phone, or games console. Read More , and services such as Vimeo and YouTube have it listed as their preferred format. The MP4 container utilizes MPEG-4 encoding, or H.264, as well as AAC or AC3 for audio. It’s widely supported on most consumer devices, and the most common container used for online video. You really can’t go wrong with MP4.

The bottom line is, a container is a (mostly) useless bit of information when referring to video. Telling someone to send you an MP4 file doesn’t give away any useful bits of information without understanding how the video and audio itself were encoded. The container is just that, a place to store the audio, video and the codecs needed to decode them for playback.

So, ultimately if you’re looking for advice on what to use, H.264 is quickly becoming the standard codec, while either mp4 or MKV are worthy containers. MP4 might get the edge here because it is better supported in consumer devices, and is the standard for most large streaming video sites. Ultimately, the choice is yours, and as long as the video can be decoded and played on the other end, there really aren’t a lot of bad choices you can make in terms of what to use.

I’d love to hear what you use and for which application you’re using it for. What are your go-to video compression codecs, settings, and containers The Best Settings & Formats for Capturing Videos for YouTube Read More ? Let us know in the comments below.

Photo credit: compression tool Via Shutterstock, Tunnel of Images, Media, Photographs via ShutterstockAmazing Nature by Dr. Wendy Longo (modified), Adobe Media Encoder CS4 by Kebman, Youtube by Esther Vargas all via Flickr

Related topics: Adobe Flash, Online Video, Video.

Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.

Whatsapp Pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Yaroslav
    November 3, 2017 at 9:06 am

    I have the Debian Linux operating system installed and a popular tool for video editing on such a system is Kdenlive, another alternative is Blender in the video-editing mode. I prefer the former one in the terms of usability but the second one seems to be more stable.
    Kdenlive can render its project into an images sequence, audio only, lossless video, 4K video, DVD standard video, Flash and generic videos in WebM, MP4 and MPEG-2 formats.
    Blender may be a more powerful solution, as it can execute Python scripts but I'm not proficient with the software at all, so I cannot tell.
    The two technologies that I have worked with are the MKV container and the FFmpeg program. I used the MKVtoolnix software to join several files of the MTS format into a single file of the MKV format and the software have accomplished the task without decompressing and rendering the videos. Then, I used the FFmpeg command to cut a part out of this file, again without decompressing and rendering.
    This tutorial is handy, especially if you have no experience like I do. Thank you, the authors of the article, for creating this content, I wish you good luck!

  2. gshunt
    October 30, 2017 at 1:14 am

    Lossless Compression
    "Through use of smart algorithms, the file doesn’t lose much quality"


    Last time I checked there was NO quality lost, a 1 to 1 clone (after decompression).

  3. Dr B
    February 6, 2016 at 9:01 pm

    Where does DNxHD fit in this discussion. It is the preferred codec for editing in ProTools. ProTools states that the .h264 is okay but results in variable performance.

  4. Not A Yes Man
    January 31, 2016 at 1:39 pm

    It would be helpful to everyone if you made it clear that MKV is the winner for containers. As it does everything the others can do, plus more... And its growing in popularity across the board... etc etc.

  5. AXP
    April 1, 2015 at 4:24 am

    1080i and 1080p HDTV uncompressed

    8 bit @ 1920 x 1080 @ 24fps = 95 MB/s, or 334 GB/hr.
    10 bit @ 1920 x 1080 @ 24fps = 127 MB/s, or 445 GB/hr.
    8 bit @ 1920 x 1080 @ 25fps = 99 MB/s, or 348 GB/hr.
    10 bit @ 1920 x 1080 @ 25fps = 132 MB/s, or 463 GB/hr.
    8 bit @ 1920 x 1080 @ 29.97fps = 119 MB/s, or 417 GB/hr.
    10 bit @ 1920 x 1080 @ 29.97fps = 158 MB/s, or 556 GB/hr.

    1080i and 1080p HDTV RGB (4:4:4) uncompressed
    10 bit @ 1280 x 720p @ 60fps = 211 MB/s, or 742 GB/hr.
    10 bit @ 1920 x 1080 @ 24fps = 190 MB/s, or 667 GB/hr.
    10 bit @ 1920 x 1080 @ 50i = 198 MB/s, or 695 GB/hr.
    10 bit @ 1920 x 1080 @ 60i = 237 MB/s, or 834 GB/hr.

  6. Bryan Clark
    March 23, 2015 at 1:36 am

    @Mike: Hard to say for sure, as AVI and MOV are containers so it's more relevant to discuss what's inside them. That said, there is a serious drop in the number of devices that output in MOV and AVI by default, and there's good reason for that.

  7. Mike
    March 23, 2015 at 12:31 am

    Bryan, many digital cameras produce AVI and MOV files, how do they fit into this taxonomy?

  8. Bryan Clark
    March 19, 2015 at 8:16 pm

    @Mike: AVI is all but dead, but for some reason, people (and manufacturers) keep using it. MOV is also nearing the end of its life. In fact, when OS X made the Mavericks update, Quicktime - MOVs biggest proponent - started converting anything in a MOV container to .h264 during playback.

    I didn't want to spend much (or any) time on them, because in a couple years, neither will exist. However, I could eat my words if some game-changing update happens to either of them, but as of right now, they're basically dead.

    • Andrea
      March 20, 2015 at 9:40 am

      Another great tip - thanks good to know:)

  9. Mike
    March 19, 2015 at 8:01 pm

    Bryan, many digital cameras produce AVI and MOV files, how do they fit into this taxonomy?

  10. Bryan Clark
    March 19, 2015 at 12:40 pm

    @Andrea: Looking at that comment again, I'm not sure why I thought you were a Mac user. Probably because I'm a Mac user, and by default I assume everyone else is as well. :P

    Anyway, Handbrake works for Windows as well (which is something I didn't know until just now)...

  11. Bryan Clark
    March 19, 2015 at 12:38 pm

    @Andrea: Sounds like you're a Mac user, so I hope you have Handbrake ( From there, I would encode in .h264 and then use the MKV container. You can tweak the sound and video settings from inside here until you get a file size/quality you can live with. These will play on a PC as well, but you're probably better off using VLC for the MKV file as most Windows programs struggle with it.

    One more thing. There's no need to break these into chunks. As long as you're using a program that handles MKV (like the open source VLC), playback will be seamless.

    • Andrea
      March 20, 2015 at 9:39 am

      Hi Bryan

      Thanks for the feedback and tips - and yes I am an out and proud PC user!

      I've not come across handbrake before so shall have a play around with this. I have Media Encoder already so shall also see how this measures up.

      Also, re the issue of breaking into chunks, it is good to know that the larger files can be handled by the VLCs of the world. However, another reason I have for segmenting files was that I could then name these logically and thus be able to navigate to specific scenes if desired. I guess I am coming at this from the old chapter marker mindset for DVDs. Is there anyway to place markers in .h264 files? I am guessing not as it seems to be a bit of an outdated function from my limited research.

      Thanks again,

    • Bryan Clark
      March 20, 2015 at 4:57 pm

      @Andrea: I had to look this up (I've never added chapters using .h264 that didn't already exist), but it appears that you can. Give this a look and see if it works for you - -

    • Andrea
      March 21, 2015 at 2:46 am

      Fantastic - thanks again Bryan.

  12. Andrea
    March 19, 2015 at 11:00 am

    Hi Bryan

    Thanks for a really helpful, practical article.

    I had been scouring the internet to find what is the best way of editing and archiving home movies now that DVDs are on the way out.

    To date, I always edited home movies in Premiere and authored to DVD in Encore, but am looking to change for two reasons: Firstly, Adobe did away with Encore and DVD authoring in its most recent iteration; and secondly, my video is shot in HD therefore converting to DVD was losing quality.

    It would appear from what you've written that either MKV or MP4 should replace the DVD container and that I should use H264 as the codec in either or these. I can then play these from file on my PC (I don't intend to upload). Presumably I would need to break these up into chunks of an appropriate size (assuming multiple small files play better than one large file). Does this sound sensible to you? Do you have any feedback on my proposed method?

    Thanks in advance,

  13. Bryan Clark
    March 17, 2015 at 4:00 pm

    I haven't seen the BBC program, but I'm definitely going to have to watch it.

    As an Apple user myself, the problems you mentioned about proprietary codecs and containers is rather frustrating. The MOV file is rather useless anymore, but Apple seems rather stuck on forcing us to use it unless we're uploading directly to YouTube.

  14. John Williams
    March 17, 2015 at 3:56 pm

    Interesting to see that BBC "Click" just made a whole program from Barcelona using just mobile devices. Apparently it was a nightmare - not so much the filming, but the editing. Predictably, the Windows system beat its way through all the codecs and containers the different manufacturers' phones generated, Whereas the iPad just refused point blank to work with any file not made with an iPhone.

    Sadly, this stunt was done in response to Apple making a complete film using just iPhone, iPad and Macbook products as the only devices they make. There is no need for the likes of Panasonic, Sony or Samsung to use consumer phone devices to make a film. They all have huge real camera divisions. Also the range of video edit software available for Windows and Linux is immense.

    It always strikes me as odd that Apple is touted as the "creative" users' choice when in fact it is completely hamstrung. Apple gets round the huge problems of codec types by locking down to one that "just works".

  15. Bryan Clark
    March 17, 2015 at 2:57 pm

    @Kevin: You're absolutely correct, there is a difference between decimation/downsampling and compression, but in this case, we're talking about raw video that is compressed and shrunk down into smaller sizes post-prodution, and not while filming under a reduced quality (downsampled) for the sake of smaller file sizes. I realize both occur, but for the sake of brevity and general understanding, it's important not to get into all of them when it wasn't necessary for the sake of the piece. he point was that modern cameras are able to shoot in much higher resolution than the current television technology can display. It has actually been like this for years. For example, re-releasing old movies in HD didn't require anything other than transferring the movie from 35mm (there are no megapixels in film, but it would be the approximate equivalent of 20 megapixels if there were) film into Blu-ray format. Of course, that's an EXTREME oversimplification, but you get the idea. Cameras are typically much better at any given time than the devices needed to display what they shoot.

    As far as the numbers, I'm not sure what you're getting at. They don't seem to make sense because you listed them without any context. For example, the 1080p number is probably causing a lot of the confusion, as I said that it can be up to 410 gigabytes per hour (uncompressed). Blu-ray, also in 1080p, utilizes compression to shrink the film down to under 50 gigabytes (or more depending on if newer triple or quadruple layer formats ever become popular). The confusion stems from a lack of context; if I'm understanding you correctly.

    Additionally, to address the last part, 4k movies - such as the one mentioned - still rely on compression (meaning - the video isn't "full" size/resolution). That said, the file size of the video mentioned is irrelevant, because it's compressed. In other words, it's like saying that it can't be a Blu-ray unless it's shorter (run time) than normal, because it's not 50GB, the max size of a double layer Blu-ray disc.

  16. Kevin Buchs
    March 17, 2015 at 2:18 pm

    You wrote: "To put it into perspective, even a 4k television doesn’t contain the resolution needed to display a film shot on a modern camera and delivered without some sort of compression." I think you are confusing file compression with downsampling to reduce the resolution. When you compress a video using one of the codecs here mentioned, you are not reducing the resolution, just the file size.

    These figured don't make sense:
    Blu-ray < 50 gigabytes
    4k = 160 gigabytes
    1080p 410 gigabytes per hour

    4k is 4000p, so given that resolution and that the video file size goes by the square of the resolution, the largest uncompressed size should be 4k, then Blu-ray, then 1080p. Now maybe that 4k movie was really short duration (but then you should have mentioned that). Anyway, given the 4k is about 4 times the resolution of 1080p and file size goes by the square of the resolution, you would expect the 4k to be 16 times the size of 1080p.

  17. Bryan Clark
    March 17, 2015 at 1:56 pm

    mtjoseph: Great question! Both are definitely "next" in terms of what's to come, but neither have a whole lot of support at the moment. While we'll definitely see more of them, I wanted to focus on formats that are currently popular and widely used.

  18. mtjoseph
    March 17, 2015 at 1:54 pm

    Good introductory article. Why no discussion of H.265 and VP9 codecs as these are considered next gen replacements?

  19. Bryan Clark
    March 17, 2015 at 11:35 am

    @astral_cyborg: Thanks! I'm glad you enjoyed it.

  20. Bryan Clark
    March 17, 2015 at 11:35 am

    @7Gs : WMV is a proprietary Windows format, and I didn't included it because it can't play natively on anything but a Windows computer. It's possible to play them with Mac and Linux machines, but both require additional steps or software programs.

    Honestly, most believe that it's nearing the end of its usable life as better container formats come out that are both multi-device compatible, and highly customizable (a major gripe against WMV/ASF).

  21. Bryan Clark
    March 17, 2015 at 11:31 am

    @jimvandamme: What software do you use to burn the disks? Maybe I can help you further by offering up some suggested settings.

  22. astral_cyborg
    March 17, 2015 at 10:27 am

    Very nice article and easily understandable. Thanks for the information

  23. 7Gs
    March 17, 2015 at 7:56 am

    What about WMV? On many video sites I know, there are more wmv files than mp4 files.

  24. jimvandamme
    March 16, 2015 at 10:58 pm

    I've been cutting a lot of home movies, from 8 & 16 mm film, VHS video, up to 720P video. I use OpenShot, KDenLive or Avidemux (on Linux) and upload to YouTube, Vimeo, or Google Picasa/Photos; and burn to DVD and send to relatives and friends in England and mainland Europe. Needless to say, I'm always confused on what format to use so everyone can watch them with acceptable quality and decent file size. You haven't answered all my questions...but it's a start.

  25. Bryan Clark
    March 14, 2015 at 10:42 am

    Do you mean playback, or creating them? For playback, VLC is easily the best option for playback due to the amount of formats it can handle.

  26. Ariel
    March 13, 2015 at 2:18 pm

    Great info: BTW: Which is the best all in one tool to deal with all this business of codecs and containers ?