[Unofficial] moonlight-embedded

Good work, if okay with it, I would put your launchscripts in the repo for everyone.

New build and push updates to CoreELEC so CoreELEC repo is updated.

go for it

The sleep interval can probably be decreased from 5 to something like 3 or 2, i hear the audio from the stream cut in way before the fb blank that brings the video in. But, 5 seconds isnt all that long to wait

I freshly installed Luna from the CoreElec Repo (CE 20 beta 1), but there seems to be a library missing, if i want to start moonlight from the CLI:

Kodi-Wohnzimmer:~ # moonlight
moonlight: error while loading shared libraries: libX11.so.6: cannot open shared object file: No such file or directory

Do I need to install something else to get the library?

Whoops.
Made a mistake with the commit where a wrong build flag is set so itā€™s compiled with libX11 even though itā€™s not supported. It will be fixed soonish, but you can use the latest version sent here in this thread.

Does Coreelec need any other components to use moonlight? I used the plug-ins in the post, including several newly released plug-ins. The same problem occurred in the post. The TV screen was always black, but the voice of the game could be heard, and even the game could be controlled by remote control, but there was no picture. I want to ask the owner of the post whether he is still solving the problem, or whether there is a stable executable version?

My test environment is as follows

Machine: X96MAX PLUS S905X3 4G RAM 1G WALN

OS: CoreELEC 19.5-Matrix

Plug in: script. luna-1.2.0-matrix.151.zip

PC: 12400F +16G DDR4 + RTX3070

GeForce Experience 3.26.0.160

I hope the landlord can help solve the problem as soon as possible

CoreELEC 19 version of Luna is not maintained, unfortunately. CoreELEC 20 should work.

Okay, Iā€™ll try coreelec 20 again

I tried

CoreELEC-Amlogic-ng.arm-20.0-Nexus_ nightly_ 20221227-Generic.img.gz

Used by plug-ins

script.luna-1.2.0-matrix.151.zip

The link did not report an error, but the black screen problem still exists. The voice and controller can control the server role, but the client still has a black screen

@smg04
CoreELEC:~/.kodi/addons/script.luna/bin # moonlight stream -app yuzu -mapping /storage/.kodi/addons/script.luna/bin/gamecontrollerdb.txt -1080 -fps 60 -bitrate 15000 -codec h265 -audio hw:0,0
Connecting to 192.168.100.15ā€¦
RTSP port: 48010
Initializing platformā€¦done
Resolving host nameā€¦done
Initializing audio streamā€¦done
Starting RTSP handshakeā€¦Audio port: 48000
Video port: 47998
Control port: 47999
done
Initializing control streamā€¦done
Initializing video streamā€¦done
Initializing input streamā€¦done
Starting control streamā€¦done
codec_init amstream version : 2.0
Starting video streamā€¦Using display thread for amlvideo pipeline
done
Starting audio streamā€¦done
Starting input streamā€¦done
Received first audio packet after 0 ms
Initial audio resync period: 500 milliseconds
Received first video packet after 0 ms
EVIOCGRAB failed with error 16
EVIOCGRAB failed with error 16

@smg04 there are some new commits for amlogic decoder on moonlight-embedded github. Can you compile new one with them?

also i wanna ask, what could mean that error:
ALSA lib /home/portisch/CE/CoreELEC/build.CoreELEC-Amlogic-ng.arm-20/build/alsa-lib-1.2.8/src/pcm/pcm.c:8570:(snd_pcm_recover) underrun occurre

Hi, Iā€™ve been using luna version 144_modded_2 so far as sort of a daily use version using luizkunā€™s launch script. I thought Iā€™d update with the current version from the repo (v.152) to see where itā€™s at but wasnā€™t able to get past a black screen. Adding luizkinā€™s launch scripts to the repo version I was able to start the stream, but with an almost 5sec input lag. Iā€™ve returned to 144mod2 for now but I am experiencing crackling sounds/interference on the audio (both stereo and multichannel surround), any clue as to why this could be happening? Using one of the latest NE releases for amlogic s905x4.

EDIT:

Seems in this specific setting the crackling subsided when I re-enabled the ā€œshow introā€ option. Or more specific, reset the entire settings page to defaults via the GUI button.

Im not sure what is in 152 in the repo as Iā€™ve been using what are essentially custom builds on mine, but

The luizkun script is just a line that blanks the framebuffer and sleeps for a second, repeated 11 times.

I made a launch script that is a cleaner way of doing this that I posted earlier in this thread. It just forks it into the background, waits 5 seconds and then blanks the framebuffer once.

I would be interested to see if just manually blanking the framebuffer clears that blackscreen issue.

echo 1 > /sys/class/graphics/fb0/blank

yeah, i noticed the fix.sh script and added it to the moonlighthelper.py script. The blackscreen indeed seems to clear right up just as in luizkunā€™s script. The thing with the latest 152 though, is that the version of moonlight embedded seems to have like a 3 sec input delay, where the version included with the 144_mod2 has noneā€¦

By the way, ever since I got surround sound working via the 144_mod2 version it totally broke after that one glorious instance and I havenā€™t been able to get it working ever since. No clue whatā€™s changed.

Hello everyone and happy new year!

This project has been quite an interesting ride for me and I would like to summarize what has happened with the project and how it will progress (at least from my side).

It started as an experiment where I wanted to try streaming games to the tv but since Android on the box was terrible I decided to move to CoreELEC. moonlight was the only option that already had some development for Amlogic boxes but it had been broken for a while. Finding a few patches online and researching Kodi and other source codes I managed to compile something that showed output on the screen.

Since then a lot has changed. Iā€™ve learned more about the system and how different components interact but one thing stayed the same: after you send the frame to the hardware decoder, I have no idea what black magic happens in order to get that frame displayed on screen.

So it has mostly been trial and error for this to work. Iā€™ve tried to read the kernel sources but it is too complex for me to understand what it does. Iā€™ve also managed to get some help along the way to help me figure it all out and make the experience better. Big thanks to all the testers and contributors that helped shape this project into something more than just an experiment! The latest version should be the version closest to ā€œthe Kodi wayā€. But it seems like it has caused more problems.

Since my first solution the way of sending frames to the decoder had changed a lot. And the sources from CoreELEC had changed too. Itā€™s all nonstandard and not documented which is why the original was broken too. It seems though that the ā€œnew eraā€ is coming and it might be the light at the end of the tunnel that makes the decoder comply with Linux standards.

Please do understand that itā€™s not been easy to maintain this as each chipset and each box has typically behaved differently to the exact same code. As you also update CoreELEC the code no longer works as it used to which is also the reason why blackscreen occursā€¦ Itā€™s not a CoreELEC problem but this has always been a trial and error experiment and without proper documentation itā€™s hard to believe it will ever work like intended.

From a more technical standpoint, Iā€™ll forever be amazed at how this code works. I would always expect that sending frames into the decoder would display them as soon as thatā€™s possible but that has not been the case. I believe that has something to do with Amlogicā€™s vsync handling and that sometimes you just get unlucky and hit the worst timing where you have to wait for a frame to finish in order to display the next one and it somehow breaks into a huge delayā€¦

As for the future of this projectā€¦ Itā€™s been difficult to maintain, thatā€™s for sure. Right now I am sitting with a broken box. Something died, it only works sometimes and it feels like its unsafe to run it. I canā€™t test most of the stuff now and it might just be that I will have to abandon this. I will do my best to try and compile multiple versions of the project with different approaches to the decoder. These can be combined with amazing launch scripts some of you have made that bypass the issues that are extremely unpredictable (like the black screen). But since I donā€™t have a box I am unable to test it and thatā€™s currently holding me back from updates. If Amlogic-ne gets the standards right, we might just be able to build moonlight-qt (thatā€™s currently the best supported moonlight project with GUI). If not, I am not sure what to do next. I guess weā€™ll just have to see.

Thank you all, itā€™s been an interesting year and I hope the future is bright for this project.
Also, thank you CoreELEC Team! For everything, big support and amazing community! Literally turned my box from garbage to a usable daily driver. At least until it broke :smile:

Awesome effort! Will keep testing stuff on the NE nightlies and share any progress until I fry my box too :fire:

Big thanks @smg04 for your work.

For me, coreelec as for you is the daily driver and your work on moonlight addon is the great additional feature i love to use with my childs :slight_smile: I have those strange problems you mention (micro stutters etc.). But from the start of your project the fluency is so much better.

I wanted to ask you about moonlight-gt but your reply was faster :slight_smile:

Iam also curious new era coreelec, cause it base on kernel 5.4 which is need for new xow->xone and xpad, and will also give better handling with gamepads :slight_smile:

I would love to see moonlight-gt addon on coreelec in the future :slight_smile:
Last days Iam looking around for the box supported by new era coreelec.

As for the future of this projectā€¦ Itā€™s been difficult to maintain, thatā€™s for sure. Right now I am sitting with a broken box. Something died, it only works sometimes and it feels like its unsafe to run it. I canā€™t test most of the stuff now and it might just be that I will have to abandon this. I will do my best to try and compile multiple versions of the project with different approaches to the decoder. These can be combined with amazing launch scripts some of you have made that bypass the issues that are extremely unpredictable (like the black screen). But since I donā€™t have a box I am unable to test it and thatā€™s currently holding me back from updates

Because this is a project I want to be able to continue to use into the future. If all you need to continue onwards is a new amlogic board, I can get you a replacement. If you dont want to continue to develop the coreelec version of moonlight, I would ask that you open whatever repositories you have to me and give me a quick rundown of whatever buildscripts & practices you have and I will try to continue it

let me know either way

Anyone who wants to try and maintain this:

GitHub - CoreELEC/CoreELEC: A lightweight OS for KODI is the source code of the CoreELEC project toolchain. Look up on resources on the Discourse on how to set it up.

Once you set it up, you would run scripts/create_addon script.luna to start building the luna addon. This will build all the dependencies (including moonlight-embedded) and give you a Kodi addon ZIP file in the target/addons folder. You would then proceed to install it in Kodi for testing.

The makefiles for moonlight packages are located in packages/addons/addon-depends for dependencies and packages/addons/script/luna for the Luna addon.

All the source code is already on GitHub. You can check it out here:

moonlight-embedded: GitHub - TheChoconut/moonlight-embedded: Gamestream client for embedded systems
luna: GitHub - TheChoconut/Luna: Luna Script for Kodi

You can send me a message if you need help or more information.

2 Likes

:expressionless: :expressionless: :expressionless: < Mfw Iā€™ve been struggling to get 7.1 channel mappings right because front left and right were swapped, having dabbled with alsa mappings and pulse overlays and it turns out Iā€™ve been listening to reversed stereo for half a year now because I swapped the connections to my AVRā€¦

After looking around at the depends and makefiles and repos everything, I seem to have a good grasp on how this all works

The only area I dont really understand is the coreelec addon repos. How does that work?