[HowTo] Moonlight-Embedded (former Limelight) using Luna Launcher

Wow, that was quick! Cheers for doing all the digging and for linking to the source! Dead over at GitHub is a great guy, have been in contact with him a couple of times now.
Just a quick educated guess regarding the syntax: looks like it refers to <device>,<subdevice> which in most cases should translate to <device>,<output> if it’s a multi output card. Will try to find some sources later today as I’m currently on my phone.
I’ll also check my local eBay later on and see if I can find a similarly cheap card. Thanks for the suggestion!
Regarding support in Luna: I’ll probably add this to the 0.6.0 version milestone, so it might take some time but it’s definitely on my list now!

Hi,

I’m using a PS3 controller and everything works great for normal Steam games (have custom mapping file selected in Luna).

But, I also play emulators (not retrostation on the pi, emulators started via steam on the host pc(PS2, Gamecube)). Now I have 2 problems, from which 1 could fit into this topic:

1.To end an emulated game, I need to press ESC on the keyboard. That is very inconvenient, because, the hosting pc is in another room. Question:

Can I map a keyboard key (to be specific: ESC) to my controller? It could be the PS button, but I prefer a button combination like Select + Start (like in emulationstation). In Retropi it is solved via input_enable_hotkey_btn = in the configuration file.

I strongly would prefer a solution inside the .map file for luna. I believe, it can’t be that hard, since every input now goes through dev/input/eventX . But I searched now for 2 days (lots of external programs, but don’t understand how to use them), and I still could not figure it out.

2.(Bonus question, possibly not connected to moonlight): My PS3 Emulator (newest dev build of PCSX2) recognizes the mapped PS3 controller via moonlight out of the box. My Gamecube Emulator (newest Dolphin) does not recognize my PS3 controller via moonlight. What do I do wrong?

Thanks!

How do you tell Luna launcher to write a log file?
For example, when I start moonlight over ssh I can just put > /home/osmc/Logs/moon.log at the end of the moonlight command and it will write the log file in the designated folder. To be more precise it would look something like
moonlight stream -1080 -60fps -app Steam 192.168.5.50 > /home/osmc/Logs/moon.log

I’d like to know what do I need to put in luna.conf to get the same result. I’ve tried
> /home/osmc/Logs/moon.log and
/home/osmc/Logs/moon.log but I get an error, Luna wont even start so obviously that’s not it.

A bit more info on my issue. I can start moonlight via Luna launcher and everything is working fine more or less. I get some stuttering when I set the bitrate to 35mbps so I would like to check the log file. Now, when I start moonlight over ssh, it is running in the background with Kodi still active. I can hear the sound from the moonlight stream but Kodi is in the foreground. For some reason Kodi does not shut down like it does when I start the stream via Luna.

It looks like this.
You can see both Kodi and moonlight stream when Kodi’s dimmed screensaver is activated. With the screensaver off Kodi is at 100% opacity.
I’ve tried sudo pkill kodi.bin but Kodi just shuts down and starts again.

So I’d appreciate any of the two solutions: either make Luna write a log file or start moonlight via ssh in a way that Kodi also shuts down like it does when launched via Luna.

Luna doesn’t log moonlight’s output anywhere right now and there’s no way to force it to do so (without changing the launch scripts). However I do agree that having the option to write it to a log file for debugging purposes comes in handy at times and I’ll look into making this possible in the future.
Since you also asked for an immediate solution: you can shut down Kodi and prevent it from restarting by using systemd: sudo systemctl stop mediacenter. After you got the output you need you can restart it by issuing sudo systemctl start mediacenter. If you want to test if this happens due to your settings in Luna you can just append the config file using the -configflag (Luna’s config file for moonlight is usually located at ~/.kodi/userdata/addon_data/script.luna/.storage/luna.conf. You can edit the config file using the same parameters moonlight takes as arguments for the respective options (as long as you don’t start Luna while doing so as Luna pulls all of its settings and dumps it to a config file right now, so your changes would be overwritten).
Hope this helps you resolve your problem as fast as possible and as I’ve said, I’ll look into a solution for general debug logging for the next update.
If you have any further questions feel free to ask - if I can’t help you I’m sure someone else can :slight_smile:

There’s two options on how this could be done:

  1. add another script which also takes controller inputs and always looks out for your button combination and sends some other command when it’s detected. Apart from this being inherently inefficient I also imagine developing this to be a total pain in the you know where (plus I’m not even sure if this can be done - I’m don’t know enough about the event API to say if this would block any inputs for moonlight)
  2. moonlight would need to support hot keys for more or less specific cases like this one. It’s somewhat related to this issue: Can you add QUIT command in the .map file? · Issue #317 · moonlight-stream/moonlight-embedded · GitHub - the only real difference is that they want to break out of the main loop inside moonlight and force the streaming to quit while you want to have another input sent if your specific button combination is pressed. If moonlight supports this my part in this is becomes more than easy.

Long story short: I won’t do this in Luna in the near future, except if moonlight properly supports such behavior. That being said I’ll probably play around with some ideas soon(ish) but I’d not expect this to work for some time. Sorry.

Thanks again for your help!

I’ve managed to capture some logs and right now I’m getting occasional errors every 5-10 seconds like:

Discarding RTP packet queued for too long
Discarding RTP packet after queue overgrowth
Network dropped middle of a frame
Waiting for IDR frame
Network dropped beginning of a frame

I have to say though, this only affects gameplay in games where fast reaction time is absolutely necessary since every now and then the screen freezes from anywhere from a fraction of a second to up to a second, sometimes even longer than a second. However, in slower paced games these frame drops seem to happen not so often and even when they do they dont affect gameplay at all, so overall I’m very satisfied with moonlight/Luna performance so far.

This was tested at 35, 40 and 50mbps, I didn’t experiment with changing the packet size for now.
Are there any bitrate value recommendations considering I’m running on a RPi2? Only info regarding bitrate I found is that 20 is the default and setting to 35 considerably enhanced my video quality.

I’m only using 20mbps (that’s the default for 1080p btw, moonlight scales this automatically IIRC) as bitrate myself, but mostly because I’m too lazy to really test which other value would work better and/or improve my visual experience (I’m spending most of my free time working on Luna, so please read this as ‘If I’m about to game, I just want to have some fun and distraction’ :wink: )

Considering your errors include the mention of a network drop: are you using a wireless connection for either your desktop or your Pi?

No, everything is wired. However there are two routers between the host and the Pi. One of them being a crappy ISP provided router and the other one is just really old (like, >15 years old) so I wouldn’t be surprised if any one of them is the source of the issue. Also, it could just be the host PC since I’ve noticed that games with lower system requirements don’t have the stuttering issue (although I could be wrong, I haven’t put much time into testing yet)

@Trondomer Sorry for my late answer, I’ve been busy the whole last week.
Given your network hardware I wouldn’t be too surprised if you’re having some amount of packet loss between your host and your Pi. Easiest (through probably not most reliable way) of figuring this out is to ping your host from your Pi for a bit and see if packets are dropped and / or you’re having spikes in RTT (you can kill the ping process using CTRL+C or just fix a number of pings to begin with, e.g. ping [host-ip] -c 100 would send 100 packets - sorry if you already knew this, but it might come in handy for other people browsing these forums for a solution to a similar problem).

My network seems fine, I have zero packet loss and very little spikes in latency.
I believe I’ve found the cause of my frame freezing issue. At least in my case it appears to be caused by Luna launcher.
If I simply start moonlight via SSH and kill the mediacenter there is zero frame drops and everything works as it should (except for some audio lag, but that seems to be caused by the host PC). However, every time I use Luna to start Steam the issue is there. And this happens like clockwork, every ten or so seconds the video freezes for about one second, more or less.
Just to be clear, I’ve double checked and made sure all the settings are the same when using Luna and when starting via SSH (as far as I can tell, though I may have missed something). I’ve even tried lowering to 720p 30fps, lowering the bitrate and even not using the external usb audio card.

Hi,
I have configured moonlight and LUNA along with setting up the XBox 360 (PC Wireless) controller as per this post. Games stream fine and keyboard/mouse also works however for the life of me I can’t get the XBox 360 controller working. xboxdrv output showed it was working fine when I tested it before adding it to start with boot. However after having the service start during bootup, running xboxdrv though ssh displays

Error couldn't claim the USB interface: LIBUSB_ERROR_BUSY

xpad service is blacklisted (and I confirmed not running) as per the instructions in the OP so I’m assuming it just doesn’t like the fact that I’m trying to run another instance of the xboxdrv.

Controller works fine on the PC so it’s not a hardware problem. The host PC is located beyond the range of the wireless xbox controller so plugging it in to the PC directly is not an option. Would really appreciate if someone would help me troubleshoot the issue cause I’ve pretty much exhausted, my admittedly amateur, linux skills.

Hey i need some help!

Every time i try to install the LUNA and LUNA SCRIPT ZIPS in kodi, i get an error basically telling me i dont satisfy the dependency to install … that being python-dateutil 2.4.2.

i did an apt-get install python-dateutil, but it only pulls down 2.2.2… which still causes the install to fail because it doesnt match or exceed the version number. Any ideas? i really want to stream from my pc. Any help would be appreciated.

Thanks

Try python3-dateutil

Edit: Debian jessie only seems to have 2.2.2 in the repository…

@GameOver69
Heya and welcome to the forums! :slight_smile:

First things first: please ask your questions in only one of the threads in the future to keep things tidied up a bit. I’m watching both of them so I’m definitely reading your questions and suggestions in both of them.

I guess the issue you’re seeing is the same as here - if it is you should be able to resolve it on your own by following the steps listed in the last comment. Please make sure to uninstall the python-dateutil you installed via apt before trying these steps.

Let me know if this works for you as well!

@mcobit
Even if 2.4.2 was available in the repo the installation would fail on the next dependency - dateutil just happens to be the first to be checked :wink: It seems to me that the kodi repository isn’t properly initialised under certain circumstances and fails to download the dependencies, thus the installation fails.

Thank you for your reply. I will try this as soon as I get home. Fingers crossed!

I apologize for the double post. I saw that this one looked much more active and thought it would be a good idea to post here. :slight_smile:

No worries about the double post, just want to make sure it doesn’t happen again :stuck_out_tongue:

When you get Luna to install please keep in mind that there’s currently another issue which causes it to crash when pre-release updates are disabled (which is the default setting). More information can be found here.

Good luck and let me know if you need any further help :slight_smile:

So just going to the kids add fixed the issue! I also enabled the pre release updates…

Unfortunately I’m still not out of the woods. I get an error from Luna… and can’t pair host from the add-on. This is what I see in the logs. Amy help is of course appreciated!

DEBUG: Could not load advanced crypto pro
vider. Reason: ImportError(‘No module named Crypto.Util’,)
18:36:30 1313.318970 T:1750070256 ERROR: EXCEPTION Thrown (PythonToCppExcep
tion) : -->Python callback/script returned the following error<–
- NOTE: IGNORING THIS CAN LEAD T
O MEMORY LEAKS!
Error Type: <type ‘exceptions.IOE
rror’>
Error Contents: [Errno 2] No such
file or directory: ‘/home/osmc/.cache/moonlight/uniqueid.dat’
Traceback (most recent call last)

Oh, damn … yeah, that kind of stuff happens when you’re doing all the testing on your own :frowning:

Issue here is that the path ~/.cache/moonlight/ doesn’t exist (yet) when Luna tries to dump the uniqueid.dat file. SSHing onto your Pi and creating that directory yourself should fix it (mkdir -p ~/.cache/moonlight).

I’ll add an issue on GitHub and will make sure that the fix is included in the next patch (it’s actually already fixed on my current branch, that’s why it took me a bit to find it).

So that worked… had to also give permission to write to that directory…

So now my issue lies with pairing… it generates a pin, and I enter it into the pc… and it fails every time. Here is the log.

Log looks good so far - the ‘Insecure Request’ Errors just appear because I’m not validating the host identity when making a request.

What’s your moonlight-embedded version and Luna’s error message? Simply “Pairing failed, try again”? If so, does moonlight list {HOST-IP} return any games or ‘not paired’?

P.S.: If you’re tired of going through these errors right now you can also just pair using moonlight’s CLI: moonlight pair {HOST-IP} - Luna should find the certificates for all subsequent requests. I’ve re-written most of the pairing stuff in 0.6.0. and it’s just impossible to test every single situation manually … sorry for the inconvenience this causes you :s