
H264 is a widely used video compression standard, with 11 levels to choose from. These levels determine the maximum bitrate, resolution, and frame rate of a video.
In H264, Level 2.1 is the lowest level, with a maximum bitrate of 64 kbps and a resolution of 176x144 pixels. This level is suitable for low-bitrate applications like mobile streaming.
Level 4.0 is a more advanced level, with a maximum bitrate of 30 Mbps and a resolution of 1920x1080 pixels. This level is commonly used for high-definition video streaming.
As you move up the levels, the maximum bitrate and resolution increase, allowing for more complex video content.
A unique perspective: Go2rtc H264 to Webrtc
H.264 Basics
The H.264 codec is a widely used video compression standard that helps reduce video file sizes without sacrificing quality.
It's a bit like how we compress our luggage to fit more into a suitcase, H.264 compression helps squeeze more video into a smaller space.
The H.264 codec uses a combination of intra and inter-frame prediction to achieve high compression ratios.
Intra-frame prediction works by analyzing the current frame and predicting what the next frame should look like.
Inter-frame prediction, on the other hand, analyzes the differences between frames and encodes only the changes.
H.264 also uses a technique called transform coding to further reduce the size of the compressed video.
Transform coding works by breaking down the video into smaller components, such as luminance and chrominance, and encoding each component separately.
The H.264 codec can be used for a variety of applications, including video conferencing, streaming, and broadcasting.
Production and Configuration
Producing H.264 can be a complex process, but it's not as daunting as it seems. There are three configuration options that all producers should understand.
The first option is the one to avoid messing with - very few producers should ever touch the dozens of configuration options that come with H.264. This is because they can be overwhelming and may not be necessary for most production needs.
To produce H.264, you need to understand the basics of its configuration. Like all codecs, H.264 has a specific set of requirements that need to be met.
The three configuration options that all producers should understand are key to producing high-quality H.264 content. These options will help you create video that is both visually appealing and efficient in terms of bandwidth usage.
Understanding these configuration options will help you produce H.264 content that meets the requirements of your target audience.
H.264 Technical Details
Levels apply additional encoding limitations on profiles, like those shown in table 6 from Wikipedia. To comply with Level 4.2, for example, the video can’t exceed 2048×1080@60fps or 50,000 Kbps.
Levels used to matter a lot in the early days of delivering video to mobile devices, but today most current devices can play any level that you can deliver to it. However, service providers like Wowza still require certain level settings for specific video formats, such as 1080p30 or 1080p60.
Here are some key level settings to keep in mind:
- Level 4.2: 2048×1080@60fps or 50,000 Kbps
- Level 4.1: 1080p30 @ 10000
Levels
Levels are a key aspect of H.264 encoding, and they impose additional restrictions on video profiles. These restrictions are outlined in tables like the one from Wikipedia, which shows the limitations for different levels, such as Level 4.2, which restricts video to 2048×1080@60fps or 50,000 Kbps.
In the past, levels were crucial for delivering video to mobile devices, but today most devices can play any level you deliver to them. However, levels still matter for service providers like Wowza, which has specific requirements for levels based on the resolution and frame rate of the video.
For example, to comply with Wowza's requirements, your incoming stream shouldn't exceed Level 4.1 for 1080p30 or Level 4.2 for 1080p60. This means you need to configure your video within the constraints of the level, rather than relying on a specific profile configuration.
To illustrate this, let's look at the encoding preset from Wirecast, which shows that there is no option for level, but rather parameters for resolution, frame rate, and data rate that must be set within the restrictions of the level. For instance, the preset in Figure 3 conforms to Level 4.1 and will work with Wowza Streaming Engine because it's set to 1080p30 @ 10000.
Here are some key facts about levels:
- Levels impose additional restrictions on video profiles, such as maximum resolution, frame rate, and data rate.
- Levels still matter for service providers like Wowza, which has specific requirements for levels based on resolution and frame rate.
- Levels are typically configured by setting video parameters within the constraints of the level, rather than relying on a specific profile configuration.
Profiles
Profiles are sets of encoding tools or algorithms that can be used to encode a file.
The baseline profile (BP) uses relatively few encoding tools, making the bitstream lower in quality than the high profile (HiP) but easier to decode.
Device manufacturers create profiles to meet product cost and performance requirements. This allows them to deploy H.264 and still meet their targets.
For example, Apple integrated silicon capable of playing the baseline profile in the first-generation iPod touch devices to meet its target cost, size, and power consumption targets.
Publishers producing video for those devices encoded using the baseline profile, otherwise the video wouldn’t play.
Today, virtually all newer devices can play the high profile, which is the highest profile used for streaming.
However, if you deliver streams to viewers watching on older devices, you may want to ensure that you have one or two lower-quality streams in your encoding ladder in the baseline or main (MP) profile.
Suggestion: Level Lift Cost
To ensure playback compatibility, all H.264 encoders allow you to specify the profile in its user interface or scripting language.
It's a good idea to check the services' recommendations for profiles when delivering live or video on demand (VOD) streams to a service like Wowza Streaming Engine or Wowza Video.
Performance and Optimization
To achieve optimal performance with h264 level, it's essential to understand the different parameters that affect video quality and compression efficiency.
The maximum bitrate for h264 level 5.1 is 10000 kbps, which is significantly higher than the 6500 kbps limit for level 4.1. This increased bitrate allows for more complex video encoding and better quality.
In addition to bitrate, the number of reference frames also plays a crucial role in h264 level performance. Level 5.1 supports up to 16 reference frames, whereas level 4.1 is limited to 8 reference frames. This increased number of reference frames enables more accurate motion compensation and improved video quality.
A fresh viewpoint: H264 Encoder
H.264 vs VP9 HEVC and AV1
H.264 is still the dominant codec, but VP9, HEVC, and AV1 are giving it a run for its money in terms of performance.
Encoding complexity, or speed, is inversely related to encoding quality. The better the quality, the longer it takes to encode.
VP9 and HEVC take between 2-15 times longer to encode than H.264, while AV1 takes 15-30 times longer.
Encoding quality is about reducing bitrate while maintaining the same quality as H.264. VP9 and HEVC can achieve around 35% bitrate reduction, while AV1 can achieve around 50%.
Better encoding quality can decrease bandwidth costs, but most companies adopt new codecs to enter new markets, not for cost savings.
HEVC was quickly adopted by premium content publishers like Netflix and Apple because it enabled 4K video and HDR. AV1, on the other hand, only recently supported HDR playback standards and has limited playback compatibility.
Here's a quick summary of codec performance:
Preset/Quality
The preset setting is a crucial factor in achieving the right balance between encoding quality and complexity.
You can choose from different presets that vary by codec, such as Ultrafast to Placebo with the x264 codec.
For VOD video, a high-quality preset can optimize quality but lengthen encoding time.
For live video, sacrificing quality might be necessary to achieve real-time encoding, so a lower-quality preset is often chosen.
Other codecs like MainConcept or Beamr may use different presets or not offer presets at all.
The quality setting in Figure 3 determines the preset, so it's essential to understand how they work together.
Ultimately, selecting the right preset depends on your specific encoding needs and goals.
Should we restrict decode buffer size?
The iPhone 6 shipped in September 2014, and supported H.264 video up to 1080p, 60 frames per second.
This means a maximum data rate of 50 Mbps, and a maximum resolution/frame rate combination of 2048×1080 at 60 fps.
To put this into perspective, it would be tough to exceed these specifications if you're distributing HD video.
As Apple specified, so long as one or more streams are "less than or equal to High Profile, Level 4.1", your viewers can find a stream to play.
This suggests that restricting decode buffer size might not be necessary, especially if you're targeting older devices like the iPhone 6.
Quick Guide
To make a long story short, some media players refuse to play video files with an AVC profile level higher than what they support. This is because they search the file for this header info and won't play it if it's too high.
If your media player is one of these, you're in luck because there's a quick way to fix it. You can change some bytes inside the file to make it appear as if it's encoded with a lower level.
The right way to do this is to reencode the file, but that can be time-consuming. Fortunately, you can use a tool like H264LevelEditor to change the value in the file header.
H264LevelEditor doesn't change the video stream compression itself, it just changes the level value in the file header. This is useful because many files are over-leveled, meaning they're encoded with a higher level than they need to be.
Here are the minimum system requirements for H264LevelEditor:
Keep in mind that if the file itself is encoded using features that require a higher level than your player can handle, you'll need to reencode it. H264LevelEditor can't magic away the need for reencoding in this case.
Featured Images: pexels.com

