[Unofficial] moonlight-embedded

Today i start testing moonlight.
All fine with the stream.

But i have no audio :frowning: How can i fix this?
And a question. Can you add higher resolution like 1440p and/or 2160p :slight_smile:

Hi everyone!

Luna 0.6.6~alpha uploadedā€¦ To assist with issues like ā€˜sound not workingā€™ (for some) during stream; Iā€™ve included the ability to be able to select your audio device from Lunaā€™s settings.

Working stream but no sound? Try the following: (New Users: Always test default settings first)

Just goto Luna > ā€˜Settingsā€™ > ā€˜Streamingā€™ > ā€˜Customize Audio Settingsā€™ (toggle it on). Choose ā€˜- Select Audio Deviceā€™ and select your device from the list.
Select ā€˜Okā€™ to exit ā€˜Settingsā€™ and try the stream againā€¦ If youā€™re unable to make a logical guess on which device to select (based upon their name/content) then try each setting.

Please note: Changing the above setting can result in a failed streamā€¦ If this occurs, then try the next listed audio device (until one works). If youā€™re still unsuccessful after exhausting the list. Please report back here with your moonlight.log. Thanks.

Quick tip:

To disconnect an active streaming session itā€™s:

Keyboard: Ctrl+Alt+Shift+Q
Xbox 360 Controller: Start + Back + LB + RB
Dualshock Controller: Start + Select + L1 + R1

For your information:

Failed sessions will automatically return to CoreElecā€™s interface with a retry prompt waiting. If at any point it does not, then reboot via SSH and upload your generated logfile from: /storage/moonlight/moonlight.log into a post here, tagging myself or @smg04 ā€¦

Log file location: /storage/moonlight/moonlight.log - Need help? Weā€™ll need thisā€¦

Notice: The in-app update service seems to be broken for the time beingā€¦ Please update manually until I get this fixed.

Github Release: https://github.com/stickman89/Luna/releases/tag/v0.6.6-alpha
Direct Download: https://github.com/stickman89/Luna/releases/download/v0.6.6-alpha/script.luna-0.6.6-alpha.zip

Changelog:

*     ā€˜Framerateā€™ max is now 120
*     ā€˜Enable Surround Soundā€™ toggle added
*     ā€˜Audio Backendā€™ Selector added
*     ā€˜Customize Audio Settingsā€™ to pass specific audio card id and device id to moonlight.
*     ā€˜Codec Selectionā€™ toggle
*     ā€˜Resolutionā€™ max is now 4k
*     ā€˜Bitrateā€™ max is now 100Mbps
*     ā€˜Enable GFE Graphics Optimizationsā€™ toggle added
*     ā€˜Enable Remote Connection Optimizationsā€™ toggle added
*     ā€˜Play Audio on Hostā€™ toggle added
*     ā€˜Scraperā€™ section renamed to ā€˜Helperā€™
*     ā€˜Setup Moonlight PKG (internet connection required)ā€™ added to ā€˜Helperā€™. Prompts also added to setup Moonlight on ā€˜first runā€™.
*     Fixed ā€˜Stream failed to initialiseā€™ prompts and recovery not occurring (due to aml_decoder.stats formatting changes)
*     Load directly from configuration file.

@sunnyfunny, @RunAway, @Adam86 and everyone else - Test this version, taking note on my advice on sound related issues. Also, higher fps/resolutions/bitrate settings have been added. See changelog.

Best Regards,

stickman89

1 Like

Incremental Update: Version: v0.6.6.1-alpha

Resolutions above 1080p require the ā€˜unsupportedā€™ flag for moonlight-embedded.

  • Added ā€˜Enable Unsupported Resolutionsā€™ toggle to Luna > Settings > Advancedā€¦ Users wanting to use resolutions higher than 1080p will need to toggle this onā€¦ It is off by default.
  • Fixed ā€˜Custom Resolutionā€™ values not writing to config file.

Github Release: https://github.com/stickman89/Luna/releases/tag/v0.6.6.1-alpha
Direct Download: https://github.com/stickman89/Luna/releases/download/v0.6.6.1-alpha/script.luna-0.6.6.1-alpha.zip

Please do not report that resolutions above 1080p are not working or custom resolution values are not respected on v0.6.6-alpha and belowā€¦ This issue is known and fixed in v0.6.6.1-alpha. Simply update manually and set the toggle Luna > Settings > Advanced > ā€˜Enable Unsupported Resolutionsā€™ to on.

Please be aware: Higher resolutions may cause a failed stream. Youā€™ll either be kicked back to Kodi, or you can become stuck on a black screen. Usually the latter is true if ā€˜Video decode buffer too smallā€™ is seen in your moonlight.log. Otherwise ensure ā€˜Enable Unsupported Resolutionsā€™ is toggled on for above 1080p resolutions, or if your were troubleshooting ā€˜no audioā€™ issues; then try a different audio device. ā€˜Stream initialisation failedā€™ prompts are normally caused by those two issues. If despite that, streams are still failing; please provide us your moonlight.log. Providing logs help us troubleshoot your issue(s), and stabilises development.

This issue stems from the original moonlight-embedded sources, fortunately it is something @smg04 can correct, and is not Luna related. @smg04 is aware of this, and will hopefully roll out a fix this weekend.

Enjoy.

stickman89

Thanks for the updateā€¦ many new featuresā€¦ but UHD not working

[INFO] Logging file has been enabled!
[DEBUG] Moonlight Embedded 2.4.10 (AML;PI;MMAL;ALSA;PULSE;EMBEDDED)
[INFO] Connect to 192.168.1.23ā€¦
[DEBUG] NVIDIA GeForce RTX 2070 SUPER, GFE 3.20.5.70 (gs_04_24_28968357, 7.1.424.0)
[DEBUG] Using platform AMLogic VPU
[INFO] Loading mappingfile gamecontrollerdb.txt
[INFO] Detected Microsoft X-Box 360 pad (030000005e0400008e02000010010000) on /dev/input/event1 as X360 Controller
[ERR] No mapping available for meson-ir (190000006d65736f6e2d697200000000) on /dev/input/event2
[ERR] No mapping available for cec_input (100000008e1b0000ec0c000001000000) on /dev/input/event0
[DEBUG] Stream 3840 x 2160, 30 fps, 70000 kbps
[WARN] Dropped 1 frames!
[ERR] Video decode buffer too small, 255931 < 122880

Surround Sound also not working for me :frowning:
Higher Bitrate result in too small decode buffer

@sunnyfunny - I had a feeling some were going to hit that error. Higher resolutions require a larger video decode buffer allocation. @smg04 is aware but is not available until the weekend. It requires a patch to Moonlight, and so is not Luna related. For the time being trial out lower than 4k resolutions until we get an updated Moonlight package from @smg04.

When @smg04 confirms a fix is rolled out; youā€™ll be able to update Moonlight via Luna > Settings > Helper > Setup Moonlight PKG

Thank you for your ā€˜Surround Soundā€™ report. Iā€™ll be sure to look into this. Soā€¦ Was sound working, just in ā€˜Stereoā€™, when you had a successful stream? Asking because thatā€™s good progress from no audio! I assume you used the ā€˜Customise Audio Settingsā€™ option? ā€¦I was waiting to hear success stories with that.

@RunAway - What happened to your report? I saw that you had ā€˜Stream initialisation failedā€™? Is it working now?

Best Regards,

Stickman89

Hello man, how did you see that?! Ahah

Anyway I have unfortunately have done few tests till now, hereā€™s a quick summary, first of all let me introduce you my setup:

Intel Core i5 8400
GTX1070ti
16GB RAM
1Gbps Ethernet with 2048 package size as transmit buffer and 2048 receive buffer on Luna

After different tries and different combinations I can say that:

  1. Resolutions higher than 1080p doesnā€™t work, they look bad and also thereā€™s a lot of stuttering;
  2. Bitrates higher than 50mbps work only if you set the frame rate to 120fps
  3. H265 responsiveness is way better than H264 as I expected

Frame rate is really important since for an optimal stream quality you need to set the same Luna framerate on your game!

For example: I tried to play Rocket League and PES 2021 but they were stuttering like hell because my monitor is 144hz, in the meanwhile on Luna I play 60fps at 50mbps or 120fps (still capped to 60 because of my TV) at 80mbps. So the only way to reduce the stutter is to cap your game frame rate through the game itself or with an external program (for example, I use RivaTuner). After I have locked my fps through the game or the program the stuttering is almost disappeared and the input lag is very very low. At the moment Iā€™m finding more responsiveness and less stuttering on 60fps at 50mbps instead of 120fps at 80mbps.

For the audio Iā€™m not finding any issue but I still didnā€™t test the Sorround. Hope this help you, if you need anything else just tell me!

@RunAway - Iā€™ve got quick eyesā€¦ Either that or my ISP connection couldnā€™t keep up with your speedy deletion. Which, wouldnā€™t suprise me. Awful here.

Thatā€™s great information. Resolutions above 1080p donā€™t work? Stream failed or just returns to kodi with no prompt? If the latter is true, are you running v0.6.6.1-alpha?

Otherwise if it just looks bad with stuttering, then the stream worked but something else is at play.

Are you connected via ethernet or wireless?

If ethernetā€¦ Then at what speed can your network controller claim to achieve? 100Mbps or 1Gbps? Check the specsheet for your Android Box

If wirelessā€¦ Then what band does your Android Box support? 2.4GHz or 5GHz?
Check the specsheet for your Android Box.

Obviously to satisfy the optimal other from either of the above; your router would also need to support 1Gbps with appropriate cabling for device and host, or just 5GHz band support for wireless.

Also to note. Try changing CoreElec Home > Settings > CoreELEC > Hardware > CPU Governor to performance.
Does this change moonlight performance for you?

Also curiousā€¦ Are you running the CoreElec stable build or CoreElec Nightly NG build?.. CoreElec stable builds run far better with Moonlight-embedded. NG builds arenā€™t quite as performant, despite the newer kernel versionā€¦

Check via: CoreElec Home > Settings > CoreELEC > About
Let me know what ā€˜Version:ā€™ reportsā€¦

I wasnā€™t able to put in any testing for fps above 60. I donā€™t have the appropriate monitor/tv for that. The general principle is, the higher the resolution/bitrate/fps (whether individually or in combination) the more strain on the clients HW and supporting libraries, and your network infrastructure.

Probably best to check what CoreElec build youā€™re running first. If you find youā€™re running a nightly NG build; then try out the latest CoreElec stable build (9.2.5 as of writing)ā€¦ Afterwards eliminate the possibility of a network bottleneck.

I am not ruling out the posibility that you/we might have exceeded the capabilities of your/our Android Boxā€™s SoC by enabling/including such high settings; it can only encode/decode so much before hitting a HW limitationā€¦ Weā€™re not quite magicians yetā€¦ Sorry :smiley:

What box do you have? Do you know what SoC (system on a chip) it uses? S905X? S905D? S905W?..

Best Regards,

stickman89

Evening all,

Iā€™ve updated the components on my setup and I went through each sound device and whilst one did show as 5.1 LPCM on my receiver, when I did the sound test within Windows I just basically got the same sound through all my speakers.

Sorry Iā€™ve not got logs to post, Iā€™ll try and do it tomorrow, just replying on my phone here, its quite hard as Iā€™ve got a little toddler who takes up most my free time. Donā€™t know why Iā€™ve got an idea in my head that Iā€™m going to be able to play games :smiley:

@Adam86

I havenā€™t got a surround setup for my TV to test this feature on. Iā€™m trying to figure out where the issue stems from. Is your CoreElec device configured for the appropriate channel count for your setup at: CoreElec/Kodi Home > Settings > System > Audio > Number of channels?

I was going to suggest people check what windows is setting the channel count to at Sound Control Panel > Playback tab > Nvidia HDMI Out (right click) > Configure Speakersā€¦ during a stream. Then set to your surround sound configuration. I think the default is actually Stereo. Otherwise Geforce Experience might have actually broke surround sound for moonlight-embedded ages ago with an update. Iā€™ve read a few mentions reporting such a thing. I hope this isnā€™t true though.

Yeah my number of channels is set to 5.1 in CoreELEC but passthrough of certain formats enabled. Tried tinkering with these but it made no difference.

From experience with the Moonlight client on Android and Windows, if you set this to surround sound, it does alter the sound device acorddingly in Windows. You are correct that there was a bug in GeForce Experience at one time, but this was definitely fixed and works for me on an old S905 that I use stock Android on.

Sorry I missed some important informations:

  • Iā€™m completely wired connected. My PC, my modem and my router (theyā€™re both fritzbox) have a gigabit port instead my Nexbox A95X (S905X) should have a 100mbps ethernet port.

  • My governon is already set on performance mode but I still havenā€™t tried the ondemand one

  • Iā€™m running CE 9.2.5 stable version

Anyway yes, I canā€™t run resolutions above 1080p, they start but they look absolutely worse than 1080 and thereā€™s a lot of stuttering. At the same time, 1080p above 50mbps can run only if I set fps to 120, otherwise the streaming would be completely black with ā€œstream initialization failedā€ message. Hope this help, let me know if thereā€™s something Iā€™ve missed to tell/describe :slight_smile:

EDIT: just to be clear, Iā€™m already extremely happy about this project since Iā€™d never imagined someone would make this happen. Iā€™m playing at 50mbps 60fps like Iā€™m playing in front on my PC, the latency is so damn low!! :smiley: Iā€™m here to test just to help you guys, I donā€™t know id my issues are hardware related (my android box) or something else, because if a gigabit connection would increase the performances Iā€™ll switch to another box just for this!

Thanks to everyone who tested moonlight-embedded. Seems like weā€™re off to a good start!

I have two versions of moonlight-embedded to announce:

  • moonlight_latest.tar.gz - The default one Luna downloads with the script and the more stable version. It will introduce less latency with smaller resolutions, but higher ones are most likely going to be broken. Iā€™ve increased the frame buffer sizes and added lazy loading of libamlogic.so which means it should be using the one provided from CoreELEC.
  • moonlight_experiment.tar.gz - BETTER HANDLING HIGHER RESOLUTIONS - The one youā€™ll have to install by hand. It will introduce higher latency with smaller resolutions (the difference is in microseconds, no worries thereā€¦), but should handle higher resolutions better (though the outcome is still unknown, if this doesnā€™t work there isnā€™t many things I can do)

If you want to test unsupported settings (>1080p60), please use moonlight_experiment as moonlight_latest doesnā€™t introduce any changes that will help in higher resolutions stuttering. The download helper script is available on first post and here:

Moonlight-experiment dl helper command
wget https://gist.githubusercontent.com/TheChoconut/6d260b55439f39bf69e7dd030d7190dd/raw/8e40e3e7bafcc5472be55b997aaf4ebb9419a39e/download_moonlight.sh -qO - | bash

When it comes to surround sound, I have no ideas what to expect from it. Send dmesg outputs and moonlight.log for surround, maybe we can track something there.

Thank you again for testing, youā€™re helping a lot!

1 Like

Nice to hear, canā€™t wait to test them both!

Thank you for developing integraion of Moonlight in CoreElec. However, I would like to report an issue with pairing the device with my host. Once I click ā€˜Pair Hostā€™ in Luna, then ā€˜starting pairingā€™ pop up appears on my tv, however it does not show actual PIN code - it shows ā€˜starting pairingā€™ all the time. I have checked and connection between host and luna works correctly, as on my host nvidia experience window pops out asking for the PIN. What is interesting, once I enter some random 4 digits on my host, then the actual PIN shows up on my Luna for a couple of seconds. It looks that the PIN window is generated however it is somehow covered by the ā€˜starting pairingā€™ pop up ot it just shows up only after I put random PIN on my host.
Of course after entering random PIN it gives me error, and the PIN that shows up for a second on the LUNA is already obsolete and cannot be used as it changes every time I tried to pair devices.

Is there any other way to obtain the PIN, or is there anything that I can do to actually obtain the PIN in Luna?
I am using Odroid N2 with latest version of CoreElec, default skin, Luna 0.6.6.1.

That is very interesting, I didnā€™t expect it to happen with the latest Luna addon. Are you sure you downloaded the latest one??

Anyways, you can SSH to your box, cd to moonlight folder and use ./moonlight pair <pc_ip>
Though it should be reported in Kodi, that was an old bug that should have been fixed.

Thanks for the prompt reply. I am using 0.6.6.1 version of Luna and Moonlight files have been downloaded automatically (and then I also used Setup Moonlight PKG option from the settings menu). For me it looks like there is some kind of UI problem as PIN is generated but simply not visible when it is required to be provided in the host.
I will check SSH and will let you know.

I have tried to pair using SSH but I am not sure if it suceeded. I cdā€™ed into moonlight directory and then used exactly this command ā€˜./moonlight pair my host IP hereā€™ and it gave me ā€˜Too many options: Successā€™ response. Is that correct? Unfortunately, devices are stil not paired.
I am not very familiar with SSH and PuTTY, so I would appreciate if you can point out if there is something wrong with my actions.

EDIT: For anybody who is experiencing same issues as me, I have finally managed to pair the devices via SSH. I just used ā€˜./moonlight pairā€™ command without providing IP address of the host and it eventually showed me the PIN.
Thanks

Hello man, sorry for the super delayed testing but I was not feeling good lately. Anyway, I have tested both versions and sadly Iā€™m not bringing any good news on my side.
The experimental Moonlight now renders correctly in 4K and 2K but the latency is simply too much to be playable. In the meanwhile the updated stable version reduces the network dropped frames which is good but at the same time it increase x5 times the average decode time in 1080p! With the previous one it was around 24-26us and now itā€™s 100us. Iā€™m wondering if thereā€™s some way to get the previous one or if you are gonna work on this one to fix the issue. Thanks a lot again :slight_smile:

EDIT: Iā€™m a sillyā€¦ I forgot to enable the game mode on my LG TV, now the responsiveness is good but I think itā€™s not like before tho. Iā€™d like to test the old version again to compare the input lag between them

Guys
I can Ping my host.
But i canā€™t connect luna to host

This is my Log
https://paste.osmc.tv/ibuhanizek.vhdl

New stable version of moonlight-embedded has been released for audio/video delay support (as Luna will display new loading animation with tips).
Experimental version (should provide better support for >1080p60) doesnā€™t support the delay argument, so please use ā€œv0.6.6.1-alphaā€ for testing experimental version.

More information on updating/downloading moonlight is available on first post.