[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.