[Unofficial] moonlight-embedded

Source code with amlogic decoder changes: https://github.com/TheChoconut/moonlight-embedded

Experimental moonlight-embedded available

Temp build for testing available on Dropbox. Download build from link below:

How-to:
SSH into your box.
Extract moonlight.tar.gz on /storage.

Manual (SSH) way

systemctl stop kodi
cd /storage/moonlight
LD_LIBRARY_PATH=/storage/moonlight ./moonlight pair <your pc ip>
echo 0 > /sys/class/video/disable_video
LD_LIBRARY_PATH=/storage/moonlight ./moonlight stream <settings>
After you are done and want to get back into kodi, use systemctl start kodi.

OR (Kodi way)

  1. Install script.luna.zip in Kodi.
  2. Start Luna launcher, add host by manually entering IP and pairing with code.
  3. Go to your host and start a session.
  4. Use Ctrl+Alt+Shift+Q or Play+Back+LeftShoulder+RightShoulder (controller) to exit streaming session.

This method works great on Mecool KI Pro and it won’t kill Kodi so you can continue right away. It only takes 2-3 seconds to get back to Kodi!

2 Likes

Gratz for the effort.
And bump for visibility.
Myself can’t help on development (lack of skills),
but a moonlight (and/or steam) client is more than welcome.

I did a build of moonlight a little while ago, didn’t have to use any outside stuff or add anything. I think just one network related package needed to be bumped.

using the osmc stuff can also cause issues with playback. since there are differences between the version of the library used by each project.

Few questions.

What compiler did you use for compiling moonlight?
Where could I locate libopus, libenet on CoreELEC?
What version of libamcodec were you using for compilation?

When I use libamcodec from CoreELEC, moonlight won’t accept libmoonlight-aml.so because /usr/lib/libamcodec.so: undefined symbol: audio_decode_set_pre_mute.
My first assumption would be missing libavutils or libamadec, but the CoreELEC build of libamcodec doesn’t require those. When I use OSMC’s version, it works just fine.

I just created a new moonlight package.

There are packages for both opus and enet in the CoreELEC repo.

You may need to update the enet package however.

diff --git a/packages/addons/addon-depends/enet/package.mk b/packages/addons/addon-depends/
enet/package.mk
index f056918478..b7687bab39 100644
--- a/packages/addons/addon-depends/enet/package.mk
+++ b/packages/addons/addon-depends/enet/package.mk
@@ -2,11 +2,11 @@
 # Copyright (C) 2016-present Team LibreELEC (https://libreelec.tv)
 
 PKG_NAME="enet"
-PKG_VERSION="e33ca1d"
-PKG_SHA256="0ba5547de2c4c7fc79d367179a9bc92a7ac27e9258dd50fb277cd8761afaf9b0"
+PKG_VERSION="eda26a26d913a1e86f44fae725049c97dc1ce5a8"
+PKG_SHA256=""
 PKG_LICENSE=""
-PKG_SITE="https://github.com/cgutman/enet/"
-PKG_URL="https://github.com/cgutman/enet/archive/$PKG_VERSION.tar.gz"
+PKG_SITE="https://github.com/lsalzman/enet/"
+PKG_URL="https://github.com/lsalzman/enet/archive/$PKG_VERSION.tar.gz"
 PKG_DEPENDS_TARGET="toolchain"
 PKG_LONGDESC="A network communication layer on top of UDP (User Datagram Protocol)."
 PKG_TOOLCHAIN="autotools"

For now I consider these two packages unimportant, my main concern is libamcodec as this library is managing video output and how moonlight communicates to aml video drivers. I’m not sure how this one is getting built, I only saw CoreELEC is pulling it from your own sources but it originates from amlogic sites. How exactly are you getting the source code for libamlogic? And does that library work just fine or not? In my case it doesn’t want to load it at all because of missing symbols… Does it work for you?

Sending good news!

I have checked out some issues of moonlight-embedded on github and found the solution for constant codec failures that kept disabling the video output and making the stream stutter. Applied the fixes from sdl decoder to amlogic and now it doesn’t drop any frames!

I have very good connection and I almost cannot experience frame drops. I am still not sure how good my coding skills are since this was my first attempt at doing this. Even though I do know programming, I never did anything close to this so I would need someone to test with wifi connections or something that can drop frames.

I will drop footage on Dropbox and more details on how to grab experimental version tmrw.
1080p60 was working on both H264 and H265 codec.

2 Likes

I have published experimental binaries of moonlight-embedded on Dropbox, it would be nice if you can checkout with poor wifi connection to see how the decoder performs (or doesn’t work at all).

I still wanna know if I could get libopus and libenet from /usr/lib? Where are these located on a CoreELEC installation? Also could you try updating libamcodec to osmc version? Or if not, I’d like to know what’s the build process for the current one. I only saw you are downloading prebuilt sources from your own site.

Thank you for your help!

Seems unfortunate that there are no testers yet. I don’t think its so dangerous to run this.
Anyways, I have now added a script.luna addon to Dropbox, which is modified from the original to work with this experimental build. I did not build libraries so it cannot find hosts on its own, you have to write the host IP address and pair with code. After that it should be working fine.

I have also tried to remove the limitation of modifying LD_LIBRARY_PATH but unfortunately it has to be modified to load the modules because it always looks at /usr/lib before anything else and it always loads libamcodec.so from there instead of using the one I prepared which works fine.
The only solution is to update the libamcodec to a version that will work w/ moonlight or to remove it from /usr/lib or somehow find a linker workaround to not search in /usr/lib.

Best fix would be to implement moonlight back in CoreELEC repo and make it an optional addon which would simplify everything. With moonlight we could also add luna launcher so its easier to load games directly from Kodi. Before that happens, this binary has to be tested on multiple devices.

1 Like

Will try this the next days with a khadas vim and report back.

Would be nice if this becomes a real addon

Installed it via Luna, but unfortunately I get an error if I want to change audio settings and nothing happens when I want to add a host.
Is there a log file anywhere I can give you?

Actually not sure about Luna. Could you try doing it manually, non-luna way?
I am still trying to understand the code structure of Luna.

If you are able to, provide kodi.log with debug logging enabled and click on controller settings, audio settings and add host. With that I can see what does and what doesn’t.

About | FAQ | Terms of Service | Privacy Policy | Legal Notice