Limelight Embedded and OSMC

Hello OSMC users. First of all, I’d like to open with some transparency, as this topic is currently also running in the old forums under topic: OSMC Forums

With that being said, and knowing this forum is really mainly help with feature-breaking bugs, I feel it’s worth a shot to see what we can get figured out.

I am currently running OSMC RC, Limelight Embedded 1.2.1, Java SE Development Kit 8 Update 33 for ARM, and am using 3 scripts (defined below) to attempt to incorporate a direct link to launch Limelight (thus far attempted both through a python script and an executable shell script via Advanced Launcher).

limelight.py
#!/usr/bin/python
import subprocess
subprocess.call(‘sudo sh /home/osmc/limelight/limelight.sh &’, shell=True)

limelight.sh
#!/bin/sh
sudo systemctl stop mediacenter &
sudo sh /home/osmc/limelight/stream.sh &

stream.sh
#!/bin/sh
sudo java -jar /home/osmc/limelight/limelight.jar stream 192.168.x.x
sudo systemctl start mediacenter

snd-bcm has been loaded into /etc/modules

When I launch the python script from file manager (or the limelight.sh script using advanced launcher), my rig with the nvidia game stream doesn’t respond in any way. Steam is not launched, and the stream does not start. To test to see if my coding was off, I ran the sh script via SSH and everything runs smoothly, mediacenter quits, the stream launches. Upon exiting the stream, mediacenter reopens.

When changing the above stream.sh file to the following, this actually initiates a pair with my streaming rig without a problem.

stream.sh stripped
#!/bin/sh
sudo java -jar /home/osmc/limelight/limelight.jar pair 192.168.x.x
sudo systemctl start mediacenter

It would seem something is preventing the stream argument from running when done through the Kodi GUI. Skipping anything to do with stopping the media center and simply running the above stream.sh file directly through advanced launcher will initiate a pair as well, but when changed back to the stream argument, it does not launch a stream.

Anybody know of anything in particular that may be preventing the stream argument being being run via a python or executable shell script through the GUI? Again, all scripts that will not launch the stream argument through Kodi’s GUI work perfect when attempted through SSH remotely.

1 Like

Try this:

subprocess.Popen([‘sudo’, ‘sh’, ‘/home/osmc/limelight/limelight.sh’, ‘&’])

Or try dropping the ampersand.

Thank you Karnage, I will attempt this tonight when I get out of the 1-9 grind. I have attempted dropping the ampersand, which yielded no feasible result.

Curious, as I know next-to-nothing regarding Python, would running it as “Popen” be different than simply running the /home/osmc/limelight/limelight.sh script manually as I did through AdvancedLauncher? Does this change something in the process of executing the limelight.sh script?

The main difference I know of is that Popen doesnt block*, but the reason I posted it is because I have external code that is confirmed to run on OSMC via Popen.

*Call is simply Popen with an automatic .wait()

Awesome, will try this when I get home and report back.

This unfortunately did not change the situation. It does still function if I change the argument from stream to pair, meaning it still requests a pair from my gaming rig, but the stream argument still does not launch.

Isnt there supposed to be a code showing up on the Pi for you to enter on the PC?

Correct there is. I may not have explained clearly that I am issuing the pair argument solely for the purpose of testing that the script is functional so as to rule out any human error in improper coding. The PC is already properly paired, and Limelight is fully functional in streaming when the command is issued via a remote ssh session. The issue lies in the fact that when the scripts are run via the OSMC gui, the stream is not started. Media center will exit as expected, but no stream is initiated. But to test that I didn’t miscode i attempt to use the pair argument, and a pair is initiated, showing that the code is in working order. It simply does not execute the stream command.

I’m baffled.

Maybe add a sleep time to the script, give kodi some time to die.

This will give it 10 seconds to exit.

import subprocess
import time
subprocess.Popen(['sudo', 'systemctl', 'stop', 'mediacenter'])
time.sleep(10)
subprocess.Popen(['sudo', 'sh', '/home/osmc/limelight/limelight.sh'])

I have attempted something similar in regards to ensuring the script has time to run. However, even when disregarding the media center stop function and simply launching the stream argument to run in the background, it is not initiated and the stream does not start on my gaming rig. The stream is not dependent upon media center being closed so it would simply run in the background without any issue, but this does not happen.

Also, I appreciate all of your suggestions, thanks for taking your time to help out.

All testing I’ve done indicates that for some unbeknownst reason, the limelight stream argument is being “blocked” or prevented when launched form within XBMC.

Anyone else attempting to accomplish this?

Hi all,

I’ve recently installed OSMC and have been trying to use it as an all-in-one media center. I’d like to try Limelight, and have tried following instructions from here: GitHub - moonlight-stream/moonlight-embedded: Gamestream client for embedded systems

Unfortunately, I can’t get Java working. I have very little experience with Linux but have established there is no package on apt-get for the Java 8 SDK, so downloaded the .tar.gz file from Oracle and “installed” in the /home/osmc/java directory using sudo tar.

That all went fine, but ssh won’t recognise the java command. I mustn’t have installed Java in the right place to be executable, but don’t know where to start. Can anybody help?

Follow this tutorial to install Java.

qpop, ensure when you run the java command you are pointing to the java directory, instead of java -jar limelight.jar make sure you’re doing something like /home/osmc/java/bin/java -jar limelight.jar.

I’ve managed to get a stream running now, which is great. How do we tweak the settings (resolution and so on)?

Any chance of us getting controller support? I have a bluetooth dongle and a PS3 controller, for example.

Hey @all,

I´ve installed Java 8u33 SDK.
Limelight pairing was successfull but when I want to start streaming I get the message Limelight needs GFE Version 2.1.1.0 or later, on my PC I have already the latest GFE (2.2.2.0).

Any suggestions?

Edit: new version 1.2.1 includes a fix of this issue

I found a solution for the OSMC start/stop issue using openvt & nohup. Thanks to mkobit for the OSMC/RetroPie scripts (GitHub - mcobit/retropie-osmc: This is a simple script to install retropie alongside osmc.).

First we need to install kdb & libopus-dev:

apt-get update
apt-get install kbd
apt-get install libopus-dev

Code of my scripts:

/home/limelight/limelight.sh:

#!/bin/sh
sudo openvt -c 7 -s -f clear
sudo openvt -c 7 -s -f echo "Running limelight from KODI"

# Start watchdog
sudo su osmc -c "sh /home/limelight/limelight_watchdog.sh &" &

# Start stream
sudo su osmc -c "nohup openvt -c 7 -s -f sh /home/limelight/stream.sh >/dev/null 2>&1 &" &

sudo openvt -c 7 -s -f clear
sleep 2

# Stop mediacenter
sudo su -c "systemctl stop mediacenter &" &

exit

/home/limelight/stream.sh:

sudo /sbin/modprobe snd-bcm2835
sudo java -jar /home/limelight/limelight.jar pair 192.168.x.x
sudo java -jar /home/limelight/limelight.jar stream 192.168.x.x -1080 -30fps

/home/limelight/limelight-watchdog.sh:

#!/bin/bash
sleep 60
while [ true ]; do
    VAR1="$(pgrep java)"
        if [ ! "$VAR1" ]; then
            sudo openvt -c 7 -s -f clear
            sudo openvt -c 7 -s -f echo "Limelight quit... Starting KODI."
            sleep 1
            sudo openvt -c 7 -f clear
            sudo su -c "sudo systemctl restart mediacenter &" &
            sleep 1
            exit
        else
            sleep 2
fi
done

In OSMC just set a shortcut to “System.Exec(/home/limelight/limelight.sh)”.

Enjoy! :smile:

1 Like

Hey miko, thanks for providing this information.
I just set everything up but ran into a small problem at the end.

Ho do i set a shortcut like this?

Hi ErnieBall, what skin are you using?

I am using Eminence. It’s pretty easy to add buttons to this skin: Eminence

If you are using Confluence you need to edit addons/skin.confluence/720p/home.xml and add a new item to your button list. This should do the trick:

<item id="19">
    <label>Steam</label>
    <onclick>System.Exec(/home/limelight/limelight.sh)</onclick>
    <icon>-</icon>
    <thumb>-</thumb>
</item>

Make sure to use a unique “id” for your new button.

http://kodi.wiki/view/HOW-TO_edit_the_Main_Menu_(Home_Screen)_via_skinning#How_to_add_a_new_button_to_the_Menu