Question / Help X264 or nvenc?

Crazywasp

New Member
I know this has been probably answered a few times, but I didnt really font the other posts useful. My problem is that right now im using x264, but its really laggy. Im wondering whether switching to nvenc would help or not. Here are my specs: i7 6700 hq 16 gb ram gtx 960m (yes it is the top model of the xps 15 9550)
 
It MAY be worth trying, but if you're streaming the picture quality loss likely won't be worth it.
 
If you're streaming, you won't get much out of going with nvenc, as its quality per bitrate is terrible compared to x264.

If you're recording, you can just set a quality target and be done with it.

There's also no guarantee your video card actually supports nvenc, as you're on a laptop.
 
NVENC (starting on Maxwell, GTX 9xx) is almost equivalent to x264 veryfast, so it can be used as a replacement.
 
@Harold, I don't know why you always write that nvenc has "terrible" quality per bitrate compared to x264. This is not true. According to this research, Nvenc on Maxwell and above is almost equivalent to reasonable streaming settings with x264. Moreover, if someone has lags and dropped frames due to high CPU usage resulting from x264, his stream quality will be definitely better with nvenc than with x264, because he will not get lags and dropped frames due to lower CPU usage.
 
@Harold, I don't know why you always write that nvenc has "terrible" quality per bitrate compared to x264. This is not true.

It's demonstrably true. 100% true. BTW I'm a big fan of NVENC, but at silly bitrates like 50Mbit/sec. It's why when Shadowplay first dropped a couple of years ago, NVidia defaulted it to: 50Mbit/sec. Why? Because the hardware encoder can't compress the video. It can only encode it. So if you want it to encode at 6Mbit/sec or 3.5Mbit/sec or something lower, the software has to remove detail to accomplish that before sending it to the encoder.

Harold is right. There is literally no way you're going to get even close to the same level of detail and picture quality out of NVENC at low bitrates than you will x264. But the obvious trade-off: 0 load on the system vs pinning the CPU at near 100%.
 
NVENC can compress video, it's just not very effective as it can't use all the features that CPU based x264 encoding can use.
From my own testings @3.500 - 6.000 kbit/s, I would say that NVENC (on Pascal) is definitely worse than x264 at the default preset "very fast", but it is better than x264 with preset "ultra fast".
 
It's demonstrably true. 100% true. BTW I'm a big fan of NVENC, but at silly bitrates like 50Mbit/sec. It's why when Shadowplay first dropped a couple of years ago, NVidia defaulted it to: 50Mbit/sec. Why? Because the hardware encoder can't compress the video. It can only encode it. So if you want it to encode at 6Mbit/sec or 3.5Mbit/sec or something lower, the software has to remove detail to accomplish that before sending it to the encoder.

H264 Video Encoding is compression. H264 is a lossy codec, which means that this "removal of quality" is intended by design in order to still fit within the data. If you want lossless video encoding, UtVideo is what you want to use.

Harold is right. There is literally no way you're going to get even close to the same level of detail and picture quality out of NVENC at low bitrates than you will x264. But the obvious trade-off: 0 load on the system vs pinning the CPU at near 100%.

I have done tests that do not rely on user input here. These tests were repeated across a number of devices for Nvidia (only had an AMD RX 480 for AMD) and always had the same bit identical result on Maxwell and Pascal GPUs, which is only slightly below x264 veryfast. The difference gets larger at smaller bitrates due to the fact that NVENC properly follows the maximum bitrate per second limitation while x264 will go over it if it is too low.

The difference at 2500kbit for example is 0.607%points, the %point difference between x264 veryfast and x264 medium. At 3500kbit it's 0.4886%points, at 6000kbit it's mere 0.3049%points - all small enough that you need very specific scenes to be encoded to even figure out what the difference is, often requiring software to tell you exactly where it is different.
 
At 3500kbit/s I recorded the same scene (game footage with some motion) in both NVENC and x264 faster and I always knew, which one was done in NVENC.
Without any direct comparison, it's hard to spot if the recording is done with NVENC or x264, but switching between both clips, it was pretty obvious.
 
Ideally we'd do a blind test, as software checking will find every single thing that the naked eye can't even see during video playback. Here's two sets of videos with common streaming settings, 1280x720 60 fps, NV12 BT.601 Partial:

3.5mbit (Commonly used streaming bitrate for 720p30 and 720p60)
6.0mbit (Recently "allowed" by twitch, still not adopted widely)
Which one of both sets is x264 veryfast? (Edit: It's rather obvious in the 3500kbit case, as the encoded video really exploits all areas of encoding, less so at 6000kbit)
 
My guess from watching the files 2 times each:
3.5mbit:
File 1 = NVENC
File 2= x264

6mbit:
File 1 = x264
File 2 = NVENC

As most of those scenes are pretty easy to encode, it's not very obvious. When you have something like Rocket League or ARK where there is a bright image with a bunch of moving details and maybe a webcam or static logo in one corner, it's a bit easier to see the downsides of NVENC.
 
Last edited:
Yep, that's correct. In both videos NVENC has issues with bright flashes and transparency, while almost matching x264 with movement and solid objects - also this is a rather extreme example. Difference for both files here is ~0.3%points.

Now if you're Twitch partnered or streaming to YouTube, this subtle detail is lost anyway in transcoding, or unnoticeable in gameplay (as the focus may be different). If you can deal with NVENC losing a tiny amount of detail in some cases while being almost identical to x264 veryfast, why would you not use it - especially because it has near zero cost?
 
The differences are more noticable at 1080p 3500kbps, NVENC vs VeryFast.
comparing: UnrealEngineElementalDemo.nvenc.3500kbit-bd-2pass.h264
with this: UnrealEngineElementalDemo.x264.3500kbit-veryfast.h264

1. I see less motion blur on NVENC mostly at 2:12, more noticeable when playing back video at slow motion, no b-frames on this NVENC video?
2. Fast moving particles at 1:37 looks better on NVENC, but x264 have better background details.
 
The differences are more noticable at 1080p 3500kbps, NVENC vs VeryFast.
comparing: UnrealEngineElementalDemo.nvenc.3500kbit-bd-2pass.h264
with this: UnrealEngineElementalDemo.x264.3500kbit-veryfast.h264

You're comparing BlueRay quality with veryfast, compare hq (High Quality, recording preset) or llhq (Low Latency High Quality, streaming preset) with veryfast instead. Additionally, 3500kbit is not enough to properly store a 1080p60 stream, but it does highlight the differences in how each encoder chooses to proceed with an image. You probably want H265/HEVC or AV1 for those cases, YouTube accepts HEVC uploads for a few months now.

1. I see less motion blur on NVENC mostly at 2:12, more noticeable when playing back video at slow motion, no b-frames on this NVENC video?
In the videos linked above, the settings were identical. In the videos in the GDrive slide, the videos all had "-bf 0" set, in order to maintain identical results across hardware. Maxwell architecture had some odd results with -bf not being 0. If you want I can re-run the tests on HW that I currently have available with B-Frames enabled.
 
There seem to be too little difference between NVENC "bd" and NVENC "hq". I compared it with "bd" because your table have "bd" higher up, above "hq", but in reality they show the same SSIM numbers. It might help to have more digits on SSIM numbers.

In the videos linked above, the settings were identical. In the videos in the GDrive slide, the videos all had "-bf 0" set

Looking at Mediainfo for x264 videos, it shows lots of x264 settings. There is bframes=3, Look for it with web browser's find in page, ctrl+f.
Code:
Complete name               : C:\Users\sam86\Downloads\UnrealEngineElementalDemo.x264.3500kbit-veryfast.h264.mp4
(...)
Writing library             : x264 core 148 r2762 90a61ec
Encoding settings           : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=24 / lookahead_threads=8 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=1 / keyint=120 / keyint_min=61 / scenecut=40 / intra_refresh=0 / rc_lookahead=10 / rc=cbr / mbtree=1 / bitrate=3500 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / vbv_maxrate=3500 / vbv_bufsize=3500 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=1:1.00
 
There seem to be too little difference between NVENC "bd" and NVENC "hq". I compared it with "bd" because your table have "bd" higher up, above "hq", but in reality they show the same SSIM numbers. It might help to have more digits on SSIM numbers.

Take a look at the field "Notes", which states the problem with some of the results. Only Low Latency presets managed to stick within the bitrate restrictions, bd/hq/default all blew past that limit (you can see that with ffprobe or Bitrate Viewer).

Looking at Mediainfo for x264 videos, it shows lots of x264 settings. There is bframes=3, Look for it with web browser's find in page, ctrl+f.

Might have been overwritten by the preset, I'll re-run the tests overnight and add results for -bframes 3 on nvenc and -bframes 0 on x264.
 
Take a look at the field "Notes", which states the problem with some of the results.
Well then, the quality comparison might be inaccurate...
actual bitrate displayed from Mediainfo, filesize, for 163 seconds of video.
3656 Kbps, 74,529,798 bytes, UnrealEngineElementalDemo.nvenc.3500kbit-hq-2pass.h264
2967 Kbps, 60,456,547 bytes, UnrealEngineElementalDemo.x264.3500kbit-veryfast.h264
3500 Kbps, 71,312,500 bytes, calculated (3500 * 1000 / 8) * 163 (seconds in video).

Your x264 shows threads=24 in Mediainfo, this can affect the quality with VBV/CBR. My CPU (i7-2600) makes x264 default to threads=12.
 
Back
Top