There are plenty of video editors out there who have a mastery over the art form, but when faced with an export screen of codecs, containers, bit rates, and more, their eyes glaze over and they begin to question their career choices. In a perfect universe, we want our videos to be small, work on every device, and look pixel perfect compared to the originals, but sadly, that trifecta simply doesn’t exist. Let’s breakdown the most essential components that make up a video file and see which options are best suited for the most common exporting scenarios.
A Couple Definitions
Before we get too deep, let’s make sure we review a couple key terms so that the next time someone asks you what codec you’re using, you don’t respond with “Quicktime” (sorry, not a codec, folks). All video files are made up of two primary components: a codec and a container. Let’s start there.
This is the language your video file speaks. Just like we have a bajillion (or so) languages on planet Earth, so too it seems we have a bajillion video codecs. Different codecs have different pros and cons from one another. Some codecs are “lossless,” which is exactly what it sounds like: visually identical to the original source material, but produce, relatively speaking, enormous files. Other codecs are file size efficient but trade off quality, sometimes a little and sometimes a lot. Examples of common codecs, which often have funky-sound names: H.264, HEVC (aka H.265), ProRes, DNxHR, Cineform, Animation, AV1, VP9.
Sometimes called the “wrapper,” the container is the digital box that the codec lives in. It’s the wrapping paper around the present. Some codecs only live in one type of container and others can live in a variety of containers. Containers are usually identified easily by their file extension. Examples: Quicktime (.mov), MPEG-4 (.mp4), MXF (.mxf), and many more. If you see .avi or .wmv files in 2019, run in the other direction, they’re old. It is through this combination of codec and container that has a large influence on the file’s quality and compatibility (and metadata capabilities, but let’s not get too far ahead of ourselves here).
This one is a bit frustrating. The term “format” is used amorphously depending on who or what is using it. Sometimes it’s used erroneously to describe a codec. Sometimes it’s used to describe a container. More accurately, it can be used to describe popular/common combinations of codecs and containers. For example, AS-11 is a format used in broadcast that usually uses an MXF container to house an AVC-Intra codec video inside. If that last sentence read like a foreign language, don’t worry about it just yet.
This is usually the file you deliver to the everyday end client or to the world at large. It will usually use a compressed codec to make sure it is small and easy to share. Common codecs used for this sort of a file are H.264 and HEVC (aka H.265).
This is usually the file you either keep backed up on a super safe drive/LTO option or share with other production professionals who might re-incorporate the video elsewhere. In most cases, DO NOT give a non-production professional a copy of the master file. Why? Because they’ll call you up and say something along the lines of “Why is this file so big?” or “Why can’t I play it on my Android?” Or “It won’t stream to my AppleTV.” Master files often are huge and aren’t very compatible on consumer hardware and software. Common codecs used for this sort of a file, also sometimes called mezzanine or intermediate codecs, are ProRes, DNxHR, and Cineform, although plenty more exist.
This is how many bits (not bytes) of information are thrown into every second of video. Usually measured as kilobits per second or megabits per second. This is one of the most important factors that determines the ultimate quality and file size of your video. More on this below!
The Long-Running Delivery King: H.264
Originally released to the public in 2003, H.264 is the Tony Bennett of video codecs - it’s had a hugely long career, getting up there in age, but despite that still sounds and looks great, and is still loved by both young and old. H.264 as a codec produces pretty small files, works on almost anything in 2019, and can look very, very good (but not perfect). This is because it is a lossy, compressed codec, but if you know what you’re doing, that “loss” can be very minimal.
Today, if you want the best “play it safe” combo of codec and container that will most likely look good and work on most devices, selecting H.264 as the codec and .mp4 as the container will likely get you there. But there is a little bit more to it than that, so keep reading!
Boo, Math! (But Also, Math is Important)
One of the most important (but far from the only) factors that influence a file’s quality is bit rate (definition above). Generally speaking, the higher the bit rate, the higher the quality and file size. Some codecs, usually the higher end ones, have a firmly set bit rate that you can’t adjust. H.264, however, is a scalable codec, meaning users usually have some controls over the bit rate, depending on the software you’re using.
The first thing to understand is that we are talking bits here, not bytes, which most users are more familiar with. First off, the shorthand is different. “MB” is short for megabyte while “Mb” is short for megabit (an easy detail to overlook). Luckily, the conversion between the two is super easy.
1 megabyte = 8 megabits
1 megabit = .125 megabytes
Also 1 megabit = 1,000 kilobits (once in a while you see data measured this way)
Well that’s fine and dandy, but what is a good or high bit rate? Well, as with all things, it depends. If we’re talking about HD (1920x1080) video for a moment, a generally accepted “high” bitrate might be around 20 Mbps (megabits per second). A lower end bitrate would probably be between 3-5 Mbps. For perspective, Blu-Ray uses a large 30-40 Mbps. YouTube uses about 16 Mbps, and Netflix uses around 5 Mbps. Of course, your personal mileage may vary for your own videos’ needs.
So can we guess a sequence’s ultimate size before we export? We can get close. Let’s say you’ve got an HD (1920x1080) video that is 2 minutes and 43 seconds in length with a bit rate setting of 15 Mbps.
2:43 = 163 seconds
163 seconds (length) x 15 Mbps (bitrate) = 2,245 megabits
2,245 megabits/8 = 306 MBs (megabytes)
This doesn’t usually account for audio, which adds a bit more data, but overall, easy peasy, right? Who doesn’t love math? Put your hands down. Luckily, many users rarely need to get this deep in the weeds as most programs contain a variety of presets that simplify this, sometimes never showing you these numbers at all, or at least hiding them under advanced settings.
An important note pertaining to 4K. 4K is roughly four times the number of pixels as HD video, which in turn means that 4K video needs four times the bit rate as HD video to maintain a comparable quality. So all that math we did above? Quadruple the bit rate and eventual file size!
But What About HEVC/H.265?
Codecs come and go over time and H.264, while dominant, won’t be king of the hill forever. H.265, also known as HEVC, is the successor to H.264, but comes with some pros and cons at the moment. One major pro is that HEVC is able to compress an image at around half the bit rate as H.264 with no discernible quality difference. In addition, it also supports more intelligent compression techniques allowing for better quality in some cases than H.264 (but that is a technical rabbit hole we won’t fall down today). So why the heck aren’t we telling you to make an H.265 file right this very second? Well, we’re not not telling you to. But keep in mind that HEVC is relatively new to the digital playground and hasn’t quite reached mainstream adoption. It’s close, but not quite there yet. Not every browser, OS, smartphone, NLE, etc. supports it just yet (but that number is growing all the time), so you might be hurting your chances of compatibility. But this is just a time thing, and most likely H.265 will reach a similar level of ubiquity that H.264 has in the near future.
On a more technical level, another drawback to HEVC is processing needs. It takes a lot more processing power to decode and encode HEVC. If a device uses purely software, playing HEVC files can be a battery killer and encoding them can be slow. Until hardware decode/encode support and acceleration is widespread (you’ll want at least a Kaby Lake Intel processor FYI and software supporting GPU acceleration), HEVC will suffer from these limits for some users.
An Important Note on Highly Compressed Files
There’s one other subtler drawback to compressed codecs like H.264 and HEVC. While they might look great at a high enough bit rate, and you think that’s all you need, heavily compressed video codecs suffer from one fatal flaw - recompression fatigue. Remember the old days of hooking up one VCR to another to copy a VHS tape (or am I old)? The quality degraded severely in that scenario, which we usually call a generation loss. Taking a compressed file and incorporating it into another video or re-compressing it can noticeably lessen the newly created file’s quality. So what is one to do? Enter: master codecs.
ProRes vs DNxHR vs Cineform (i.e. Coke vs Pepsi vs Dr. Pepper)
When it comes to creating archival/master files, there are a few competing codecs to consider, the most popular of which are ProRes, DNxHR, and Cineform. Whereas the bit rates for compressed codecs are usually in the double digits, these higher end codecs’ bit rates are often hundreds and sometimes even thousands of megabits per second, producing enormous sizes, but near perfect quality.
But which one should you use? This is what I like to call Coke, Pepsi, and Dr. Pepper metaphor. Some people like Coke best, some prefer Pepsi, and some Dr. Pepper. But at the end of the day, they’re all brown sugar water and taste pretty similar to one another. Think of these codecs like that. All three can produce visually lossless, beautiful images. Yes, if we got nitpicky, there are some subtle differences between them, but for most newer users, it’s a bit of a matter of preference if you haven’t been told directly by someone which to pick. Some hardcore production nerds will take issue with that simplification, but it’s true… to a degree. Production houses and professionals will have a preference they stick to for the sake of synergy and streamlining workflows and there’s nothing wrong with that.
Remember, these codecs don’t usually play nice with consumer software and devices. That’s what H.264 and HEVC are for. But one other major perk to these formats is they survive generation losses much better than compressed codecs, allowing you to re-encode a file multiple times with (usually) no discernible lost in quality, making it great for archiving purposes.
A New Challenger Approaching: AV1
H.265 is not going unchallenged in the never-ending format war. Many large tech companies are unhappy with the associated licensing fee that comes with incorporating HEVC into their products. To combat this, many of these companies, including Apple, Microsoft, Amazon, Google, Intel, and Netflix (to name a few) have come together to form the Alliance for Open Media. It’s been a slow moving process, but the consortium released the first version of their AV1 codec (not to be confused with the similar-looking-in-print container AVI) in late 2018 as a direct competitor to HEVC. Adoption is nascent at this point in time and no major NLE natively supports it (yet), but it’s one to keep an eye on over the next couple years with so many large backers.
The Long and Winding Code(c)
The truth is, video compression is… messy. There are a lot of formats out there, each with their own pros and cons and each with lots of deep-cut settings we didn’t even get to touch upon in this primer (bit depth, one vs two pass encoding, other niche formats, and more), but watch this space and check back!. And for every “fact” in this article, there are always little obscure exceptions that further muddy the waters. The next time you’re faced with a screenful of codec options, ask yourself, “Where am I going?” to help make the decision, and hopefully you won’t break out into an existential crisis.
So what is your goto codec? Are you using HEVC regularly yet? Do you prefer Coke, Pepsi, or Dr. Pepper? Tell us in the comments below!