How to Encode to HEVC: A Simple Guide for H.265 First-Timers
Changing from Medium to Slower did produce a meaningful quality increase of 6 percent, but came at a cost of extending encoding times by a factor of seven. If you’re already operating at full capacity, this means an additional seven installations, which seems prohibitive. Conversely, if Ultra Fast continues to offer better quality than Medium at one-third the encoding time, high-volume shops with more than one x.265 installation can cut the machines dedicated to encoding by two-thirds.
I ran these results by my contact at Multicore, who said he produced different results with a longer test file. So I encoded a 90-second test file using the Ultra Fast, Very Fast, Medium and Slower Presets and produced the results shown in Table 3. Though the percentages weren’t as stark, the Ultra Fast preset again produced better quality than the Very Fast and Medium presets.
Table 3. Again, the Ultra Fast preset produced better quality than Very Fast and Medium.
I went back and checked an older version of x265 running on Telestream Vantage, and it worked as it should, with a logical progression of longer encoding times and increasing quality. I’m guessing the dynamic I found in my tests of the latest version of x265 won’t hold; either I made an error or x265’s developers will adjust the configuration options to deliver a logical increase in encoding quality over the presets at the cost of encoding time. The overall point is that the pre-set you use could have a dramatic impact on the number of encoders necessary to complete your required encoding chores. For this reason, you shouldn’t blindly assume that the presets produced by the codec developers operate as you would expect or use their presets—you should run your own tests and make your own choices.
Now that we have a good idea which preset we’ll use, let’s circle back and see which data rate will deliver at least as good quality as H.264.
What Data Rate?
The high-level goal here was to find the data rate necessary to produce HEVC video that matched the quality of H.264 at 1080p at 4Mbps. To accomplish this, I encoded the seven test clips with Sorenson Squeeze using the x264 codec at 1920x1080x29.97 at 4Mbps, and then calculated the VQM score with the Moscow University tool. Then I encoded the files with the MainConcept (using P/Q 27) and x265 (using the Slower preset) HEVC encoders at 2Mbps and calculated the VQM score. If the VQM score was within 5 percent of the H.264 score, I stopped for that clip. If not, I added 500Kbps to the data rate, encoded again, and measured again, doing this iteratively until HEVC quality equaled H.264.
Both HEVC codecs achieved parity with the easier to compress clips at 2Mbps, proving the “equal to H.264 quality at half the data rate” claim that’s accompanied HEVC from its inception. Both required a data rate of up to 3Mbps for two of the more demanding clips, though the clips differed by codec. Table 4 shows the results with the MainConcept codec, which had the most trouble with clips containing high motion and high detail.
Table 4. Achieving parity with x264 with the MainConcept HEVC codec
Table 5 shows the x265 results. This codec performed well with the Food City clip, which has both high motion and extreme detail, but had issues with a man walking in a liquor store, which had low motion but extreme detail.
Table 5. Achieving parity with x264 with the x265 codec
Overall, with both codecs, the key lesson is that if you’re encoding talking head or similar easy-to-compress video, a good starting point for your encodes is 50 percent of the data rate of your existing 1080p H.264 encodes. If your videos are harder to compress, either due to extreme motion, extreme detail, or both, start at 62.5 percent of your existing data rate and anticipate having to increase the data rate to 75 percent to achieve similar quality.
Intuitively, the discrepancy in performance between H.264 and HEVC with harder-to-compress clips indicates the relative immaturity of HEVC development. We’re still at the nascent stages of HEVC encoding, and these results indicate that there is definite room for improvement.
Beyond these basics, I also wanted to test several HEVC-specific configuration options, including Wavefront Parallel Processing and Sample Adaptive Offset.
Wavefront Parallel Processing
Wavefront Parallel Processing (WPP) is an HEVC feature designed to improve encoding speed and decode efficiency with a slight potential cost in quality. Interestingly, WPP is enabled by x265 by default and disabled by MainConcept by default, and it turned out to be a good decision by both vendors.
Specifically, when encoding without WPP in x265, encoding time increased by approximately 180 percent, from 131 seconds to 371, while quality dropped by about 3.6 percent. With MainConcept, enabling WPP increased encoding time by about 23 percent while increasing quality by only 0.2 percent. I tested playback of longer files with WPP enabled and disabled on 4-core HP Elitebook and saw no meaningful difference in playback efficiency. Going forward, I would keep WPP enabled in x265 and keep it disabled in MainConcept.
Sample Adaptive Offset
Sample Adaptive Offset (SAO) is a filter applied after the standard deblocking filter; it’s designed to increase picture quality and reduce banding and ringing artifacts at some cost of encoding speed. The filter is on by default with both codecs which again turns out to be a good decision. Specifically, with the MainConcept codec, deploying SOA improved quality by about 13 percent overall, with only a 1 percent increase in encoding time. With x265, SAO improved quality by about 5 percent, with encoding speed again slowed by about 1 percent.
With both codecs, the benefit was not evenly distributed over all clips, but concentrated in two clips: a very detail-intensive security shot of a liquor store and a detail and motion-laden clip of a busy street. However, SAO never reduced the quality of a clip, and given the minimal increase in encoding time, it should be enabled when encoding with both codecs.
The configuration options covered in this article should get you through your first HEVC encodes with more experimentation to come in 2015 and beyond.
This article appears in the 2015 Streaming Media Sourcebook as "How to Encode to HEVC."
Use a single adaptive group, packaged differently for different targets, to keep encoding and storage costs down.
06 Apr 2016
While it's fun to be on the cutting-edge of new video codecs and formats, H.264 should be every publishers' primary focus for the time being.
04 Jun 2015
Why would set-top box makers bother supporting UHD video when home bandwidth connections aren't nearly robust enough to carry it?
24 Apr 2015
If you've spent any time at NAB or IBC, you'd think that HEVC is ready for prime time. The reality is that, for almost every use case, it's nowhere close.
15 Sep 2014
Are you already using HEVC? Are you thinking about it, but waiting until encoding times get shorter? Or are you still on the fence? We want to hear from you in our Streaming Media HEVC Survey.
03 Jun 2014
Which codec delivers better image quality? Which is more compatible? And what about Daala, the spoiler codec currently being developed from scratch?
09 May 2014
Companies and Suppliers Mentioned