Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full Install Guide For Raspi 4 Bookworm [HDMI Audio/Wifi/XBox Bluetooth Controller/Autostart] #1484

Open
snickerweb opened this issue Dec 14, 2024 · 5 comments

Comments

@snickerweb
Copy link

snickerweb commented Dec 14, 2024

[14.12.2024]
Hi, I have gathered some information from the internet. Perhaps this will save some people from having to search as much.

  1. Use Raspberry Pi Imager:
    • Install Raspberry Pi OS 64-bit Lite (Bookworm) on an SD card.
    • Preconfigure the following settings:
      • Hostname
      • User
      • WiFi
      • Language
      • SSH with password

Updating the Raspberry Pi

  1. Connect via SSH: (Change Hostname)
    ssh {Hostname}
  2. Update and Upgrade Packages:
    sudo apt update
    sudo apt upgrade

Install Moonlight-Qt

  1. Add Moonlight-Qt Repository and Install:
    curl -1sLf 'https://dl.cloudsmith.io/public/moonlight-game-streaming/moonlight-qt/setup.deb.sh' | distro=raspbian codename=$(lsb_release -cs) sudo -E bash
    sudo apt install moonlight-qt

Optional Configurations

HDMI Audio Configuration (use the HDMI Port near the USB-C Power)

  1. Install PulseAudio:
    sudo apt install pulseaudio
  2. Configure Audio Settings:
    sudo raspi-config
    • Navigate to `6 Advanced Options
    • `
  • Select A7 Audio Config
    • Choose 1 PulseAudio
    • Then go to 1 System Options
      • Select S2 Audio
        • Choose 1 vc4-hdmi-0

WiFi 5GHz only

  1. Edit Network Configuration:

    sudo nano /etc/NetworkManager/system-connections/preconfigured.nmconnection
    • Under [wifi], add:
      band=a
      
  2. Save and Exit:

    • Press <CTRL+C>, then <Y>, and <Enter> to save.
  3. Moonlight settings

    • max. 1080p 60Hz
    • Video Decoder: Force Hardware Decoding
    • Video Codec: HEVC (H.265)

Bluetooth Controller Setup

  1. Connect Bluetooth Controller:
    sudo bluetoothctl
    • Enter the following commands: (change MAC Address from Controller)
      agent on
      default-agent   
      scan on
      connect {MAC Address from Controller}
      trust {MAC Address from Controller}
      quit

Autostart Moonlight-Qt

  1. Configure Autostart Settings:

    sudo raspi-config
    • Navigate to 1 System Options
      • Select S5 Boot
        • Choose B2 Console Autologin
  2. Create a Systemd Service for Moonlight:

    sudo nano /etc/systemd/system/moonlight.service
  3. Add the Following Service Configuration: (change the Username)

    [Unit]
    Description=Moonlight Game Streaming Service
    After=network-online.target pulseaudio.service
    Wants=pulseaudio.service
    
    [Service]
    Type=simple
    Environment="PULSE_SERVER=unix:/run/user/1000/pulse/native"
    ExecStart=moonlight-qt
    Restart=on-failure
    User={Username}
    
    [Install]
    WantedBy=multi-user.target
    
  4. Save and Exit:

    • Press <CTRL+C>, then <Y>, and <Enter> to save.
  5. Enable and Start the Service:

    sudo systemctl enable moonlight.service
    sudo systemctl start moonlight.service

reboot and have fun!!!

@snickerweb snickerweb changed the title Full Install Guide For Raspi 4 Bookworm [HDMI Audio/Wifi/Bluetooth Controller/Autostart] Full Install Guide For Raspi 4 Bookworm [HDMI Audio/Wifi/XBox Bluetooth Controller/Autostart] Dec 14, 2024
@daniele-athome
Copy link

Hi, thanks for the guide. I'm trying to make Moonlight to work on Debian Bookworm but I'm having a weird issue (see #1480). Can I ask you if and what did you modify in /boot/firmware/config.txt and /boot/firmware/cmdline.txt? What's the resolution of your monitor attached to the pi? Thanks!

@snickerweb
Copy link
Author

snickerweb commented Dec 16, 2024

Hi Daniele. Thanks to reading my guide. Change nothing in the config.txt. Out of the box is perfect for moonlight. Only the commands from the Guide is enough. Use wifi 5ghz only with 720p 30 Hz in the Moonlight settings.

edit: with HEVC/Hardware Encoding you can use higher resolutions

@x1000knives
Copy link

Thanks for this guide! I was following a few other guides online, but this one covered everything needed with the least amount of hiccups, besides a few tweaks to get HDMI audio to work.

A few questions,

  1. My Moonlight menu GUI is extremely small. Is there any way to adjust this?

  2. Is there any possibility of getting 4k@60Hz to work? 1080p and 1440p + HDR both stream flawlessly using HEVC (more smooth than Moonlight-android on my FireTV it seems), but 4K streaming is very jittery.

I'm on a Raspberry Pi 4 running Bookwork OS Lite, on a wired LAN. (my Sunshine host is on a wireless 802.11ax 5Ghz connection.). I'm not expecting much from an older device like this, but I'm wondering if 4K is possible with some config changes, given the near-perfect streaming I get with 1440p@60Hz.

@daniele-athome
Copy link

My Moonlight menu GUI is extremely small. Is there any way to adjust this?

On 1080p you will need these environment variables:

export QT_SCALE_FACTOR=0.9
export QT_QPA_EGLFS_PHYSICAL_WIDTH=$( awk "BEGIN { print int($QT_SCALE_FACTOR*437)}" )
export QT_QPA_EGLFS_PHYSICAL_HEIGHT=$( awk "BEGIN { print int($QT_SCALE_FACTOR*250)}" )

These were extracted from the source code of a Kodi addon I use on my system: https://github.com/veldenb/plugin.program.moonlight-qt/blob/main/resources/bin/bootstrap_moonlight-qt.sh

Is there any possibility of getting 4k@60Hz to work?

I don't think the Pi 4 can handle Moonlight at 4k@60Hz. You could try reducing the bitrate.

@Dregu
Copy link

Dregu commented Dec 20, 2024

Here's what I'm doing on RPi 3B+ for embedded and RPi 4B for QT eglfs, both on RaspiOS bookworm. Includes some shenanigans for autostarting the systemd service via GPIO when the TV is powered on. Not really a guide, just a dump of my setup. https://gist.github.com/Dregu/1163dddcd879d0ed390707a2b3dead30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants