Codec vs. Container: Encoder Settings for Live Streaming
Live streaming video content is becoming more prominent in the professional world. Businesses are incorporating videos for sales, marketing, training, and more.
People with little to no broadcasting experience are diving headfirst into the world of online video, not realizing how technologically complex this topic is. That’s why we’ve made it our mission to break down the more technical aspects of video broadcasting.
One thing that confuses new broadcasters off is encoding. This is an essential process for professional broadcasting, so it’s important to understand it from the get-go.
In this post, we’re going to cover what video encoding is before we dive into two key components: codecs and containers. We will break down examples of each and compare these two encoding aspects.
To wrap things up, we will lay out some other encoder settings that professional broadcasters should pay attention to.
Without further ado, let’s talk about all things encoding, codecs, and containers.
Table of Contents
- What is an Encoder?
- What is a Video Codec?
- Lossless vs. Lossy Codecs
- Different Video Codecs
- Best Video Codec for Live Streaming
- What is a Container?
- Different Video Containers
- Best Container for Live Streaming
- Video Codecs vs. Containers
- Other Encoder Settings
- Conclusion
What is an Encoder?
In order to understand the ins and outs of video codecs, containers, and how the two relate, you need to know what an encoder is and why it’s so important for live streaming.
An encoder is a device that takes the RAW video files from the camera and converts them to digital files that are suitable for streaming. This process is made possible by the use of codecs, which we will explore shortly.
There are both hardware and software encoders. Neither is inherently better or worse, so you should choose which direction to go based on your needs and your budget.
Hardware encoders are dedicated encoding devices that are considered more powerful than the software alternatives, but these come with a hefty price tag.
Software encoders, on the other hand, run right on your computer and these are typically much more affordable. Some are even free.
If you’re new to broadcasting, we recommend checking out OBS Studio for Dacast. It is a free, open-source software encoder that is super easy to use.
Please note that encoding should not be confused with transcoding, which resizes video files into multiple renditions for multi-bitrate or adaptive bitrate streaming.
What is a Video Codec?
As we mentioned, a video codec is a technology that makes encoding possible. Codec is short for “coder-decoder.” This technology is responsible for both encoding and decoding video files.
Codecs are not unique to video files. There are different codecs for photos, files, audio, and more. For this post, we’re focusing specifically on video codecs.
To understand the purpose of codecs and how they work, you must understand the difference between RAW and digital video files.
A RAW file works the same way that a motion picture would work. It is a collection of thousands of still frames that flow in a lifelike motion when put together and sped up. Since it contains so many individual frames, these files become bulk and impossible to stream over the internet.
That’s where the codec comes into play. The codec compresses and decodes these files to create digital files. These files are much smaller in size, which enables them to be streamed to viewers over the internet.
Lossless vs. Lossy Codecs
There are two main types of video codecs: lossy and lossless.
With lossy codecs, the encoder removes frames that are nearly identical or less important in order to trim down the file. This is typically the type of codec that is used for online streaming.
Lossless codecs, on the other hand, compress the files and retain all of the information. This makes them smaller but not as small as files encoded with a lossy codec.
While lossless codecs help maintain the quality of a video, it isn’t necessarily better than lossy. Which you should use depends on what you’re doing with the video.
If you need to send or broadcast the video quickly, lossy codecs are the way to go since they make the video files small enough to be sent over the internet. If the quality of the video is more important and you can send it another way, lossless may be a better option.
Different Video Codecs
Some examples of video codecs include:
- H.264 is the most universal codec used today. Currently, H.264 is considered the best video codec for live streaming, and AAC is the best audio codec for live streaming.
- VP9 is a video codec that’s developed by Google. It’s free and open-source, but it’s not widely supported yet. Many consider this code of the future
- MPEG-4 is an older video codec that used to be very common. It is still pretty universal, but it’s not the first choice for most broadcasters since the technology isn’t cutting edge.
- DivX is an older video codec that is known for maintaining video quality. It isn’t popular in OTT broadcasting since it doesn’t reduce file sizes.
Best Video Codec for Live Streaming
Currently, the H.264 AVC, or advanced video coding, is considered the best video codec. It has gone through a number of iterations and updates. It’s not a monolithic standard. In fact, H.264 could best be understood as a “family” of related standards. These are captured in the H.264 “profiles” that are available in any encoder.
There are at least 20 profiles available for H.264. However, most of those are very specialized. Most encoding software only uses a small number of these profiles. These more commonly-used profiles are:
1. Baseline Encoder Profile:
The baseline profile uses only the older, most widely-supported compression features of H.264. This means that video compressed using the H.264 codec, the baseline profile will be compatible with almost all devices. This includes older and low-power devices. However, the tradeoff is that file sizes will be larger. Please also note, that the baseline profile is not a supported setting for the Dacast OVP and will break your stream.
2. Main Encoder Profile:
The main profile applies some additional encoding features of the H.264 family. This requires more processing power and memory on the decoding side. Old or low-powered devices (such as tablets or smartphones made more than 5-8 years ago) may not be able to decode this video. However, file sizes are smaller.
3. High Encoder Profile:
The high profile is the most modern implementation of H.264. It includes more encoding features that enable smaller file sizes. However, this requires more processing power and memory from the viewer’s devices. Today, device power has become less of an issue. The high profile is supported on all modern smartphones, tablets, computers, set-top boxes, gaming consoles, and so on. However, using a high profile may prevent users with very old devices from accessing content.
In short: use the baseline profile if you’re targeting users on very old, underpowered devices. If your viewers tend to use modern devices, the high or main profile should be fine to use.
Please keep in mind that this is an ever-changing technology, so these likely will be replaced by more advanced options in the future.
What is a Container?
Video containers, which are commonly known as “file formats,” are the technology that “holds together” compressed video files. Essentially, video containers store the video content and are responsible for transporting the video content.
Containers include more than just audio and video content. They include metadata about the content, such as the file name, date of creation, what sort of device it was created on, and specs related to streaming.
File formats are important to broadcasters because the metadata lets you know right off the bat if your video file is going to be compatible with your video player and/or codec.
Different Video Containers
Here are some examples of video containers used for professional broadcasting:
- M-PEG4 (MP4) is the most universal video container. It works with the most popular codecs and practically any video player.
- AVI is an older container. It is widely compatible, but AVI files are known to be bulk, which makes them unsuitable for OTT broadcasting.
- MOV is Apple’s container designed for streaming with the Quicktime video player.
- FLV was designed by Adobe to stream with the Flash player.
- WMV is known for its super small file sizes that are perfect for being attached to an email. Unfortunately, the small file sizes obliterate the video’s quality.
Best Container for Live Streaming
Currently, the MP4 container is considered the most universal option. This is because it’s compatible with the most common video codecs and most video players.
It’s important to note that two of the common containers, MOV and FLV, are slowly dying out because they’re each only compatible with one video player.
MOV is the container that was developed to work with Apple’s Quicktime player. The container itself is quite powerful, but it’s not compatible with most other video players.
Dacast’s video player is one of the few third-party players that still support the MOV format. However, it must be encoded after upload to be compatible with all-device streaming.
FLV, on the other hand, was developed for the Adobe Flash player. This used to be the most common container, but the Flash player has become pretty much obsolete so there has been less of a need for FLV.
Like MOV, this format can be compatible with some video players if encoded properly.
Video Codecs vs. Containers
Even though they are two different things, video codecs and containers are often confused with one another. There is also a common misconception that it’s an either-or situation when it comes to these things, but they are actually both essential to professional live streaming.
This misunderstanding is common in the world of professional broadcasting since there is so much technical jargon. It doesn’t help that some codecs and contains have the same name.
These two technologies have different roles in the live streaming process but work together during the transport of the video content from the camera to the viewer-facing video player.
Codecs and containers can be used in many different combinations, but this is not to say that you can randomly choose two. You must choose a pair that are compatible with each other and your video player.
The most common codec and container combination is the H.264 codec with the MP4 container. This is combo is as universal as it gets.
The H.264/MP4 combination works with Dacast, but if you are using another streaming platform, we recommend checking their player’s compatibility.
Other Encoder Settings
In addition to codecs and containers, there some other encoder settings that you should use for live streaming.
Here is a list of required encoder settings for live streaming with Dacast:
VIDEO CODEC | H.264 (x264 may work) |
FRAME RATE | 25 or 30 |
KEYFRAME INTERVAL | 2 secs (or 2x frame rate) |
SCANNING | Progressive |
ENCODING BITRATE | Constant (CBR) |
AUDIO CODEC | AAC-LC |
AUDIO BITRATE | 128 kbps |
AUDIO CHANNELS | 2 (Stereo) |
AUDIO SAMPLE RATE | 48 kHz (48,000 Hz) |
Pay close attention when you’re configuring your encoder so that your settings align with the required settings for your chosen online video platform. Some settings and features within your streaming software may require specific encoder configurations.
Conclusion
Encoding is essential to professional broadcasting. It may seem like a daunting topic to approach, but once you break it down into smaller parts, it’s much easier to understand.
Codecs and containers, for example, are just two of the many moving parts of live stream encoding. Now that you’re familiar with the basics, you’ll be able to apply this knowledge when configuring your encoder settings.
Want to see these settings in action? Use Dacast to live stream video content with the encoder of your choice. Try our live streaming platform risk-free for 14 days. Sign up now to get started with your free trial. No credit card required.
For regular tips on live streaming and exclusive offers, please feel free to join our LinkedIn group.