Eric Niquette

What is in-home streaming?

In-home streaming is the process of capturing the video feed from one machine and transmitting it to another in realtime. This exchange also includes inputs and commands so you can use the mouse, keyboard, or controller remotely. In other words, you can play your desktop from your TV, laptop, phone, tablet, or any other supported device.

Assuming a solid network connection, a decently-powerful host, and a client that can process high bitrate video signals, you can expect to stream up to a 4k resolution in HDR at high framerates and in 7.1 surround sound with very little delay.

What you'll need

For the best possible experience, you'll first need a capable network. Ideally, both the host and the client should use a wired connection but you can get decent results on wifi if you have a quality network.

You'll also need compatible hardware. The host machine needs to be powerful enough to encode the feed in realtime, and the client have the brunt to decode it. In general, the faster the devices, the less input delay you'll feel as it will cut down on processing time.

Ideally, you want both devices to support AV1 or H.265 hardware decoding, though there are fallback encoders available should you be using older devices.

Limitations

So you're thinking this all sounds nice and all, but what's the downside? Well, there's a couple of things you should keep in mind.

  • Encoded audio formats like Dolby Atmos and DTS are not supported. Only linear PCM surround is available in either 5.1 or 7.1 channels, which isn't too bad.
  • Media with digital rights management (DRM) cannot be captured.
  • Expect some visual degradation. The amount will vary with the encoder, bitrate, and quality settings, but you're inevitably going to notice some form of colour banding and artifacts.
  • There is some input delay to consider. It's usually not enough to cause issues but you won't be playing competitive shooters while streaming.
  • Higher quality streams require a lot of bandwidth and decently powerful hardware to encode, send, receive, and decode 4k signals at 60 or 120 frames per second in realtime.
  • You can't use flight yolks or wheels on the client device. You'll need USB over IP software for that, and a compatible platform.

What are Sunshine and Moonlight?

Sunshine is the streaming server 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 the video 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.

Installing Sunshine

Sunshine is available for Windows and a variety of Linux flavors. Assuming you're on Windows, you have the option to either install the full Sunshine package, or run it as a portable application.

The full installation package (sunshine-windows-installer.exe) will configure Sunshine as a service, allowing it to run on the login screen and control secured prompts. The full package also includes Steam audio device drivers, and other useful tools. By default, this is the installation I recommend for ease of use.

The portable package (sunshine-windows-portable.zip) can be run locally without administrative permissions, but it lacks some of the features the full installation provides.

Following the installation, and unless configured otherwise, Sunshine will fire off a web service on port 47990. You can access the GUI by navigating to https://localhost:47990 on the host machine.

You'll need to create a user ID and password combination the first time the GUI is accessed. Take into consideration that an attacker would have full access to your machine if cracked, so select a secure ID and password.

Configuring Sunshine and best settings

The Sunshine GUI is a host to a broad array of settings and options you can configure to make the most of your setup. Let's take a look at some of the more obtuse ones and try to make sense of them.

Audio sink

The audio sink — not to be confused with audio sync — is the device Sunshine will capture audio from. In other words, it'll set this device as the output in Windows and capture from it. If present, Sunshine will default to the Steam Virtual Audio Speaker which has the benefit of having no audible sound on the host and is highly configurable. The Steam Virtual Audio Speaker is installed alongside Sunshine unless checked off in the installation wizard.

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

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

Note that the audio-info tool cannot be run directly and should instead be launched from a command prompt or via PowerShell.

Virtual sink

The virtual sink is the device Sunshine will route output audio to. By default, audio will be tunnelled to the Steam Virtual Speaker so you don't hear it on the host as you stream, but you can specify a different device output if desired.

HEVC and AV1 Support

High Efficiency Video Coding (HEVC), also known as H.265, provides higher quality video at the expense of a slightly higher CPU overhead. Modern devices typically have dedicated hardware for encoding and decoding H.265 streams. If you find your client is struggling to keep up, you can disable HEVC in the Advanced settings and see if it helps. Note that HEVC must be enabled for HDR.

AV1 is a newer codec that promises up to 30% better performance than H.265. If your both your host and client devices support it, AV1 will probably yield better performance and fewer visual artifacts.

Advanced encoding settings

In the vendor-specific encoding tabs are series of preset quality and compression settings. Unless your devices are struggling to encode or decode the stream, or you want to improve the image quality at the expense of an increase in input delay, leave these as-is. They've already been optimized to offer the fastest response.

Use realtime priority in hardware accelerated gpu scheduling

Hardware-accelerated GPU scheduling (HAGS) is a Windows feature that is utilized to, amongst other things, process features like raytracing, frame generation, and other enhancements.

On NVidia devices, hardware-accelerated GPU scheduling has been known to occasionally trigger issues when encoding in realtime, resulting in the video stream abruptly terminating while the audio feed continues. You can disable this option at the cost of some performance and image quality in certain games and scenarios.

As I understand it — and this may be entirely wrong — this is caused by conflicting realtime processing tasks, where the GPU task scheduler and the video encoder clash and fight for resources. This setting effectively lowers the priority of the video encoder from realtime to high, which can cause some stuttering when the GPU is strained for memory and the encoder lags behind.

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. ViGEmBus is now bundled in with Sunshine and simply needs to be enabled during the installation.

ViGemBus is effectively being retired due to a copyright issue, and its author has announced he is stepping away from the project, but it should (hopefully) still work for the foreseeable future.

Installing Moonlight

Moonlight is available on phones, TV boxes, consoles, Linux, Windows, and various other systems. 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.

Its installation does not require anything in particular.

Configuring Moonlight and best settings

Adding a host machine

When you first launch Moonshine, it should automatically discover active Sunshine installations on your network. If that's not the case, as it often is for me, you can manually add a device using the host machine's network IP.

When connecting to a host for the first time, Moonlight will generate a four-digit security PIN that has to be entered in the Sunshine GUI's "PIN" section to validate the connection. You should only have to do this once.

Resolution and framerate

The resolution and refresh rates specified here refer to the client's display, not the host machine's. However, where possible, try to match the client and host resolutions to avoid scaling. If you're streaming to a mobile device, you can adjust this setting to match the device's resolution if desired.

Moonlight's requested resolution does not affect the host machine's resolution. The host's display will remain as-is and the client image scaled to fit.

Bitrate

The optimal bitrate depends largely on the resolution, framerate, network speed, and the capabilities of the host and client. Moonlight will provide a suggestion as you change the resolution and refresh rates but I find these to be a little conservative and can usually be bumped up a bit.

If the host and clients are both on a wired connection and have decent hardware, you can consider setting the bitrate to 60-80 or higher, depending on the resolution. In my experience, in 4K resolution at 60 frames per second, setting the bitrate beyond 100 to 120 Mbps offers diminishing returns. The difference in image quality isn't noticeable enough to justify the processing overhead that can increase input delay.

As a general rule, try Moonlight's suggested rate and increase it a little if you find the image quality isn't up to par.

The greater the bitrate, the greater the bandwidth and processing power required to encode and decode the stream. If your devices or network struggle to keep up, reduce the bitrate, resolution, and/or refresh rate.

V-sync

As it can potentially add a slight input delay, v-sync should only be enabled if you're experiencing tearing. In my experience, this is typically more of an issue on client devices with 60hz displays than it is at 120hz or higher.

Where possible, try to match the host and client's refresh rates ratios. For example, if the host outputs 144hz but the client can only display 60hz, change the host to 120hz so it divides cleanly (2:1) to 60hz on the client to prevent tearing and juddering.

You should disable your game's vsync options when streaming.

Decoder settings

Unless you're using an old client that does not support hardware video decoding, leave these as-is. On connection, Sunshine and Moonlight will automatically negotiate and figure out what encoder to use.

If your device struggles with H.265, you may find some respite with H.264 at the cost of image quality. Conversely, some devices may find that H.264 offers lower latency than H.265 so give it a shot!

Surround sound

To get surround sound on the client, adjust the number of channels in Moonlight's Audio Settings accordingly. The host's audio sink must be able to output the number of desired channels. The default device, Steam Virtual Speaker, supports up to 7.1 channels.

If you've specified a custom audio device as the audio sink, you may need to configure Windows to output to the correct number of channels as well.

Bitstream audio signals like Dolby Digital, DTS, and Atmos are not supported. Surround sound is only possible via PCM in 5.1 or 7.1.

Accessing Sunshine through the internet

By default, Sunshine can only be accessed from machines on the local network. However, it can be configured so you can connect to your machine from anywhere.

Exposing a remote desktop solution to the internet is not something you should do carelessly. If compromised, it could allow full control your PC. Be sure to use a complex password to prevent brute force attacks.

In most cases, enabling external access only entails enabling Sunshine's UPnP setting. UPnP configures your network, adds a rule to the firewall, and forwards connections to the appropriate ports automatically. To enable the feature, navigate to the Sunshine GUI and enable UPnP in the General tab.

Should your network not support UPnP, you'll need to manually set your firewall and forward the traffic to a specific machine. The following table outlines the ports Sunshine needs to operate.

Description Port Protocol
HTTPS 47984 TCP
HTTP 47989 TCP
Web 47990 TCP
RTSP 48010 TCP
Video 47998 UDP
Control 47999 UDP
Audio 48000 UDP

If you need to configure Sunshine to utilize ports other than the default set, check the Sunshine Documentaition guide for more information.

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 window
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 spcial key capture (alt-tab and the like)