Question / Help NVENC rendering lag

Altair

New Member
I've been experiencing severe frame rendering lag (40%+) when recording. This is something I noticed some time ago, but since the hardware I've been using (GTX 1080) was so new at the time I figured I'd wait a little while to see if others were encountering the same issues. This occurs when streaming as well but to eliminate network problems let's restrict the discussion to recording.

My native resolution is 1440p but I have my canvas and output resolution in OBS set to 1080p, so the frames being sent to the encoder are downscaled. I'm using the NVENC encoder with a bitrate of 40000 CBR.

Depending on the game and how graphically intensive it is I see varying levels of rendering lag, but it is often 20%+ of the frames regardless of how light the requirements are. As I mentioned above this is a GTX 1080 we're talking about here so it's a little confusing why this is an issue at all. I didn't have this problem on a GTX 770, although I was not running a native resolution of 1440p at the time. Due to my CPU I am limited to using PCI-E 2.0, but since this wasn't a problem for the 770 I'm not sure why it would be for the 1080 either.

I've tested various different scenarios and I've noticed something strange that I didn't think would have that large of an impact, which is that the rendering lag seems to correlate strongly with the number of sources active in the scene. This is true even if the sources are not actually visible in the frame (hidden behind another source, for example). Things like a webcam have the largest impact, but even static image sources have a significant effect (1-2% for each). If I remove all sources except the capture itself the rendering lag drops to almost nothing. I suppose I don't know enough about how hardware encoding/rendering works because it's surprising to me that the sources have that strong of an effect on the encoding at all. Shouldn't the encoding time be at least roughly similar (for CBR) regardless of the elements in the frame itself?

It's worth noting that I tried a similar setup using the x264 encoder and didn't get any rendering lag on my aging i7 2600K (although it did use roughly 25-30% CPU).

Here's a log file from a 10-minute capture of Hitman: https://gist.github.com/anonymous/f4cf5dc4d061f4fc7879d080e21adbdf. You can see that it has 43.9% lagged frames.

Has anyone else encountered this same problem? Is there something different with the Pascal architecture that might be causing this problem?
 

Altair

New Member
I am using the 'Default' preset on the NVENC encoder.

If you're asking why I'm using the 'Advanced' over 'Simple' configuration options, it's because I want more control over the output file size, etc. And although it is irrelevant to this discussion in particular, I require a more advanced configuration for the streaming encoder.
 

Fenrir

Forum Admin
I only ask because for local recordings, it's far better to use CQP than to just set an obnoxiously high bitrate. Here's an example of the settings used with the Indistinguishable Quality preset for NVENC:

Code:
12:18:06.021: [NVENC encoder: 'simple_h264_recording'] settings:
12:18:06.021:     rate_control: CQP
12:18:06.021:     bitrate:      0
12:18:06.021:     cqp:          16
12:18:06.021:     keyint:       250
12:18:06.021:     preset:       hq
12:18:06.021:     profile:      high
12:18:06.021:     level:        auto
12:18:06.021:     width:        2560
12:18:06.021:     height:       1440
12:18:06.021:     2-pass:       true

However, you're right that you shouldn't really be overloading the GPU with what you're doing. Lagged frames usually means something funky is going on with the hardware. Can you run a utility like GPU-Z and verify that the card is running in the highest mode it can?
 

Altair

New Member
I tried the settings you suggested (at 1080p), and the result was the same on the recording end: https://gist.github.com/ddd7df0f5d49997f77c2856f57b4c558

Notably, doing it this way seemed to have a profound impact on the game's performance as well. I lost 15-20 FPS and it was quite stuttery aside from that. Very strange.

Using 'Display Capture' instead of 'Game Capture' dropped the lagged frames to ~10%, but that still seems excessive to me. I can't for the life of me see what the underlying issue is.

GPU load% stays around the low to mid-90s when playing Hitman. 12% when recording with no game currently running. 8% when "idle" (OBS open). 0% with OBS closed.
 
Last edited:

Altair

New Member
I think I've discovered the primary problem. For some reason I had "Multi-adapter Compatibility" toggled in the Game Capture source. Turning that off reduced the number of lagged frames substantially.

The problem isn't entirely eliminated for more demanding games, which still results in about 2% lagged frames, but it has been reduced to an acceptable level.
 
Top