Moonshine: Lets you stream games from your PC to any device running Moonlight
Moonshine: Lets you stream games from your PC to any device running Moonlight
Moonshine 🌙 Moonshine lets you stream games from your PC to any device running Moonlight. Your keyboard, mouse, and controller inputs are sent back to the host so you can play games remotely as if you were sitting in front of it.
Moonshine 🌙 Moonshine 允许你将游戏从 PC 流式传输到任何运行 Moonlight 的设备上。你的键盘、鼠标和手柄输入会被发送回主机,因此你可以像坐在电脑前一样远程玩游戏。
Features
功能特性
- Isolated streaming sessions: Each stream runs in its own compositor, completely separate from your desktop environment. Your host PC can still be used for other things while you stream.
- 隔离的流式传输会话: 每个流都在其独立的合成器(compositor)中运行,与你的桌面环境完全隔离。在流式传输时,你的主机 PC 仍可用于其他用途。
- No monitor required: Works on headless servers — no HDMI dummy plug needed.
- 无需显示器: 可在无头服务器(headless server)上运行,无需 HDMI 虚拟显示器插头。
- Hardware video encoding: H.264, H.265, and AV1 encoding using the GPU.
- 硬件视频编码: 使用 GPU 进行 H.264、H.265 和 AV1 编码。
- ⚠️ AV1 Warning: AV1 encoding is experimental and has issues on NVIDIA GPUs that cause frame sizes to grow over time (see issue). This should be fixed in driver version 595.44.3.0. Until then, stick with H.264 or H.265.
- ⚠️ AV1 警告: AV1 编码目前处于实验阶段,在 NVIDIA GPU 上存在会导致帧大小随时间增长的问题(详见相关 issue)。该问题预计在驱动版本 595.44.3.0 中修复。在此之前,请使用 H.264 或 H.265。
- HDR support: True 10-bit HDR streaming for supported games.
- HDR 支持: 为支持的游戏提供真正的 10-bit HDR 流式传输。
- Full input support: Mouse, keyboard, and gamepad (including motion, touchpad, and haptics).
- 完整的输入支持: 支持鼠标、键盘和手柄(包括体感、触摸板和触觉反馈)。
- Audio streaming: Stereo and surround sound (5.1/7.1) with low-latency Opus encoding.
- 音频流: 支持立体声和环绕声(5.1/7.1),采用低延迟的 Opus 编码。
Requirements
系统要求
- Linux only. Tested on Arch Linux, but it’s been reported to work on other Linux distributions too.
- 仅限 Linux。 已在 Arch Linux 上测试,据反馈也可在其他 Linux 发行版上运行。
- systemd. Required for launching and managing application processes. Almost all modern Linux distributions include it by default.
- systemd。 用于启动和管理应用程序进程。几乎所有现代 Linux 发行版都默认包含它。
- A GPU with Vulkan video encoding. NVIDIA RTX, AMD RDNA2+, or Intel Arc.
- 支持 Vulkan 视频编码的 GPU。 NVIDIA RTX、AMD RDNA2+ 或 Intel Arc。
- Moonlight v6.0.0 or higher. Compatibility with older versions or unofficial ports is not guaranteed.
- Moonlight v6.0.0 或更高版本。 不保证与旧版本或非官方移植版的兼容性。
Installation
安装
Arch
The simplest method is to install through the AUR using:
yay -S moonshine
Arch
最简单的方法是通过 AUR 安装:
yay -S moonshine
To run Moonshine for your user:
Enable user lingering: sudo loginctl enable-linger $USER
This allows Moonshine to run applications in the user’s session even when the user is not logged in. If your user is always logged in when you want to stream, you can skip this step.
Enable the service to start on boot and run immediately: sudo systemctl enable --now moonshine@$USER
若要为你的用户运行 Moonshine:
启用用户驻留(user lingering):sudo loginctl enable-linger $USER
这允许 Moonshine 在用户未登录时也能在用户会话中运行应用程序。如果你在流式传输时用户始终处于登录状态,则可以跳过此步骤。
启用服务以在开机时启动并立即运行:sudo systemctl enable --now moonshine@$USER
Configuration
配置
A configuration file is created automatically if the path you provide doesn’t exist. When using the AUR package, it defaults to $XDG_CONFIG_HOME/moonshine/config.toml.
如果你提供的路径不存在,系统会自动创建一个配置文件。使用 AUR 包时,默认路径为 $XDG_CONFIG_HOME/moonshine/config.toml。
Pairing with a client
与客户端配对
When you connect with Moonlight for the first time, it will show a PIN. A notification will appear on the host that you can click to open the pairing page, or you can visit it manually at http://localhost:47989/pin. You can also pair from the command line:
curl -X POST "http://localhost:47989/submit-pin" -d "uniqueid=0123456789ABCDEF&pin=<PIN>"
当你首次使用 Moonlight 连接时,它会显示一个 PIN 码。主机上会出现一个通知,你可以点击它打开配对页面,或者手动访问 http://localhost:47989/pin。你也可以通过命令行进行配对:
curl -X POST "http://localhost:47989/submit-pin" -d "uniqueid=0123456789ABCDEF&pin=<PIN>"
Security
安全性
Moonshine is not designed for use on public networks. The underlying GameStream protocol has limitations that mean traffic is not fully encrypted at the application level. If you need to stream over the internet, use a VPN such as Tailscale, WireGuard, or ZeroTier. Do not expose Moonshine ports directly to the internet.
Moonshine 不适用于公共网络。底层的 GameStream 协议存在局限性,意味着流量在应用层并未完全加密。如果你需要通过互联网进行流式传输,请使用 Tailscale、WireGuard 或 ZeroTier 等 VPN。请勿将 Moonshine 端口直接暴露在互联网上。
Acknowledgement
致谢
This wouldn’t have been possible without the incredible work by the people behind the following projects: Moonlight, Sunshine, Inputtino, and magic-mirror.
如果没有以下项目背后人员的出色工作,这一切都不可能实现:Moonlight(没有它就没有 Moonshine 客户端)、Sunshine(为 API 的主机部分奠定了基础)、Inputtino(提供了完善的输入设备实现)、magic-mirror(启发了使用 Vulkan 和 Wayland 合成器进行无头流式传输的思路)。