Let op: Tweakers stopt per 2023 met Tweakblogs. In
dit artikel
leggen we uit waarom we hiervoor hebben gekozen.
DIY 4K Steam Link (aka Moonlight Box)
Vanwege een aantal reacties in dit nieuwsbericht dacht ik dat ik een korte howto van mijn setup even op het digitale papier wil toevertrouwen. Ik doe het even in het Engels zodat onze internationale vrienden er ook nog wat aan hebben.
.
To install the OS you can use fe this guide. Make sure that you enable SSH.
Insert the SD card, and connect the RPi to the TV and the network. Make sure you are using the HDMI-0 port on the Pi4 (closest to USB-C power jack)
After booting the RPi. Run raspi-config configure it to auto login (Option 1 System Options, S5 Boot / Auto Login, B2 Console Autologin) and configure the max GPU memory (Option 4 Performance Options, P2 GPU Memory set it to 256)
SSH into your PI and edit the /boot/config.txt.
Find the line with
and change it to this:
With some cooling and heatsinks this overclock was rock stable when using Moonlight
Also uncomment the line with config_hdmi_boost and change it's value to 7 (atleast that resolved some issues in my setup).
Also make sure that disable_overscan is uncommented and set to 1.
Reboot your Pi for the changes to take effect.
So I have setup my Pi to a resultion of 1440p using this config:
Ok. This may vary from setup to setup. For the # steps I will tell you what I use, and what you could use.
#0 This can not be done in code ofc. I have the RPi power supply in a smart switch. That switch is controlled by Home Assisant. So with a quick shout to Google Assistant, or manually in Home Assistant I can power on the Raspberry. You could ofcourse just plug it into the socket, or use a extention cord with a on/off button.
#1 In my home almost everything is controlled through Home Assistant. In my script a curl call is done to NodeRed. Which in turn turns on the PC though the wake_on_lan integration. You could use etherwake (apt-get install etherwake, and in the script put etherwake xx:yy:zz:11:22:33 where xx:yy:zz:11:22:33 is the MAC address of your game PC)
#2 Again. In my situation a curl call is done to NodeRed. And a RPC shutdown is send to my PC. To do it directly from the RPi just google "net rpc raspberry pi".
#3 In my situation a timer starts with the call done in #2. After 30 seconds the smart switch is switched off. You could ofcourse remove the power supply from the socket or turn it off through an extention cord with an on/off button.
Now to start the script on boot, edit .bashrc (sudo nano ~/.bashrc) and add this to the end of the file:
After rebooting the RPi, the autorun script runs in the console and starts Moonlight-QT.
Introduction
This tutorial/how-to guides you in creating a Steam Link-like device using a Raspberry PI 4 and Moonlight to have solid in home game streaming at 4K60. There are some optional steps that I have implemented that may or may not be applicable for you, cherry pick the ones that are of interest for you. 😊.Required/Recommended Equipment
- A windows PC with a GeForce GTX GPU and GameStream setup howto
- A Raspberry Pi 4 with a solid power supply, and preferably with a case with active cooling and ofcourse an SD card
- A wired network connection on your Windows PC and the RPi (Wireless does technically work. But just… don’t…)
- A controller (I use a Xbox One Wireless adapter, in the optional steps I will guide you through the setup, if you have an other controller Google will be your friend on how to set that one up)
Prep your Pi
We will be using Raspberry PI OS Lite as our operating system. The reason why we do not use the regular one is that if you want HEVC support in Moonlight (and we do want that) you need to run it from the console.To install the OS you can use fe this guide. Make sure that you enable SSH.
Insert the SD card, and connect the RPi to the TV and the network. Make sure you are using the HDMI-0 port on the Pi4 (closest to USB-C power jack)
After booting the RPi. Run raspi-config configure it to auto login (Option 1 System Options, S5 Boot / Auto Login, B2 Console Autologin) and configure the max GPU memory (Option 4 Performance Options, P2 GPU Memory set it to 256)
Changing config.txt
First we need to overclock your PI. With stock speeds you will have same jittering when streaming at resolutions higher then 1080p.SSH into your PI and edit the /boot/config.txt.
Find the line with
code:
1
2
| #uncomment to overclock the arm. 700 MHz is the default. #arm_freq=800 |
and change it to this:
code:
1
2
3
4
5
| #uncomment to overclock the arm. 700 MHz is the default. #arm_freq=800 over_voltage=6 arm_freq=2147 gpu_freq=750 |
With some cooling and heatsinks this overclock was rock stable when using Moonlight
Also uncomment the line with config_hdmi_boost and change it's value to 7 (atleast that resolved some issues in my setup).
Also make sure that disable_overscan is uncommented and set to 1.
Reboot your Pi for the changes to take effect.
(Optional) set the resolution to 1440p
Yes. I know. This is a guide for 4K streaming. But my game PC can't quite handle this. And to be honest, I do not really see the difference between 4K and 1440p on my TV. But your milage may vary.So I have setup my Pi to a resultion of 1440p using this config:
code:
1
2
3
4
5
6
| hdmi_group=2 hdmi_mode=87 hdmi_cvt=2560 1440 60 3 0 0 1 max_framebuffer_width=2560 max_framebuffer_height=1440 hdmi_pixel_freq_limit=400000000 |
Install Moonlight-Qt
Can't be more simple then this:code:
1
2
| curl -1sLf 'https://dl.cloudsmith.io/public/moonlight-game-streaming/moonlight-qt/setup.deb.sh' | sudo -E bash sudo apt install moonlight-qt |
(Optional) Install the drivers for the Xbox One wireless adapter
The great medusalix has developed a driver for the Xbox One wireless adapter. To install this on your RPi4 follow these steps:code:
1
2
3
4
5
6
7
8
| sudo apt-get install git sudo apt-get install libusb-1.0-0-dev sudo apt-get install cabextract git clone https://github.com/medusalix/xow cd xow make BUILD=RELEASE sudo make install sudo systemctl enable xow |
Automaticlly starting Moonlight on bootup
Create a script called autorun_moonlight.sh in your home directory. And use this codecode:
1
2
3
4
5
6
7
8
9
10
11
| #0 Power on RPi echo "Starting PC" #1 code to start pc echo "Starting Moonlight" moonlight-qt echo "Moonlight exited." echo "Shutting down PC" #2 code to shutdown pc echo "Shutting down RPi" shutdown now #3 power off RPi |
Ok. This may vary from setup to setup. For the # steps I will tell you what I use, and what you could use.
#0 This can not be done in code ofc. I have the RPi power supply in a smart switch. That switch is controlled by Home Assisant. So with a quick shout to Google Assistant, or manually in Home Assistant I can power on the Raspberry. You could ofcourse just plug it into the socket, or use a extention cord with a on/off button.
#1 In my home almost everything is controlled through Home Assistant. In my script a curl call is done to NodeRed. Which in turn turns on the PC though the wake_on_lan integration. You could use etherwake (apt-get install etherwake, and in the script put etherwake xx:yy:zz:11:22:33 where xx:yy:zz:11:22:33 is the MAC address of your game PC)
#2 Again. In my situation a curl call is done to NodeRed. And a RPC shutdown is send to my PC. To do it directly from the RPi just google "net rpc raspberry pi".
#3 In my situation a timer starts with the call done in #2. After 30 seconds the smart switch is switched off. You could ofcourse remove the power supply from the socket or turn it off through an extention cord with an on/off button.
Now to start the script on boot, edit .bashrc (sudo nano ~/.bashrc) and add this to the end of the file:
code:
1
2
3
| if [ $(tty) == /dev/tty1 ]; then
~/autorun_moonlight.sh
fi |
After rebooting the RPi, the autorun script runs in the console and starts Moonlight-QT.