NVENC Hardware Encoding for H264 and H265

Archive of historical feature requests.
Please use the GitHub link above to report issues.
Forum rules
*******************************
Please be aware we are now using GitHub for issue tracking and feature requests.
- This section of the forum is now closed to new topics.

*******************************
Hanbrakeur
Regular User
Posts: 84
Joined: Mon Jun 30, 2014 10:39 pm

NVENC Hardware Encoding for H264 and H265

Post by Hanbrakeur »

Hello,

NVENC support would be great.

It's a specific integrated circuit in Nvidia's GeForce graphic cards since 2012 (GeForce 600 and above) that is dedicated to H264 video encoding. The 3rd generation even supports HEVC/H265 encoding :shock:

Given the popularity of Nvidia's graphic cards, it would be really nice that Handbrake that is one of the greatest H264 encoders supports NVENC that has been created for nothing else than H264/265 encoding. Even their cheapest GeForce 730 that costs only $50 supports NVENC.

A screen recorder called Bandicam already supports it and it works great :)
http://www.bandicam.com/support/tips/nvidia-nvenc/

They even say that it's the best hardware codec, better than CUDA, AMD, or QuickSync :shock:

Image
Last edited by Hanbrakeur on Wed May 13, 2015 8:29 am, edited 1 time in total.
User avatar
Rodeo
HandBrake Team
Posts: 12679
Joined: Tue Mar 03, 2009 8:55 pm

Re: NVENC Hardware Encoding for H264 and H265

Post by Rodeo »

Then again they place the CUDA encoder and QSV in the same boat, LOL.

Anyway, there are still unresolved licensing issues, so this won't happen overnight.
JackNF
Regular User
Posts: 114
Joined: Fri Feb 06, 2009 4:59 pm

Re: NVENC Hardware Encoding for H264 and H265

Post by JackNF »

I've been doing some testing recently on my GTX960 using a command line tool that's been floating around for a few months now (NVEncC). At present software support for NVENC isn't where it would need to be to get me to use it regularly, but as soon as better tools come along it'll be quite a compelling option IMO.

The h.265 encoder isn't quite ready for prime time yet, my card is of the first (only) generation so far with h.265 hardware baked in but it lacks b-frame support for h.265 so doesn't exactly speak to best quality at low bitrates... it's strictly a curiosity for this generation albeit at a couple of orders of magnitude faster encoding then software encoding with x265 on my system at present (AMD FX-8350, 8 cores @ stock 4ghz).

The h.264 encoder OTOH shows great promise as-is. I was test encoding some video (1440x1080 hand drawn cell animation with little to no DNR applied to the source so lots of film grain and fine detail) getting ~260fps with NVEncC while only getting ~72fps using x264 veryfast preset in Handbrake. As NVEncC defaults to CRF 20 that's what I tested at, which is rather high for HD content but looked great with both encoders at less then half the bitrate of the original blu-ray (~12mbps for NVEncC and ~14mbps for x264 vs the ~30mbps original). I'd need to do further testing at lower bitrates and make a closer examination of the output to really speak to encoding quality, but I've been happy overall with what I've seen so far.

Another nice thing about NVENC is that the hardware is designed to actually run two encoding jobs simultaneously at near full speed, something I've tested and seen by running two instances of NVEncC simultaneously. If the right software comes along it'll be an absolute monster at batch encoding large amounts of video very quickly.
Last edited by JackNF on Tue May 12, 2015 2:14 pm, edited 1 time in total.
Djfe
Bright Spark User
Posts: 178
Joined: Tue May 13, 2014 8:01 pm

Re: NVENC Hardware Encoding for H264 and H265

Post by Djfe »

Hasn't somebody around here said that the quality that nvenc outputs for H264 is worse than Intel Quick Sync?
Or am I mistaken? Has it changed since then? Or was that statement about the encoder speed?

Encoding several videos at the same time would be awesome though!
Especially since you could maybe use the CPU for a third encode (if the hardware doesn't throttle the transmission speed too much)
JackNF
Regular User
Posts: 114
Joined: Fri Feb 06, 2009 4:59 pm

Re: NVENC Hardware Encoding for H264 and H265

Post by JackNF »

I don't have current Intel hardware so I can't compare quality, although given that Intel's a few generations further along then Nvidia it wouldn't surprise me. I know my card with it's '2nd Gen Maxwell' architecture is supposed to be better then the NVENC found on the older Kepler and original Maxwell designs, just as newer generations of Intel's QuickSync are better then what's on the older Intel hardware.
Last edited by JackNF on Tue May 12, 2015 2:23 pm, edited 1 time in total.
User avatar
Rodeo
HandBrake Team
Posts: 12679
Joined: Tue Mar 03, 2009 8:55 pm

Re: NVENC Hardware Encoding for H264 and H265

Post by Rodeo »

As far as I know, NVENC only supports constant QP encoding, it doesn't have any CRF-like rate control yet (unlike QSV which has ICQ and LA_ICQ).
Hanbrakeur
Regular User
Posts: 84
Joined: Mon Jun 30, 2014 10:39 pm

Re: NVENC Hardware Encoding for H264 and H265

Post by Hanbrakeur »

JackNF wrote:Another nice thing about NVENC is that the hardware is designed to actually run two encoding jobs simultaneously at near full speed, something I've tested and seen by running two instances of NVEncC simultaneously. If the right software comes along it'll be an absolute monster at batch encoding large amounts of video very quickly.
WOW Thanks for all this info JackNF :)
Rodeo wrote:Anyway, there are still unresolved licensing issues, so this won't happen overnight.
What a pity that some features can't be added because of licensing issues :( For example Sony Vegas cannot use x264 because of GPL restrictions, they had to choose the MainConcept H264 encoder instead :|
EDIT : They also have the x264vfw codec.
User avatar
Rodeo
HandBrake Team
Posts: 12679
Joined: Tue Mar 03, 2009 8:55 pm

Re: NVENC Hardware Encoding for H264 and H265

Post by Rodeo »

x264 has been available under a commercial license for a couple years now. I doubt it's more expensive than MainConcept, but maybe I'm wrong.
JackNF
Regular User
Posts: 114
Joined: Fri Feb 06, 2009 4:59 pm

Re: NVENC Hardware Encoding for H264 and H265

Post by JackNF »

Rodeo wrote:As far as I know, NVENC only supports constant QP encoding, it doesn't have any CRF-like rate control yet (unlike QSV which has ICQ and LA_ICQ).
You're right, sorry it is using constant quant not constant RF. Just one more thing keeping my rudimentary testing from being a proper 100% apples-to-apples comparison between encoders.
musicvid
Veteran User
Posts: 3823
Joined: Sat Jun 27, 2009 1:19 am

Re: NVENC Hardware Encoding for H264 and H265

Post by musicvid »

EDIT : They also have the x264vfw codec.
No, x264vfw is not native in Vegas.
As open source GPL, it is available in Vegas when installed as a third-party system codec.
vfw is an antiquated filter that leaves lots of things out -- such as decoding b-frames.

Commercial x264 support in Vegas probably won't happen, just my guess.
Sony's partner history with Mainconcept predates x264 by several years, and yes, it's pretty expensive because it used to be the only game in town for commercial Windows NLEs.
We've found out over the years there are plenty of politics involved as well . . .
Last edited by musicvid on Tue May 12, 2015 3:02 pm, edited 1 time in total.
Hanbrakeur
Regular User
Posts: 84
Joined: Mon Jun 30, 2014 10:39 pm

Re: NVENC Hardware Encoding for H264 and H265

Post by Hanbrakeur »

You are right musicvid, x264vfw is an external codec. It's a pity that Sony Vegas doesn't support natively x264 the best H264 codec. MainConcept is meh, except for its GPU encoders that can be interesting at high bitrates (at low bitrates, the quality is horrible).

I hope that Handbrake will solve all its licensing issues. It's always frustrating when you have the development tools to implement a feature but are blocked by licensing issues.
musicvid
Veteran User
Posts: 3823
Joined: Sat Jun 27, 2009 1:19 am

Re: NVENC Hardware Encoding for H264 and H265

Post by musicvid »

(at low bitrates, the quality is horrible).
Yes, my partner Jerry ran the low-bitrate tests some time back (cpu-only).
(Let them load completely before playing, they are not optimized for progressive download)
http://www.jazzythedog.com/testing/DNxH ... e.aspx#LBR
I hope that Handbrake will solve all its licensing issues.
Handbrake has been almost ocd about licensing -- which means they plan on being around for a long time :wink:
User avatar
Rodeo
HandBrake Team
Posts: 12679
Joined: Tue Mar 03, 2009 8:55 pm

Re: NVENC Hardware Encoding for H264 and H265

Post by Rodeo »

Hanbrakeur wrote:I hope that Handbrake will solve all its licensing issues. It's always frustrating when you have the development tools to implement a feature but are blocked by licensing issues.
Erm, the NVENC licensing issue is on NVIDIA's end, not ours. IIRC, it lies in the fact that you have to include header files that happen to be GPL-incompatible.
Hanbrakeur
Regular User
Posts: 84
Joined: Mon Jun 30, 2014 10:39 pm

Re: NVENC Hardware Encoding for H264 and H265

Post by Hanbrakeur »

Some info on the NVENC encoder :
https://developer.nvidia.com/sites/defa ... ppNote.pdf
Introduction

NVIDIA's latest generation of GPUs based on the Kepler architecture, contain a hardware-based H.264 video encoder (henceforth referred to as NVENC). This document provides information about the capabilities of the hardware encoder, along with some relevant data about quality and performance.

Before Kepler GPUs, the only NVIDIA solution for video encoding was via use of NVIDIA's CUDA-based encoder, exposed through the NVCUVENC API. One of the disadvantages of the CUDA-based encoder is that it used a combination of the CPU and GPU's 3D engine for encoding, leaving very little processing power for other tasks. This approach also increased overall system power consumption.

NVENC, being dedicated H.264 hardware, does not use 3D engine and hence uses much less power compared to the CUDA-based encoder. It also leaves the CPU to perform other tasks. The hardware is optimized to provide excellent quality at high performance, enabling a wide range of applications that require video encoding capabilities. The NVENC hardware encoder improves encoding performance by almost a factor of 4, compared to the CUDA encoder* (at equivalent quality).

It is important to note that an application can choose to encode using both NVENC hardware and NVIDIA's legacy CUDA encoder in parallel, without affecting each other. Note, however, that, video pre-processing algorithms may require CUDA, and will result in reduced performance from the CUDA encoder.

* CUDA encoder profiled with Core 2 Duo (2.6 GHz) + Tesla C2050 with GF100

Image


Performance

The NVENC hardware is designed to support up to 8X real-time HD video encoding (1080p @30 fps). This means that the hardware can encode 240 frames per second of 1920 × 1080 progressive video. The application can trade performance for encoded picture quality.

A more common setting of the encoder (internally referred to as HQ – High Quality) results in a very good quality encoded bit-stream. At this setting, NVENC can encode 1080p video at 4X real-time; i.e. at 120 fps (no B frames).

With the inclusion of B frames in the encoding, the performance is lower and depends on the exact GOP structure.

The encoding latency is currently 1 frame (without B-frames), but the software supports slice-based encoding and subsequent software API releases will expose this feature to the applications.

The hardware has been extensively tested and verified to yield the advertised performance at all settings. The performance has been measured using the sample application provided with the NVENC SDK [1], using a single encode session and multiple concurrent encode sessions. Figure 2 shows the measured encoding performance of NVENC with various sample video clips using several presets.

Although the performance benchmarking results below use motion video, performance is not different with synthetic content (e.g. gameplay, desktop). However, it should be noted that the quality constraints for such synthetic content can vary significantly from application to application, and this may indirectly affect the performance.


Quality

NVENC hardware has been designed to provide quality comparable to x264 (an open source H.264 encode library) with much higher performance. The comparable x264 preset used for quality comparison between NVENC, x264 and other competitive solutions is as follows (refer to x264 documentation) :


Image
User avatar
s55
HandBrake Team
Posts: 9904
Joined: Sun Dec 24, 2006 1:05 pm

Re: NVENC Hardware Encoding for H264 and H265

Post by s55 »

You may want to do some research based on information not provided by Nvidia.
User avatar
Rodeo
HandBrake Team
Posts: 12679
Joined: Tue Mar 03, 2009 8:55 pm

Re: NVENC Hardware Encoding for H264 and H265

Post by Rodeo »

libav-devel is reviewing another NVENC wrapper… still not GPL-compatible.

Once a GPL-compatible wrapper lands in libav, adding it to HandBrake would be quite easy, but who knows if and when the licensing issue will be cleared…
ashleylai87
Posts: 33
Joined: Tue Jul 30, 2013 3:54 am

Re: NVENC Hardware Encoding for H264 and H265

Post by ashleylai87 »

Updating this thread a bit.....
So Rodeo....apparently libav already added support for Nvenc on 31 May 2015.
http://www.phoronix.com/scan.php?page=n ... evc-encode
http://anzwix.com/a/Libav/NvencH264AndHEVCEncoders

Any comment? I am hopeful......
User avatar
Rodeo
HandBrake Team
Posts: 12679
Joined: Tue Mar 03, 2009 8:55 pm

Re: NVENC Hardware Encoding for H264 and H265

Post by Rodeo »

This code is still unredistributable, just like the FFmpeg wrapper.
Djfe
Bright Spark User
Posts: 178
Joined: Tue May 13, 2014 8:01 pm

Re: NVENC Hardware Encoding for H264 and H265

Post by Djfe »

if you read all previous posts then you would know that the current and one of the knew implementations are protected (licensing issues)
Boildown
Posts: 9
Joined: Tue Sep 10, 2013 5:52 pm

Re: NVENC Hardware Encoding for H264 and H265

Post by Boildown »

NVEnc isn't very desirable for non-live encoding anyways. Their marketing material is technically true but misleading to the majority of their readers. The quality is great, and CPU and GPU usage is low, but it uses a lot of bits to achieve it. The important measurement is Quality Per Bitrate, and NVEnc's quality per bitrate is low.

NVEnc's quality, for the number of bits used to encode, is worse than just about every software H.264 encoder (including x264) and Intel's QuickSync. (And AMD's VCE encoding is probably still too new to really know how they compare.)

What NVEnc is good for is live encoding. But Handbrake isn't a live encoder. NVEnc can make really nice encodes, but it'll fill your hard drive doing it. If you set the bitrate down to something reasonable, it'll look like crap compared to x264 or QS encodes. There's really no place for NVEnc outside of live encoding.

(I was about to say Live Streaming instead of Live Encoding, but NVEnc isn't any good for live streaming either. No live streaming service allows people to upload at bitrates high enough to allow NVEnc to look any good. Its only good for saving live video [chiefly video games] to your hard drive at very high bitrates.)
User avatar
Rodeo
HandBrake Team
Posts: 12679
Joined: Tue Mar 03, 2009 8:55 pm

Re: NVENC Hardware Encoding for H264 and H265

Post by Rodeo »

We're not against supporting it anyway, if people want to use it… once the license compatibility issues are solved, that is.
Djfe
Bright Spark User
Posts: 178
Joined: Tue May 13, 2014 8:01 pm

Re: NVENC Hardware Encoding for H264 and H265

Post by Djfe »

@Boildown:
you are forgetting about the HEVC support though
it doesn't only encode much faster than Handbrake now, but also allows two encodes at the same time

-> it can be a huge time saver until HEVC gets reasonably fast
JackNF
Regular User
Posts: 114
Joined: Fri Feb 06, 2009 4:59 pm

Re: NVENC Hardware Encoding for H264 and H265

Post by JackNF »

AS I mentioned earlier in this thread, the HEVC hardware is a nice curiosity but only present on the latest 900-series cards and really only half-baked at the moment. The lack of b-frames in HEVC encodes with the current hardware is a real showstopper, and while the current lacklustre software support for editing and playing back anything HEVC right now will no doubt be rectified in time it's not there yet. Not even Nvidia's own Shadowplay software bothers to offer it as an encoding option last I checked, and I'd wager they won't add it until they're pushing whatever their next generation of GPUs will be in a year or two from now by which time they will have no doubt improved their hardware encoding designs compared to what's available right now.

When speed matters and hard drive space is cheap and plentiful (but not so cheap and plentiful as to warrant simply ripping ISOs and forgoing re-encoding entirely) that's where I see the use case for NVENC. If you need the absolute best quality at the lowest bitrates then hardware encoders are not for you, but if just you need something fast that's good enough at a manageable bitrate then I think NVENC has the potential to fill that role, if the software to let it do so in an easy uncomplicated manner ever comes along. That just hasn't happened yet.
Hanbrakeur
Regular User
Posts: 84
Joined: Mon Jun 30, 2014 10:39 pm

Re: NVENC Hardware Encoding for H264 and H265

Post by Hanbrakeur »

Rodeo wrote:We're not against supporting it anyway, if people want to use it… once the license compatibility issues are solved, that is.
And I thank you for taking into account my feature request :) NVenc may not give great quality, but those who have a slow computer but an NVENC-Compatible graphic card may find it a good compromise. Not to mention that it speeds up HEVC too. Hope the licensing issues get fixed :(
ashleylai87
Posts: 33
Joined: Tue Jul 30, 2013 3:54 am

Re: NVENC Hardware Encoding for H264 and H265

Post by ashleylai87 »

To be honest though, AMD cpu + gpu users probably would like it if VCE support can be added. This is the only hardware encoder solution available for them.
Post Reply