We all know how import the B-frame can be for video encoding. At the launch of RDNA2 AMD promised to add it back into their Hardware Encoders for H.264, and finally on March 17th they did just that! The question is, will it actually make a difference?
For years AMD has struggled behind Intel and Nvidia with their hardware based video encoders on their graphic cards. We saw previously that AMD hasn’t been able to keep up with the newer H.265 encodings. However nobody streams on the web with H.265 as nothing supports it. It’s great for video backup or recording your desktop locally, but no streaming service handles it, because most browsers do not support H.265 video playback.
That leaves H.264 until we have AV1 hardware encoders. So does the almighty b-frame make a difference?
The B-frame difference
I am happy to report that with a quick test, that yes, the B-frame is back and does help!
This graph was generated using FFMetrics v1.0, and shows a small section of the encoding of Big Buck Bunny at 5000 kbps. We are using variable bitrate based encoding as hardware encoders are designed with streaming in mind, and they usually requires a set bitrate. 5000 kbps is right in the range Twitch suggests for 1080p.
The blue line is the encoding without B-frames, and the orange line is with B-frames. We are looking at a frame by frame score, with the frame number as the x-axis is on bottom and VMAF is the Y-AXIS.
We can see that there are several places that greatly benefit by saving bitrate with B-frames (the places the b-frame orange line is far above the blue line.) Notice how jagged the line with B-frames is as well. Because of how b-frames operate, they have quality drops compared to the frames around them, however because they are so small, they allow the P and I frames to be much higher initial quality.
Overall the first 2 minutes of Big Buck Bunny encoded from raw Y4M video to H.264 had almost two full point increases on PSNR from 41.694 to 43.326 (out of a possible max of 48). It also had a over a full point increase in VMAF from 94.12 to 95.39 (out of a possible max of 100).
Is AMD better than everyone else finally?
AMD might not be smoking everyone else, but they are a solid contender!
This same video scored a VMAF of 96.13 with Nvidia’s NVENC and the high score of 96.37 to Intel’s QSV. AMD is now less than a VMAF point behind. Whereas previously they were over two full points behind without B-frames.
Here we can see AMD is the red is still a bit below its competitors, with Intel in the blue and Nvidia in the orange.
All hardware encoders still fall short of a proper two-pass software encode with x264 using veryslow preset, which scored 97.33, but that is not a comparable use case. That is simply the ceiling of what’s possible.
Also be aware that not everything is going to instantly support this feature. You’ll have to keep an eye on your favorite streaming software release notes and see if they add it in.
Wrap Up
Sorry I don’t have time for a deeper dive with a lot more comparisons. However Big Buck Bunny is a solid test for B-frames, and I am confident there will be similar behavior across other media that benefits from b-frames. Expect a quality increase, but not to be quite at the same level as the competitors.
These tests were done on two very different systems, so not providing encoding speeds. However they were all using latest drivers available as of 2022-07-01 and latest version of rigaya’s hardware encoding software.
Commands run:
# AMD 6900XT VCEEncC64.exe -i big_buck_bunny_1080p24.y4m --trim 0:2880 --video-metadata clear --metadata clear --chapter-copy -c avc --vbr 5000 --bframes 3 --ref 3 --b-pyramid --preset slow --level auto --motion-est q-pel --pe --colorrange tv --avsync cfr -o big_buck_bunny_1080p-vce-5000-bp.mp4 # Intel i7-12700H QSVEncC64.exe -i big_buck_bunny_1080p24.y4m --trim 0:2880 --video-metadata clear --metadata clear --chapter-copy -c h264 --vbr 5000 --bframes 3 --ref 3 --quality best --output-depth 8 --level auto --colorrange tv --avsync cfr -o big_buck_bunny_1080-qsv-5000.mp4 # NVIDIA GeForce RTX 3060 Laptop NVEncC64.exe -i big_buck_bunny_1080p24.y4m --trim 0:2880 --video-metadata clear --metadata clear --chapter-copy -c avc --vbr 5000 --bframes 3 --ref 3 --bref-mode disabled --preset quality --aq --aq-strength 0 --level auto --multipass 2pass-full --mv-precision Q-pel --colorrange tv --avsync cfr -o big_buck_bunny_1080-nvnec-5000.mp4 # Also tried with bref-mode each and middle for NVENC. Middle had a slight bump to VMAF 96.17, but wasn't worth re-generating the charts.
I wonder, why now, just on the verge of RDNA2 passing the baton to RDNA3? And I wonder if this prepares the ground for more impressive improvements with RDNA3’s encoder?
I am guessing it has simply been a resource constraint that took them so long, as they promised it a year ago. RDNA3 should include AV1 encoding support as well, so no idea if they will improve the entire VCN encoding ecosystem with 4.0 but would be a good time to do it.
I’m interested to know if this also impacts x265 hardware encoding performance? I’m in the process of building a new computer and one of the tasks, besides work/gaming, will be to convert my BluRay/DVD collection to HEVC-mkv-files. At first my initial thought was Nvidia RTX3080 (of course) but right now I am really thinking of an AMD RX6950 XT. Pricewise it doesn’t make that big of a difference in my country. Also for my work/games it’s not a huge deal (overal AMD even scores better in those areas), but if Quality/Performance of the H265-encoding suffers than I would likely stay on Nvidia. At the moment I’m running on a GTX1060 Mobile and Fastflix and nvencc give me great results. Would love to hear your thoughts on this…..
I actually did testing for just that use case: https://codecalamity.com/hardware-encoding-4k-hdr10-videos/#hardware-encoding-head-to-head
tl;dr: Nvidia wins hands down for HEVC. AMD never said they would bring B-frame or advance features to HEVC and both Nvidia and Intel have much better H.265 encoding. The new generation coming out in the fall will support AV1 as well, and probably have some improvements if you’re still in the looking to build phase and can wait a bit (no idea how well prices will be then though.)
On Intel you can use –extbrc which will improve the quality a bit for CBR bitrate mode. If you are testing H265 try CQP on Intel with 14 bframes, open gop, and SAO+tskip off. Very good quality, Nvidia cannot match this.