NVENC Performance Improvements (Beta)

dodgepong

Administrator
Forum Admin
#1
This build contains a new implementation of NVIDIA's NVENC encoder in OBS using the new NVIDIA SDK as well as implementing some new performance improvements. Specifically, the main improvement in this build is that frames from OBS are no longer sent to system RAM prior to being sent to the NVENC encoder -- instead, the frames are sent directly from VRAM, which should noticeably reduce resource usage.

The quality improvements you may have been hearing about will largely only be seen on Turing GPUs (RTX 20XX), but the performance improvements should be measurable on all GPUs that have NVENC (GTX 6XX and higher).

THIS IS A BETA, USE AT YOUR OWN RISK.

Here is a link to the build: https://obsproject.com/temp/nvenc-test-9.zip (Fixes a crash when using multiple NVENC encoder sessions)

https://obsproject.com/temp/nvenc-test-6.zip - First public beta release

https://obsproject.com/temp/nvenc-test-8.zip - Fixed an issue with frame jitter at high GPU usage and a crash when stopping encoding

[Note: The new NVENC changes only work on Windows 8 and higher. It does not work on Windows 7 or lower due to missing DX11.1 features. If you use Windows 7, OBS will fall back to the previous NVENC implementation.]

Please report your findings on this thread or in the #beta-testing channel on the OBS Discord. In particular, please test your performance at high GPU load compared to the Release version of OBS (22.0.2).

Note that, due to being a beta build, this binary is not signed, and may have issues with game capture. If you want to make game capture work, you can copy the capture plugin from the release version of OBS. To do this, copy the data/obs-plugins/win-capture folder in the release OBS install directory and overwrite the corresponding folder in the beta directory.
 
Last edited:
#2
At high GPU load it tends to run rather smoothly on battlefield v which is a big improvement, i even went as far as to try with DXR on, at 3440x1440 i was averging about 50 fps or so with everything on ultra, stream was fine no frame drops @ 1080p60fps.

I just noticed, testing on Final Fantasy XIV with preview enable causes large frame drops, guna be going to bed in a moment but will have to try that again on BFV when i wake up


last note is GPU usage %,
BFV was 90-99 %
FFXIV about 70-80%


Edit: Appears the frame drop from Preview on occurs when OBS is on a secondary monitor, frame rate goes back into place when preview is turned off or on the main monitor.
 
Last edited:
#4
Just wondering but if this beta goes well, when could we expect this to be implemented into the next proper update?

This sounds like a fantastic update but I can't imagine I'll be making use of it, as to not mess up my current streaming setup.
 
#5
Hello!
1) What settings in the test version need to be turned on, so that on a 2K stream there is the highest possible quality of the live broadcast? (YouTube)
2) What does the Look Ahead option mean?
3) What does the Psycho Visual Tuning option mean?
 

dodgepong

Administrator
Forum Admin
#7
1) What settings in the test version need to be turned on, so that on a 2K stream there is the highest possible quality of the live broadcast? (YouTube)
I recommend starting by using the Quality preset, and see how your performance is. If things perform poorly, you can reduce to Performance or Max Performance. Max Quality and Quality are actually the same thing, except Max Quality uses two-pass encoding, which uses CUDA, which can have an impact on GPU usage.

2) What does the Look Ahead option mean?
I'm not exactly sure on this one, but I will look into it. Usually look-ahead refers to a process that buffers a certain number of frames in order to improve the accuracy of rate control, where a larger buffer has better results but is slower. Here, though, it's an on/off checkbox, which doesn't really make sense to me in context of that definition.

This option enables dynamic B-frames. Without this option, the encoder will always use the number of B-frames specified in the "Max B-frames" setting. If Look-ahead is enabled, it will only use the number of B-frames that it decides it needs to, resulting in better quality via better resource usage, but uses CUDA.

3) What does the Psycho Visual Tuning option mean?
There are some tools out there that can automatically grade video quality, but sometimes the metrics they use end up grading some things higher that have lower perceived quality to a human in certain situations. Enabling Psycho Visual Tuning turns on some options that sacrifice these quality scores but may increase perceived visual quality, but also uses CUDA. For example, this might end up having a better effect on things like grass, but might degrade something else. It can be subtle and nuanced. I encourage you to give it a try and see what you think.
 
Last edited:
#8
Do you know if it's possible to target a specific GPU with this? for example i got 1070ti's in SLI but i mostly game on one due to lack of good SLI drivers, would i be able to tell the NVENC to target a specific GPU and use 100% of it's resources & cuda whilst the other one games? would be super interesting, or atleast make them work togheter if you got two connected to share the load of encoding
 

dodgepong

Administrator
Forum Admin
#9
No. The only way the performance improvement in this patch can even happen is if OBS is running on the same GPU as the encoder, and you also need to run OBS on the same GPU as the game you're running to game capture it. Generally speaking, it's not possible to use one GPU for encoding and one for gaming.

Well, technically it might be possible to program, probably, but would actually result in significant performance degradation, not improvement.
 
#10
Just tested this out. It's stellar, I can now record 1440p60 without stuttering/overloading PCI bus, can't even tell it is recording.

99% GPU usage, gaming @ 1440p Ultra, uncapped FPS
Game Mode Off

Recording 2560x1440p60, no downscale.
No lagged frames, no encoding lag.
0.5ms average time to render frame! This is easily a 50-70% reduction is rendering time over live.

1546992819863.png


The same settings on Live build I have render times as high as 1.5ms, sometimes creeping up to 4-10ms, and it begins to stutter.

1546992988254.png


One thing I did notice, CQP 16 on the test build uses considerably less bitrate, less than half, with no discernible difference in quality. Same scene, not much difference between the 2 videos, not enough to justify half the bitrate.

Test build video - Average 36.8Mb

1546992454176.png


Live OBS - Average 68.9
1546992481936.png


Code:
15:54:11.999: CPU Name: AMD Ryzen 7 2700X Eight-Core Processor     
15:54:11.999: CPU Speed: 3693MHz
15:54:11.999: Physical Cores: 8, Logical Cores: 16
15:54:11.999: Physical Memory: 16310MB Total, 11476MB Free
15:54:11.999: Windows Version: 10.0 Build 17763 (revision: 195; 64-bit)
15:54:12.000: Running as administrator: false
15:54:12.000: Aero is Enabled (Aero is always on for windows 8 and above)
15:54:12.000: Windows 10 Gaming Features:
15:54:12.000:     Game Bar: Off
15:54:12.000:     Game DVR: Off
15:54:12.000:     Game DVR Background Recording: Off
15:54:12.001: Sec. Software Status:
15:54:12.002:     Windows Defender Antivirus: enabled (AV)
15:54:12.002:     Windows Firewall: enabled (FW)
15:54:12.002:     Windows Defender Antivirus: enabled (ASW)
15:54:12.002: Browser Hardware Acceleration: false
15:54:12.002: Portable mode: false
15:54:12.326: OBS 22.0.2-263-g4fdff6622-modified (64-bit, windows)
15:54:12.326: ---------------------------------
15:54:12.335: ---------------------------------
15:54:12.335: audio settings reset:
15:54:12.335:     samples per sec: 48000
15:54:12.335:     speakers:        2
15:54:12.335: ---------------------------------
15:54:12.335: Initializing D3D11...
15:54:12.335: Available Video Adapters:
15:54:12.337:     Adapter 1: NVIDIA GeForce GTX 1080 Ti
15:54:12.337:       Dedicated VRAM: 3077570560
15:54:12.337:       Shared VRAM:    4256202752
15:54:12.337:       output 1: pos={0, 0}, size={2560, 1440}, attached=true
15:54:12.337:       output 2: pos={-2560, 0}, size={2560, 1440}, attached=true
15:54:12.338: Loading up D3D11 on adapter NVIDIA GeForce GTX 1080 Ti (0)
15:54:12.384: D3D11 loaded successfully, feature level used: 45056
15:54:12.968: ---------------------------------
15:54:12.968: video settings reset:
15:54:12.968:     base resolution:   2560x1440
15:54:12.968:     output resolution: 2560x1440
15:54:12.968:     downscale filter:  Lanczos
15:54:12.968:     fps:               60/1
15:54:12.968:     format:            NV12
15:54:12.968:     YUV mode:          709/Full
15:54:12.968: NV12 texture support enabled
15:54:12.970: Audio monitoring device:
15:54:12.970:     name: Default
15:54:12.970:     id: default
15:54:12.970: ---------------------------------
15:54:12.971: Required module function 'obs_module_load' in module '../../obs-plugins/64bit/chrome_elf.dll' not found, loading of module failed
15:54:12.976: [CoreAudio encoder]: Adding CoreAudio AAC encoder
15:54:13.031: [AMF] AMF Test failed due to one or more errors.
15:54:13.031: Failed to initialize module 'enc-amf.dll'
15:54:13.039: Required module function 'obs_module_load' in module '../../obs-plugins/64bit/libcef.dll' not found, loading of module failed
15:54:13.039: LoadLibrary failed for '../../obs-plugins/64bit/libEGL.dll': The specified procedure could not be found.
15:54:13.039:  (127)
15:54:13.039: Module '../../obs-plugins/64bit/libEGL.dll' not loaded
15:54:13.040: Required module function 'obs_module_load' in module '../../obs-plugins/64bit/libGLESv2.dll' not found, loading of module failed
15:54:13.041: [obs-browser]: Version 2.1.6
15:54:13.042: NVENC supported
15:54:13.087: Couldn't find VLC installation, VLC video source disabled
15:54:13.089: No blackmagic support
15:54:13.092: ---------------------------------
15:54:13.093:   Loaded Modules:
15:54:13.093:     win-wasapi.dll
15:54:13.093:     win-mf.dll
15:54:13.093:     win-ivcam.dll
15:54:13.093:     win-dshow.dll
15:54:13.093:     win-decklink.dll
15:54:13.093:     win-capture.dll
15:54:13.093:     vlc-video.dll
15:54:13.093:     text-freetype2.dll
15:54:13.093:     rtmp-services.dll
15:54:13.093:     obs-x264.dll
15:54:13.093:     obs-vst.dll
15:54:13.093:     obs-transitions.dll
15:54:13.093:     obs-text.dll
15:54:13.093:     obs-qsv11.dll
15:54:13.093:     obs-outputs.dll
15:54:13.093:     obs-filters.dll
15:54:13.093:     obs-ffmpeg.dll
15:54:13.093:     obs-browser.dll
15:54:13.093:     image-source.dll
15:54:13.093:     frontend-tools.dll
15:54:13.093:     enc-amf.dll
15:54:13.093:     coreaudio-encoder.dll
15:54:13.093: ---------------------------------
15:54:13.093: ==== Startup complete ===============================================
15:54:13.104: All scene data cleared
15:54:13.104: ------------------------------------------------
15:54:13.639: WASAPI: Device 'AT BP40 (DUO-CAPTURE EX)' initialized
15:54:13.673: WASAPI: Device 'ATH-R70X (Realtek High Definition Audio)' initialized
15:54:13.673: Switched to scene 'Gaming'
15:54:13.674: ------------------------------------------------
15:54:13.674: Loaded scenes:
15:54:13.674: - scene 'Background':
15:54:13.674:     - source: 'Backdrop Color' (color_source)
15:54:13.674:     - source: 'VanCity' (image_source)
15:54:13.674: - scene 'Desktop':
15:54:13.674:     - source: 'Audio' (scene)
15:54:13.674:     - source: 'Display Capture' (monitor_capture)
15:54:13.674:     - source: 'Foreground' (scene)
15:54:13.674: - scene 'Gaming':
15:54:13.674:     - source: 'Audio' (scene)
15:54:13.674:     - source: 'Background' (scene)
15:54:13.675:     - source: 'Game Capture' (game_capture)
15:54:13.675:     - source: 'Foreground' (scene)
15:54:13.675: - scene 'Audio':
15:54:13.675:     - source: 'AT BP40 (Microphone)' (wasapi_input_capture)
15:54:13.675:     - source: 'ATH-R70X (Headphones)' (wasapi_output_capture)
15:54:13.675: - scene 'Foreground':
15:54:13.675:     - source: 'VanCity' (image_source)
15:54:13.675: ------------------------------------------------
15:54:13.698: adding 21 milliseconds of audio buffering, total audio buffering is now 21 milliseconds (source: AT BP40 (Microphone))
15:54:13.698:
15:54:13.723: CalculateFileHash: Failed to open file 'C:\Users\leede\AppData\Roaming\obs-studio\updates\whatsnew.json':
15:54:14.029: adding 21 milliseconds of audio buffering, total audio buffering is now 42 milliseconds (source: AT BP40 (Microphone))
15:54:14.029:
15:54:20.721: [game-capture: 'Game Capture'] attempting to hook fullscreen process: InsurgencyClient-Win64-Shipping.exe
15:54:20.724: [game-capture: 'Game Capture'] using helper (compatibility hook)
15:54:20.767: [game-capture: 'Game Capture'] hook not loaded yet, retrying..
15:54:23.737: [game-capture: 'Game Capture'] attempting to hook fullscreen process: InsurgencyClient-Win64-Shipping.exe
15:54:23.827: [game-capture: 'Game Capture'] d3d11 shared texture capture successful
15:54:23.837: [game-capture: 'Game Capture'] shared texture capture successful
15:54:25.723: [jim-nvenc] settings:
15:54:25.723:     rate_control: CQP
15:54:25.723:     bitrate:      2500
15:54:25.723:     cqp:          16
15:54:25.723:     keyint:       250
15:54:25.723:     preset:       mq
15:54:25.723:     profile:      high
15:54:25.723:     width:        2560
15:54:25.723:     height:       1440
15:54:25.723:     2-pass:       true
15:54:25.723:     b-frames:     4
15:54:25.723:     GPU:          0
15:54:25.723:
15:54:25.741: [CoreAudio AAC: 'Track1']: settings:
15:54:25.741:     mode:          AAC
15:54:25.741:     bitrate:       320
15:54:25.741:     sample rate:   48000
15:54:25.741:     cbr:           on
15:54:25.741:     output buffer: 1536
15:54:25.772: ==== Recording Start ===============================================
15:54:25.772: [ffmpeg muxer: 'adv_file_output'] Writing file 'D:/Videos/2019-01-08 15-54-25.mkv'...
15:57:19.449: [ffmpeg muxer: 'adv_file_output'] Output of file 'D:/Videos/2019-01-08 15-54-25.mkv' stopped
15:57:19.449: Output 'adv_file_output': stopping
15:57:19.449: Output 'adv_file_output': Total frames output: 10402
15:57:19.449: Output 'adv_file_output': Total drawn frames: 10420
15:57:19.449: ==== Recording Stop ================================================
Love it!
 
Last edited:
#16
I tried recording at 1080p@60fps 6000bitrate New Nvenc with Max Quality preset, Look Ahead and Psycho Visual Tuning enabled on RTX 2070 and everything was smooth like butter with good quality! And performance impact was very low! I love it! But, i cant capture Win10 games, i mean like SoT. On OBS Studio i create a Game Capture and i select the Sea of Thieves window and it works, but in this beta i have black screen, even if i use the windows capture plugin folder from the stable build.
 
#17
I tried recording at 1080p@60fps 6000bitrate New Nvenc with Max Quality preset, Look Ahead and Psycho Visual Tuning enabled on RTX 2070 and everything was smooth like butter with good quality! And performance impact was very low! I love it! But, i cant capture Win10 games, i mean like SoT. On OBS Studio i create a Game Capture and i select the Sea of Thieves window and it works, but in this beta i have black screen, even if i use the windows capture plugin folder from the stable build.
do you use things like MSI afterburner by any chance?
 
#19
Are the improvements also applied to the NVENC/HEVC code? I see that the beta is also including multi-track audio recording with "Custom", and I'd prefer to record in HEVC to cut down on file sizes a bit. It works wonderfully, too; I was just curious if these improvements are applicable to the h.265 stuff?

Thanks!
 
Top