Sunshine/Moonlight Advanced Settings

Profile picture of Christopher Bell

Draft

Aug 21, 2024

·

5 min read

·

12045 Views


Hello I am back with an article on some advanced settings for Sunshine and better Moonlight bitrate targets. For setup of your system see my previous articles here on Devs4Devs.

Self Hosted Cloud Gaming Part 1: https://www.devsfordevs.com/blogs/110-Sunshine%3A-Self-Hosted-Cloud-Gaming:

Self Hosted Cloud Gaming Part 2: https://www.devsfordevs.com/blogs/111-Sunshine%3A-Self-Hosted-Cloud-Gaming-Part-2

I use Sunshine nearly daily and have been since shortly after it launched. I originally used it in my main gaming computer, as my homelab urge grew stronger I converted this PC into a server. I still wanted to game so I used Sunshine/Moonlight and a headless monitor driver called IDDSampleDriver. To maximize performance, especially at higher resolutions, you may need to adjust some settings. For reference my system has been able to stream resolutions up to 4k30fps. I haven’t tested higher because my PC would melt. Most the settings are fairly explanatory, some not so much. Here’s my best interpretation, feel free to correct me if I’m wrong, it’s a learning experience.

PC: Ryzen 7 3rd gen 8c16t

RTX 3070ti

32GB assigned RAM

The settings you will most likely want to adjust are under the “Advanced” tab:

FEC Percentage: This setting has a fairly sizable impact on overall streaming performance. It also has a sizable impact on overall network usage. By correcting for more packet loss we are able to get better image consistency and a more stable network. You should adjust this if you notice frame rate drops or noticeable input lag coming from the network. I was able to deduce this by using task manager to watch network throughput before, during and after frame rate drops. At the same time as the FPS drop I would notice a drop in packets.

Other times where it may be beneficial to increase this is when a device you use often has poor signal quality. This can lead to higher packet loss and increasing FEC percentage can help to correct this. I have only encountered this on my OLED Switch.

My setting: 50

QP: 1, I don’t want a lot of compression and increasing this increases compression. If you have limited bandwidth then increase this.

Minimum CPU Thread Count: I’m not sure how beneficial this was overall, I don’t notice a high level of CPU cost for encoding, that’s done with my GPU. I assigned half my available threads, mostly because why not?

AV1 Support: I leave this at the default

I have no experience with AMD and Intel GPUs so this next section only applies to NVIDIA GPUs

Under the Nvidia Encoder tab

Performance Preset: This is s nifty little function, if you increase the P# you will basically get the same result as increasing the bitrate. I can’t really exceed 200-250Mbps bitrate without network saturation so I generally leave this at P1 but I have had good results through P4 without too much latency or bandwidth increase. This does seem to increase overall quality when also increasing bitrate, this is the most likely solution for 4k60+ to work. It will take a 2.5Gbps+ network, a powerful PC, and patience.

Two-Pass Mode: I have set 2 pass mode to full resolution, it seems to have more stability and has not significantly impacted overall network performance or encoding performance too badly.

Spatial AQ: I keep this enabled because I stream on mobile networks while travelling, I also stream to an OLED Switch. Generally I am streaming 720p when mobile, and to the Switch. At maximum I set it to about 12Mbps, this tends to be the maximum mobile networks in my area can handle given average connection speeds. Spatial AQ helps, by increasing compression. At 720p any quality decrease is hardly noticeable and mostly results in texture blurring with more graphically demanding games.

Single-frame VBV/HRD percentage increase: From what I understand this can increase the systems ability to adjust the bitrate, but if your network has a lot of headroom you can increase this significantly. I’m running Wireless with a 1Gbps backhaul, and 2.5Gbps ethernet to my server, I have increased this to maximum and have had no issues running as high as 1440p 120hz. I do start to see network issues when running in the 4k60+ range.

Use realtime priority in hardware accelerated gpu scheduling: I set this to disabled mostly because I stream at 1080p or less. This prevents my GPU from freezing when it is close to maximum load, which provides more consistency. This could significantly affect the resolution you are able to steam at, and should be enabled if you tend to stream at 1440p60 or higher.

All other settings I keep at default.

Moonlight settings

These are my aproximate bitrate suggestions for your streaming. These may need to be adjusted depending on above settings and available bandwidth.

720p30/60: 8-14 Mbps

1080p60: 25-50Mbps

1440p120/144: 50-100Mbps

4k60: 125-150Mbps

Changing settings can easily double the actual network bandwith you use, bear this in mind based on your hardware and network resources.


Profile picture of Christopher Bell

Written By

@Christopher Bell

No bio found