Eric Niquette UI, UX, Accessibility

High-quality, low-latency in-home game streaming with Sunshine and Moonlight

Published Updated

A guide on streaming high-quality, low-latency video and inputs from your gaming machine to almost any other device in your house using the Sunshine server and Moonlight client.

Introduction

In no small part due to the pandemic and the scarcity of next-generation consoles, cloud and remote gaming has exploded in popularity. Sunshine and Moonlight are powerful software solutions that enable the streaming of high-quality, low-latency gaming from a powerful machine to client device.

It should be noted that, as Sunshine has greatly matured since I originally wrote this article, much of the troubleshooting and configurations sections are no longer relevant and have been trimmed.

What to expect

With a sufficiently powerful host and a client with decent video-decoding hardware on a wired network, you can expect a 4k HDR stream at 60 or 120 FPS with very little input delay in 7.1 linear PCM surround, with controller support.

Sunshine and Moonlight can also be used as a powerful remote desktop solution, allowing access to your PC on the go, even offering mouse emulation on touch screen devices.

Will it work on wifi?

While wifi does work, I've found it to be a little hit and miss, even with a wired host and the client sitting just a few feet from the access point. It's definitely usable but introduces the occasional hitching and lag spikes. Your mileage may vary but I don't think it'd work well if both the host and client are using wifi.

I find that other solutions like Parsec are considerably more resiliant to wifi hitching at the cost of image and sound quality, and a touch more input delay.

What are Sunshine and Moonlight?

Sunshine is streaming server service that serves as a replacement — or upgrade, depending on who you ask — to NVidia's defunct GameStream service. In conjunction with the Moonlight client, Sunshine provides a high-quality, low latency stream from your desktop to your laptop, mobile, media box, and other devices.

While in-home streaming clients like Parsec and Steam In-Home Streaming may offer a simpler initial setup, Sunshine and Moonlight offer what is arguably the best performance and image quality.

Requirements

Host

The Sunshine host server (e.g., the one you'll be streaming from) should be your most powerful machine. This is typically a gaming desktop but pretty much any modern device should be work fine. Sunshine has specific hardware requirements but really anything with a relatively recent dedicated GPU should be compatible and support HEVC hardware encoding.

You'll also need to install ViGEmBus if you want controller support.

Client

The Moonlight client is available on an impressively-wide array of devices and platforms. For the best performance, the client should have the hardware to decode H.265 video but H.264 or software decoding options are available as fallbacks.

Configuring Sunshine

Installation

Sunshine is offered in multiple configuration packages. It can be installed as a service (sunshine-windows-installer.exe) which lets it run on the login screen and control elevated prompts, or it can be run from a portable package (sunshine-windows-portable.zip). The portable package is ran on-demand but may need to be run as an administrator to control elevated prompts.

If you plan on using Sunshine regularly, the full installer is probably your best bet. Both options are configured the same way.

Accessing the Sunshine GUI

After the installation and unless configured otherwise, Sunshine will run a web service on port 47990. You can access the GUI by navigating to https://localhost:47990 in your browser.

Sunshine settings

Audio sink

The audio sink device is used as the audio playback device. By default, if the user has Steam installed, the audio playback will be set to the Steam Virtual Audio Speaker, which has the benefit of having no sound playback on the server. Newer versions also provide audio drivers if you want to install them.

Should you need to use a specific device, a list of devices can be found by running the audio-info.exe tool in the Sunshine tools folder.

C:\Program Files\Sunshine\tools\audio-info.exe

Virtual sink

The virtual sink is a device that Sunshine uses to output sound from the host PC so you don't hear audio on the host machine. If you're using a virtual audio device like the Steam Virtual Speaker you can leave this field empty, or enter a device ID.

HEVC (H.265)

High Efficiency Video Coding (HEVC), also known as H.265, provides higher quality video at the expense of higher CPU usage, especially when relying on software encoding. Modern devices now typically have dedicated hardware for encoding and decoding H.265 streams but should you find your devices struggling to keep up, you can disable HEVC in the Advanced settings.

Note that HEVC must be enabled for HDR.

Controller support

If you plan on gaming with a controller, you'll need to install ViGEmBus on your host machine. The driver emulates a gaming peripheral and is compatible with Sunshine. It does not require any configuration or customization - install it and you're done.

Configuring Moonlight

Moonlight is offered on a ton of different platforms; from desktops to phones and TV boxes, I won't go into the specifics for its installation but its all very straightforward. For the sake of this article I'm assuming your client is a Windows machine but the configuration is pretty much the same for all platforms.

Adding a host machine

When you first launch Moonshine, it should automatically discover devices on your network. If your Sunshine host machine does not appear, you can manually add it using the host's IP.

When connecting to the host for the first time, you'll need to validate the connection by entering a four-digit code in the PIN section of the Sunshine GUI. After entering the code, press the "Send" button to confirm the connection. You should only need to do this once per client.

Resolution and FPS

The resolution specified here refers to the client's display, not the host's. It's usually recommended to match the client and host resolutions as well as refresh rates to avoid issues like tearing and scaling, but you can definitely use a higher host resolution if you want to upscale. If you're streaming to a mobile device, you can adjust this setting to match the device's resolution.

The optimal bitrate value depends largely on the resolution, framerate, network speed, and devices being used. If both the host and clients are connected via wired connections and have adequate processing power, you can consider setting the bitrate to 80 or higher. In my experience, going beyond a 100-120 Mbps bitrate offers diminishing returns unless you're streaming in 4k HDR, which can require a bit more. The difference in image quality isn't noticeable enough to justify the processing overhead that can increase input delay.

V-Sync can cause a slight increase in input delay but if you're experience tearing, you can turn on this option. You can leave it off otherwise. I've never noticed tearing myself.

Encoder settings

While the settings vary from one encoder to the next, it's generally best to leave the defaults as-is for optimal performance. Sunshine, by default, will favor settings that reduce input delay at the cost of some slight image degradation in fast-paced scenes.

If you find your host or client struggling to encode or decode despite a low bitrate, encoders also offer a lower quality presets that may help.

Surround sound

To get surround sound on the client, adjust the number of channels in Moonlight's Audio Settings accordingly. The host must be using a capable input device as the audio sink. The default Steam Virtual Speaker device offers up to 7.1 channels.

Note that encoded audio such as Dolby Digital, DTS, or Atmos are sadly not possible; only PCM audio is supported.

Automatic resolution switching

It's quite likely that your host's and client's resolutions won't match which can cause scaling, tearing, or other issues. In my case, my desktop feeds a 165hz ultrawide but my television only supports 120hz at 1440p and I want Sunshine to automatically switch to 1440p at 120hz when I connect.

QRes

When used in conjunction with Sunshine's Command Preparations, QRes facilitates automatic switching the host's resolution and refresh rate. While it hasn't been updated in an eon, QRes surprisingly still works just fine in Windows 11.

As an example set of arguments you can use, the following will change the host's resolution to 1440p at 120hz:

"C:\Tools\QRes\QRes.exe" /x 2560 /y 1440 r:120

Another trick is to keep handful of shortcuts to other resolutions on the host machine's desktop so you can quickly swap after connecting. I have a handful of common configurations:

  • 1920x1080 at 60hz for my laptop
  • 1920x1200 at 60hz for my Steam Deck
  • 2560x1440 at 120hz for my TV
  • 3440x1440 at 165hz for my desktop monitor

There's no need to include the quotation marks when creating shortcuts in Windows so I have the following four shortcuts on my desktop:

C:\Tools\Qres\QRes.exe /x 1920 /y 1080 /r:60
C:\Tools\Qres\QRes.exe /x 1920 /y 1200 /r:60
C:\Tools\Qres\QRes.exe /x 2560 /y 1440 /r:120
C:\Tools\Qres\QRes.exe /x 3440 /y 1440 /r:165

Resolution Automation

Specifically built for Sunshine and Moonlight, Resolution Automation, as its name implies, automatically changes the host's resolution based on the client's configuration.

The tool features a one-click installation script but requires a small Windows configuration beforehand, as well as a full installation of Sunshine; the portable version is not supported.

In my own experience, it tends to be hit and miss and has broken a few times, but I hop between different devices fairly often which may be causing issues. Give it a shot, though. It's an elegant solution when it works.

Virtual displays

Virtual displays are a useful way to provide Sunshine with a resolution that is not supported by your monitor, or when you want to stream while your monitor is turned off to save power or what have you.

Software solutions

While not the most intuitive of tools, Indirect Display Driver Sample can create a virtual display customized to your needs. Once configured, tools like Monitor Swap Automation can be used in conjunction to automatically swap to the correct monitor.

Another option is a utility developed by Amyuni for their USB-based displays that can also be used to create virtual displays. I've never tried it bu from what I could gather it seems to have a high success rate.

HDMI dummy adapters

A simpler hardware approach is with HDMI dummy adapters that, once plugged into the host's HDMI output, will simulate a display that can be configured and used by Sunshine.

When looking at adapters keep an eye on the supported resolutions and refresh rates to find one that'll suit your needs. You may also be able to create custom resolutions for it through other software like the NVidia Control Panel, but your mileage may vary.

Useful shortcuts

Depending on the platform you're using, there are a few shortcuts available in Moonlight that can be quite helpful. You can find a full list of them on the Moonlight Github wiki but I've listed the ones I use regularly below.

Gamepad

Shortcut Description
Start (Hold 2 secs.) Toggle virtual mouse mode
Start + Select + L1 + R1 Disconnect the client

PC/Windows

Shortcut Description
Ctrl + Alt + Shift + D Minimize the client
Ctrl + Alt + Shift + Q Disconnect the client
Ctrl + Alt + Shift + M Toggle mouse capture mode
Ctrl + Alt + Shift + S Toggle on-screen performance display
Ctrl + Alt + Shift + X Toggle fullscreen/windowed mode
Ctrl + Alt + Shift + Z Toggle key capture (alt-tab and the like)

Other resources

Moonlight Setup Guide

Moonlight Docs | GitHub

Sunshine Installation

Sunshine Documentation | Lizardbyte

Moonlight Streaming subreddit

Reddit