What is in-home streaming?
In-home streaming lets you use apps or play games from one device, like your computer, on another device in real-time. It sends the screen display and sound from your main device to another one, like a TV or tablet, while also sending back your controls, like moving the mouse or using a controller. This way, you can enjoy what's on your computer from another device in your home.
Assuming you have a solid network, a decently-powerful host machine, and a client device that can process high-resolution, high-framerate video feeds, you can expect to stream up in 4k HDR with 7.1 surround sound with surprisingly very little delay.
What you'll need
For the best possible experience you'll first need a capable network. Both the host and the client should be on a wired connection but you can still get decent results if the client is using wifi as long as you have a quality network that can handle the throughput.
I generally recommend against having both the host and client use wireless. I've never had good results in that configuration, but if that's all you have don't let that discourage you; there are some settings you can adjust to reduce the overhead.
You'll also need compatible hardware. The host machine needs to be powerful enough to encode the video in realtime without significantly degrading performance, and the client needs to have the hardware that can decode that stream quickly. 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 the odd artifacts, especially in fast-moving scenes.
- There will always be some latency. It's usually not enough to cause issues but you probably won't be playing any competitive shooters while streaming.
- High quality streams require a lot of bandwidth, and decently powerful hardware. The process of encoding, broadcasting, receiving, and decoding a 4k signal at 60 or 120 frames per second in realtime takes up a lot of resources.
- You can't use flight yolks, wheels, or other specialized devices on the client. You'll need USB over IP software for that, and a compatible platform.
What are Sunshine and Moonlight?
Sunshine is a streaming server that replaces—or even improves on—NVidia's old GameStream service. It sends video from your computer to other devices like laptops, phones, or media boxes. The Moonlight app then receives this video stream, decodes it, and formats it for smooth viewing on your chosen device.
You may find that other in-home streaming clients like Parsec and Steam In-Home Streaming offer a simpler initial setup, but Sunshine and Moonlight offer what is arguably the best performance and image quality.
Installing Sunshine
Sunshine is available for both Windows and various Linux flavors. Assuming you're on Windows, you have the option to either install the full 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.
After the installation, and unless configured otherwise, Sunshine will run a web service for its UI on port 47990. You can access is by navigating to https://localhost:47990
on the host machine's browser.
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 audio device Sunshine will capture from. When you connect to Sunshine, it automatically sets this audio sink as your Windows default output device, so all sound on your computer is routed to it and can be streamed to your client device.
By default, the audio sink is set to the Steam Virtual Audio Speaker, a virtual device installed with Sunshine to ensure all audio is captured silently for streaming.
Should you need to use another output, a list of available devices can be found by running the audio-info.exe tool in the Sunshine tools folder, located by default at:
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. An easy way to open it is to open a command prompt and drag the executable into the window.
Virtual sink
Think of the Virtual Sink as an extra audio pathway you can use if you want to separate certain sounds or mix additional audio without impacting what's streamed. For example, it can be used to keep specific sounds local to the computer or to mix in other audio for streaming.
By default, the Virtual Sink is configured to use a silent device (the Steam Virtual Speaker) and for regular use, leaving it as-is will work perfectly well.
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.
With that said, in most cases you should be able to bump up the quality presets by one or two with little impact. This is very much dependant on your own configuration but it may be worth trying if image quality is a concern.
Use realtime priority in hardware accelerated gpu scheduling
Hardware-accelerated GPU scheduling (HAGS) is a Windows feature that helps manage GPU scheduling directly on the GPU itself, rather than on the CPU. This has the benefit of reducing the latency and CPU load, typically resulting in improved performance in certain games.
However, in some cases where NVIDIA devices are under high load, HAGS can sometimes interfere with real-time encoding, causing the video stream to suddenly stop while the audio feed continues.
As I understand it — and this may be entirely wrong — this issue may be due to conflicting real-time processing tasks, where the GPU task scheduler and the video encoder compete for resources when the GPU is strained for memory. Disabling "Use Real-Time Priority in Hardware-Accelerated GPU Scheduling" lowers the video encoder's priority from "realtime" to "high," which can prevent the video stream from crashing but may cause the capture to stutter or lag if the GPU is under heavy load.
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 being retired due to a copyright issue, but should hopefully still work for the short-term, foreseeable future.
Network buffers
There are optimization guides floating on reddit recommending you increase your network adapter's TX and RX buffer sizes. In networking, TX and RX buffers are temporary storage areas for data being sent (TX) and data that is received (RX). Buffers help manage data flow and prevent packet loss.
- Large buffers can introduce delays as data could potentially wait longer in the buffer before being transmitted or processed, which can be particularly noticeable in real-time applications like gaming.
- Smaller buffer sizes, on the other hand, reduce latency but can increase the chance of data loss if the buffer overflows, especially on slower connections or if the network is congested.
The long and short of it is that unless your network's in rough shape and you're dropping packets all over the place, don't fiddle with buffers. Sunshine and Moonlight already incorporate Forward Error Correction (FEC) to handle dropped packets during streaming. If you're running into issues, try increasing Sunshine's FEC value and see if that helps.
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 video stream and will not impact the host machine. For example, if your host is sending out a 4K signal but your client can't display that, you can compress it down to 1080p to save on bandwith and processing.
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.
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 pretty conservative and can usually be bumped up quite 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, a 4K stream at 60 frames per second will start seeing diminishing returns around the 120 Mbs range, but you can go much higher (up to 500 following a recent update) if you want to keep compression artifacts to a minimum.
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 frame 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.
Encoded bitstream signals like Dolby Digital, DTS, and Atmos are not supported. Surround sound is only possible via PCM in 5.1 or 7.1.
Virtual displays
If you want to stream with your monitor turned off or need features, resolutions, or refresh rates that your current display doesn't support, virtual displays can bridge the gap. In short, virtual displays trick your PC into believing a monitor is plugged in, which in turn can be captured by Sunshine.
On the hardware side, there are physical dummy display plugs that connect via HDMI, DisplayPort, or USB-C. Dummy plugs are inexpensive, can be purchased online, and are the simplest way to create a virtual display at the cost of limited features.
Software solutions like SudoVDA and Virtual Display Driver are viable options as well and are relatively quick and painless to setup.
There's also a fork of Sunshine, Apollo, that includes a built-in virtual display, amongst other interesting features, that may streamline the process.
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. Use complex, unique passwords and usernames to prevent brute force attacks.
In most home networks, enabling external access only requires that you enable Sunshine's UPnP setting. Universal Plug and Play (UPnP) automatically 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. You should not need any other software, nor any other networking solutions like Tailscale.
Should your network not support UPnP, you'll need to manually configure your firewall and forward network traffic to the 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 Documentation guide for more information.
Once everything has been configured, you'll need your public IP address. You can use web-based services like What Is My IP to find it. Use that address when adding a new PC in Moonlight. If you've already added that machine from your local network, it should automatically add the public IP to the existing configuration.
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) |
See also
-
How to configure Sunshine to automatically match the client's display resolution
Eric Niquette | Niquette.ca
-
How to configure Sunshine to automatically switch displays
Eric Niquette | Niquette.ca
-
How to reboot, shutdown, or log off from your PC with Moonlight and Sunshine
Eric Niquette | Niquette.ca