Video Quality / Compression TutorialAuthor: IPVM Team, Published on Jul 17, 2012
While CODECs, like H.264, H.265, and MJPEG, get a lot of attention, a camera's 'quality' or compression setting has a big impact on overall quality. In this training, we explain what this level is, what options you have and how you should optimize it.
To start, review these two images, (A) and (B):
And answer this question before continuing:
If your gut feel is that this is a trick question you are right. With the information presented, the best answer is likely that it cannot be determined. In this case, technically the correct answer is 'neither - they are the same resolution'. We used the same camera for each image and simply lowered the quality level for the 'B' image (while keeping everything else the same, including resolution - 720p - and CODEC - H.264).
The fact that two exact shots with the same resolution can look significantly different has a number of important implications. Inside, we explain why, covering:
- Quantization levels
- Bandwidth vs. quality loss
- Image quality examples
- Manufacturer differences
- MBR/VBR/CBR impact
- Smart codec impact
Regardless of codec used (MJPEG, JPEG2000, MPEG-4, H.264), all IP cameras offer quality levels, often called 'compression' or 'quantization'.
H.264 quantization is a measured on a standard scale which varies from 0 to 51, with lower numbers meaning less compression, and thus higher quality. If this seems counterintuitive to you, it is understandable, but these measurements were agreed upon in H.264 standards.
Key Tradeoff: Bandwidth Vs. Quality Loss
The key tradeoff in setting quantization is determining how much 'loss' you are willing to accept for a particular decrease in bandwidth. Recall that all production surveillance video compression is 'lossy', meaning that some information will be lost when video is compressed.
The decision which must be made is how much information loss is acceptable. Increase compression/lower the quality level and you save on bandwidth, but reduce quality. Increase quality/reduce compression and you may gain usable details, but use more bandwidth and reduce storage time.
Demonstrated in Pictures
The image below shows the impact of changing quality levels. In order to show this, we took examples from two scenes (indoor / simple and outdoor / complex) and adjusted bitrate. The Average DRF (quantization) levels below, underlined in red can be seen decreasing in both scenes as bitrate goes up. Inversely, image quality increases, with less pixelation and blocking on objects. Note that we used a CBR stream to simply show the effects of bitrate.
All manufacturers set default quality levels. Even if you never touch these settings, the manufacturer will make a choice for you. However, with the vast majority of professional cameras, configuration options are available to let advanced users adjust this.
Below, we look at a few manufacturers to better demonstrate their approaches. Readers should see our IP Camera Manufacturer Compression Comparison test for full details of 10+ manufacturers compression scales and how to default these cameras to "average" compression.
Axis currently uses two different web interfaces, as many of their cameras have not yet transitioned to their new HTML5 based UI. Both new and old web UIs refer to quality as "Compression", with higher numbers being more compressed/lower bandwidth. Beware of this, as inexperienced users may simply increase the scale thinking it increases image quality.
The new web interface uses a slider/manual entry:
While the old interface simply allows free entry:
Regardless of UI, Axis Compression 30 equates to ~28 on the quantization scale.
Bosch's codec setup bases quantization on P-frames, with I-frames allowed to vary by a specific amount ("I/P-frame delta QP" below). So if P-frames are set to 25 and I-frames set to -6, I-frames will use a minimum of 19 quantization.
Hikvision's compression settings are under the video/audio tab, on a scale of "lowest" (most compression) to "highest" (least compression), defaulting to "Higher." These settings are mapped to specific quantization levels, ranging from ~20-35.
Important: MBR/VBR/CBR Impact
Most surveillance deployments use variable bit rate streaming (VBR), which varies bandwidth in order to maintain a pre-set quality level, sometimes with a maximum bit rate cap (called MBR). The levels set above define the quantization level the camera is targeting, e.g., an Axis camera will target quantization level 28, with bitrate increasing and decreasing as necessary.
However, if cameras are set to constant bit rate, quality level is NOT configurable because the bit rate, by definition is 'constant', with quality level automatically adjusted to keep bandwidth the same. For instance, if you have a CBR video stream set at 1Mb/s looking at a white wall, the camera may use a 'high' quality level since it is easy to compress. However, if the lights are turned off and a hand is waved in front of the camera, it may need to drop down to 'low' quality to maintain the same 1Mb/s constant bit rate as compression is more difficult.
For more on the key points of these streaming modes, see our CBR vs VBR vs MBR - Surveillance Streaming tutorial.
Smart Codec Impact
Further complicating things, in the past few years, camera manufacturers have introduced smart codecs, which allow image quality to vary based on activity in the scene. So a person or vehicle moving through a parking lot will be higher quality, while parked cars and trees in the background are lower quality. Generally speaking, these codecs allow for similar or better image quality compared to standard (non-"smart") codecs, but at much lower bitrates, with 25-30% lower bandwidth common, and as much as 90% lower possible.
However, we strongly recommend readers test smart codecs in the scene where the camera will be installed, as some negative image quality effects may be seen. For example, in one of our tests, higher levels of smart codec settings caused blurring/smearing/artifacts in the scene, visible in the subject and background below. Settings should be carefully adjusted to avoid these issues.
Readers should also see our Smart Codec Guide for more information on these and other considerations.
What Should You Use?
Ultimately, the most important question is: what quality setting is necessary in the camera's application?
Unfortunately, it is impossible to give a universal answer as:
- The right level is a subjective judgment call. Changing from a quantization level of 30 to 29 or 42 to 41 produces no magical difference. Often the changes are nearly imperceptible and debatable.
- The right level depends on the complexity of the scene. More complex scenes (like an intersection) will typically benefit from a higher quality levels than a simple scene (like a stairwell). The smaller the elements being observed (like a person across an intersection), the more higher quality levels can capture meaningful details.
However, based on our tests, we offer two key recommendations:
- Quantization ~28 is the "sweet spot": Based on years of ongoing testing, we have found 28 to offer the best tradeoffs between bandwidth and image quality. Many manufacturers default to 28-30, though users should see our IP Camera Manufacturer Compression Comparison for more details on how to standardize others.
- Use smart codecs (but carefully): Because of their drastic bitrate reductions in many scenes, we smart codecs be used wherever possible, as users may be able to increase image quality where necessary, while bitrates remain lower than typical codecs.
11 reports cite this report:
Most Recent Industry Reports
The world's leading video surveillance information source, IPVM provides the best reporting, testing and training for 10,000+ members globally. Dedicated to independent and objective information, we uniquely refuse any and all advertisements, sponsorship and consulting from manufacturers.