Applying your Findings - Proryanator/encoder-benchmark GitHub Wiki
This section details out how to use knowledge you've gained from this tool in software like Sunshine, Moonlight, OBS Studio, and many more.
Streaming Host & Client Software Suggestions
The author suggests using the following tools:
- Moonlight - an open-source game streaming client that provides insane low-latency streaming, with a very helpful stats overlay
- Sunshine - an open-source version of GeForce Experience with encoder setting customization
They will be referenced throughout the README in various examples, and can be downloaded from here.
Updating Encoder Settings in Sunshine
We'll first be discussing how to change encoder settings in Sunshine. Bitrate settings will not be something you can set in Sunshine, but will be something you can change in your Moonlight app on your computer or other streaming device.
As of February 2023, Nvidia is stopping support of it's own home GameStream service bundled with GeForce Experience. Introducing Sunshine, the open-source alternative that runs on your gaming rig, and encodes your gameplay footage to be streamed to other devices, like another computer or even your phone. Sunshine, unlike other streaming programs like Nvidia's GameStream, allows you to customize some encoding settings that can often out-perform Nvidia's GameStream program.
Note: we'll assume that you already have a Sunshine server setup and that you have attached at least one client device.
Sunshine sets some encoder settings by default, at the time of writing this, for Nvidia encoders the default preset
is p4
. You can view the currently used encoder settings by going
to youripaddress:47990 -> Web UI -> Configuration -> NVIDIA NVENC Encoder / Intel QuickSync Encoder / AMD AMF Encoder
.
Let's say that using the tools in this project, you identified that of all the possible encoder settings for NVENC_H264 on your 3080, the settings that allowed you to encode 4K@120 were:
-preset p1 -tune ll -profile:v high -rc cbr
To apply these settings in Sunshine (for Nvidia), go to Web UI -> Configuration -> NVIDIA NVENC Encoder
and change to
the following values in the dropdowns:
NVENC Preset: p1 -- fastest (lowest quality)
NVENC Tune: ll -- low latency
NVENC Rate Control: cbr -- constant bitrate
You may have noticed that you could not set the profile for the encoder in Sunshine. Sunshine does not expose all encoder settings, but exposes the ones that make the most impact to your encode (most likely Sunshine defaults profile to high). Perhaps in a future update you'll be able to specify more settings but, for now you may be limited.
Once you've saved these settings, Sunshine will now encode your game using your specific settings, enabling you to stream at potentially higher framerates, or framerates with higher 1% lows than before. (Author was not able to get higher than 4K@90 with default settings in Sunshine and Nvidia's GameStreaming service, but with the findings from this tool, is able to get stable 4K@120).
Applying Bitrate Knowledge in Moonlight App
When using Moonlight as your game streaming client, it auto-recommends a bitrate for you to stream at. Most of the time this is pretty accurate for lower resolutions, however depending on your hardware's capabilities you might be able to get away with less bitrate than it suggests. Even moreso, some AMD GPU's need way more bitrate than Nvidia cards, so you'll want to know if you'll need much higher bitrates.
For example: Moonlight auto-selects 80Mb/s
for streaming 4K@60 game content. However from our testing, you really only
need 50Mb/s
when encoding using H264_NVENC. Notice that this applies to nvenc encoders on Nvidia GPU's, and may or
may not apply for other vendor GPU's, even using the same H264 algorithm.
After running the tool on a 4K@60 input file, we know we can get a visually lossless streaming experience with just 50Mb/s on our Nvidia GPU. We also know that, if we are attempting to stream our games outside our home network, we know that our cellular connection speeds or wifi speeds should be at least 50Mb/s to get a clean 4K@60. In addition to this, our gaming rig (and home network upload speeds) should also be capable of 50Mb/s.
The tools here enable you to know whether you can actually stream to where you are, or if you are bitrate limited, encoder hardware limited, or somewhere in-between. It's easier to know if you can stream games to your phone while on cellular data, and know what resolution & framerate to set your stream to given that you are bitrate limited.
Streaming with OBS Studio
For the most part, if the encoder that you're interested in using to stream with is supported in OBS Studio, you'll be able to apply the settings identified that product the highest FPS or highest quality of a stream at a given bitrate directly in OBS Studio's Settings -> Output area like you normally would.
For example, you can just set the preset, profile, and tune if you are Streaming/Recording using OBS Studio:
https://github.com/Proryanator/encoder-benchmark/blob/main/docs/obs-simple-encoder-example.png
With the use of a very useful plugin called StreamFX you can gain access to passing in even more encoder settings via the UI, in addition to passing arguments directly to ffmpeg itself as well.
If use of the standard preset, tune, and profile settings are not granular enough for you, you can always mess with additional settings via this plugin:
https://github.com/Proryanator/encoder-benchmark/blob/main/docs/streamfx-example.png
Note: there most likely will be a performance hit when applying the same settings that you saw from use of the tools in this project. This is due to some potential overhead in the way that OBS Studio does encoding but, you should be able to get very close to the performance/quality that the tools here identify.