Moonshine: Headless Game Streaming Server for Moonlight

Moonshine: Headless Game Streaming Server for Moonlight

Moonshine enables headless, isolated game streaming on Linux

Moonshine is a headless streaming server written in Rust that allows users to stream games from a Linux PC to any device running the Moonlight client. Unlike traditional streaming solutions that mirror a physical display, Moonshine creates its own compositor for each streaming session, enabling the host PC to remain usable for other tasks while a game is being streamed and allowing the server to operate without a monitor or HDMI dummy plug.

Key Technical Features

Moonshine provides a lean, focused implementation of the GameStream protocol with several high-performance capabilities:

Isolated Streaming Sessions

Each stream runs in its own compositor, completely separate from the host's desktop environment. This architecture allows for "multi-seat" style functionality where the host machine can be used by one person while another streams a game from the same hardware.

Headless Operation

Because Moonshine manages its own compositor, it does not require an active desktop session or a physical monitor. It can run on headless servers without the need for HDMI dummy plugs to trick the GPU into activating.

Hardware Encoding and HDR

Moonshine utilizes Vulkan video encoding to support H.264, H.265, and AV1. It also supports true 10-bit HDR streaming for compatible games, even if the host's physical monitor does not support HDR.

AV1 Warning: AV1 encoding is currently experimental. On NVIDIA GPUs, it may cause frame sizes to grow over time; the developer notes this should be resolved in driver version 595.44.3.0.

Low-Latency Audio and Input

The server supports stereo and surround sound (5.1/7.1) using low-latency Opus encoding. Input support is comprehensive, covering mice, keyboards, and gamepads, including haptics, touchpads, and motion controls.

System Requirements and Compatibility

Moonshine is designed with a narrow technical scope to maintain a lean codebase, which results in specific hardware and software requirements:

  • Operating System: Linux only (tested on Arch Linux).
  • Process Management: Requires systemd for launching and managing applications.
  • Hardware: A GPU with Vulkan video encoding (NVIDIA RTX, AMD RDNA2+, or Intel Arc).
  • Client: Moonlight v6.0.0 or higher.

Configuration and Installation

Installation on Arch Linux

Moonshine can be installed via the AUR using yay -S moonshine. To ensure the server can run applications in a user session without the user being logged in, users should enable lingering via sudo loginctl enable-linger $USER and enable the service with sudo systemctl enable --now moonshine@$USER.

Application Management

Applications are added to the config.toml file. Each entry defines the command to execute and can include pre_command and post_command hooks to handle environment setup (e.g., stopping conflicting services or adjusting GPU power states).

Moonshine includes automatic scanners to reduce manual configuration:

  • Steam Scanner: Automatically detects installed Steam games.
  • Desktop Scanner: Finds applications via .desktop files in standard system and user directories.

Moonshine vs. Sunshine

While both servers target Moonlight clients, they differ fundamentally in their approach to the display pipeline:

  • Sunshine is a cross-platform, feature-rich server that generally mirrors the existing desktop session. This often means the host desktop is unusable during streaming and may require a dummy plug for headless setups.
  • Moonshine is Linux-exclusive and creates a separate compositor for each session. This allows for headless operation and simultaneous use of the host desktop.

As the creator of Moonshine, hgaiser, explains:

"At its core it's similar to Sunshine but with one important difference: Moonshine creates its own compositor and does not rely on an existing desktop environment."

Security Considerations

Moonshine is not designed for use on public networks. The GameStream protocol has limitations regarding application-level encryption. Users streaming over the internet are strongly advised to use a VPN (such as Tailscale, WireGuard, or ZeroTier) and must not expose Moonshine ports directly to the internet.

Sources