Moonlight Game Streaming (Docker)

  • I've been messing around with getting moonlight-embedded running in a docker container on LibreELEC and thought I'd share the current state. This allows you to stream games from a PC to your HTPC device (Raspberry Pi 3B+ in my case) through the NVidia GeForce gamestream protocol. It currently supports only audio/video out and works pretty well at 1080p/60fps going from my gaming PC to my TV in another room over wifi. I have not tried to get controllers working as I just connect my controller to my PC via bluetooth.

    Files/Readme:

    GitHub - clarkemw/moonlight-embedded-launcher: Launcher for moonlight-embedded on LibreELEC Raspberry Pi systems

    Prerequisites

    • Raspberry Pi device with LibreELEC installed, connected to local network via ethernet (preferred) or wifi
    • Gaming PC with Steam and Nvidia GeForce Experience installed, connected to local network via ethernet (preferred) or wifi
    • Basic familiarity with ssh and terminal for installation

    Instructions:

    1. Enable Nvidia Gamestream on your gaming PC: GeForce Experience/Settings/Shield/Gamestream (move slider to right)

    2. Enable Avahi in LibreELEC: Kodi/Add-ons/LibreELEC Configuration/Services/Enable Avahi

    3. Enable Docker in LibreELEC: Kodi/Add-ons/Install from repository/LibreELEC Add-ons/Services/Docker

    4. SSH into your LibreELEC device, download/extract the latest release of this repository to your LibreELEC device and run install.sh

    Code
    wget https://github.com/clarkemw/moonlight-embedded-launcher/archive/v0.4/moonlight-embedded-launcher-0.4.zip
    unzip moonlight-embedded-launcher-0.4.zip
    cd moonlight-embedded-launcher-0.4
    bash ./install.sh

    5. The installer script will guide you through the process. The only user interaction required is during the pairing process. The LibreELEC terminal will give you a 4 digit code, and you will see a pop-up on your gaming PC to enter the code.

    Code
    Searching for server...
    Connect to 192.168.0.101...
    Generating certificate...done
    Please enter the following PIN on the target PC: 4321

    6. Install the launcher add-on from the script.moonlight-embedded-launcher.zip file: Kodi/Add-ons/Install from zip file/Select script.moonlight-embedded-launcher.zip

    7. Launch moonlight-embedded from within Kodi and enjoy your game streaming experience: Kodi/Add-ons/Game add-ons/Moonlight Embedded Launcher

    8. Exit Steam (power icon) to stop streaming/re-open Kodi

    Current to-do list:

    • Add/test controller support
    • Automated installation process instead of install.sh
    • General cleanup (this is my first ever docker image) and potentially build moonlight-embedded from source to reduce image size

    Edited 8 times, last by mcs5280: v4 release (February 21, 2021 at 1:08 AM).

  • Revamped this a bit with a simple Kodi launcher add-on and installer script to build/configure the docker image. The first post has been updated to reflect the current state.

  • This is cool! Much better than moonlight on the FireTV, I think I can resell my single-purpose Shield now.

    Currently I've just got a controller RF stick plugged into the host computer, but I also have a controller plugged into kodi. Is there a way to do mouse emulation from kodi? Additionally, it there a way to exit the game in-game or from the launcher in Kodi? That's pretty critical, as GFE gets picky about starting another game without closing down the first one.

  • This is cool! Much better than moonlight on the FireTV, I think I can resell my single-purpose Shield now.

    Currently I've just got a controller RF stick plugged into the host computer, but I also have a controller plugged into kodi. Is there a way to do mouse emulation from kodi? Additionally, it there a way to exit the game in-game or from the launcher in Kodi? That's pretty critical, as GFE gets picky about starting another game without closing down the first one.

    I'll confess I haven't experimented much with controllers connected to the Kodi device but I'd like to expand that capability in the future. I just tried plugging in a USB mouse to the Kodi device and that seemed to work inside moonlight...but that's a fairly basic input device. What kind of controller are you trying to use? Is it wired or wireless? You can check this file to see if its got a registered mapping for moonlight:

    moonlight-embedded/gamecontrollerdb.txt at master · irtimmer/moonlight-embedded · GitHub

    As far as exiting goes I've had the cleanest experience using games that I launch from Steam. Once you exit the game via it's internal menus, the Steam window will re-appear and you can use your controller to select/press the power icon in the upper right corner. This will bring up a dialog asking if you want to end the Gamestream session. Once you hit ok to that it should close out of GFE completely and reopen the Kodi gui.

    If you aren't launching via Steam you can try one of the following commands from a keyboard/controller that is connected to the Kodi device:

    Code
    Use Ctrl+Alt+Shift+Q or Play+Back+LeftShoulder+RightShoulder to exit streaming session
  • Hi, thanks for creating this, I installed it just now. I notice the link you posted (moonlight-embedded-launcher-0.4.zip) was contained v0.3 inside the folder. I found v0.4 on your github so installed from there.

    On the initial install of my LibreELEC, I had to adjust overscan to fit into my TV screen. But when I launch Moonlight, the streaming display doesn't seem to respect that and the edges of screen stretch beyond it. I am streaming my desktop. Also when I quit using Ctrl+Alt+Shift+Q, it doesn't seem to terminate the connection on my computer (meaning I do not get audio on the host back). I'm not sure if this is related to an issue with your code or not. I'm going to try the moonlight embedded on OSMC next. Thanks.

  • Kodi overscan settings only change the output of Kodi itself so when you run this add-on Kodi is stopped and the add-on runs from the framebuffer which has no knowledge of them (or mechanism to recreate them) then when you exit Kodi restarts and the overscan settings are reapplied. The solution to overscan is to set the TV to "just scan" or similar so you don't need overscan, it's a hack. You might need to change HDMI outputs as some TVs don't support it on all.

  • Hi, thanks for creating this, I installed it just now. I notice the link you posted (moonlight-embedded-launcher-0.4.zip) was contained v0.3 inside the folder. I found v0.4 on your github so installed from there.

    On the initial install of my LibreELEC, I had to adjust overscan to fit into my TV screen. But when I launch Moonlight, the streaming display doesn't seem to respect that and the edges of screen stretch beyond it. I am streaming my desktop. Also when I quit using Ctrl+Alt+Shift+Q, it doesn't seem to terminate the connection on my computer (meaning I do not get audio on the host back). I'm not sure if this is related to an issue with your code or not. I'm going to try the moonlight embedded on OSMC next. Thanks.

    Oops fixed the incorrect link in the first post, thanks for pointing that out. I think the previous poster is correct, you probably need to change your TV HDMI settings to correct the overscan issue. Regarding streaming your desktop I found the -quitappafter flag that should tell the host to exit streaming if you quit on the LibreELEC device. Can you run the following command and let me know if it resolves the exit issue (seemed to work for me but just want to double check)? I'll get this incorporated into the next release.

    Code
    sed -i 's|moonlight stream|moonlight stream -quitappafter|' ~/.kodi/addons/script.moonlight-embedded-launcher/bin/launch_moonlight.sh