Standalone looping video kiosk?

7 posts
by rhorange » Sat Nov 03, 2012 8:02 pm

Apologies if this has been covered (I searched & didn't see much, but that might be my ineffective searching) or, even worse, if this is self-evident, but I'm having trouble setting up a Pi to act as a standalone video kiosk. All I want it to do is loop the same video again and again, ad nauseum. I doubt if it makes a difference, but sound is not necessary.

I'm thinking there has to be a pre-built version of a linux kiosk out there, but I'm missing it.

Would something like raspbmc or xbian do this? Can they be set to loop a file indefinitely? The Pi will not have a network connection; if either of the above are an option, will they read from the mounted SD card?

Posts: 1
Joined: Sat Nov 03, 2012 7:57 pm
by ghans » Sun Nov 04, 2012 9:12 am
Perhaps just loop omxplayer with a bash script ?
Might be not pretty , but is bound to work.

• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere
Posts: 7203
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany
by SmeeMalc » Fri Nov 09, 2012 2:37 pm
I've developed a little python program that solved my problem of the command line and omxplayer output appearing in the black bars above and below my videos. I 'wrapped' omxplayer up in a ncurses screen and piped the keypresses to omxplayer (using a method similar to those I had seen previously on the boards) - I had to dig around a little to find out the escape codes that needed to be sent through the pipe to omxplayer to indicate that the cursor keys had been pressed, but I eventually found them here:

At the moment the code only supports a single parameter (the name of the video to play), so no subtitles etc., and the audio output option is hard-wired into the code at 'local', but there's not a lot of code involved so feel free to muck about with it! I include it below. Although I don't intend to use the code for this purpose, as ghans suggests I can't see any reason why code such as this couldn't be just repeatedly executed in a bash script (and killed remotely if necessary). I've also tried running the code from a terminal on the desktop and as long as you hide the taskbar, 'full screen' and 'defurnish' the terminal window before running the code, the only annoyance appears to be 2 pixel taskbar line remaining!

Code: Select all
#!/usr/bin/env python

import curses, subprocess, thread, sys
from time import sleep

allowedKeysList = ("q","+","-","z","1","2","j","k","i","o","n","m","s"," ","p")
cursorKeysDict = {curses.KEY_DOWN: "\c[[B", curses.KEY_UP: "\c[[A",
         curses.KEY_LEFT: "\c[[D", curses.KEY_RIGHT: "\c[[C"}

def main(video):
    pyVideo = PyVideo(video)

class PyVideo(object):
    def __init__(self, video):
        self.stdscr = None
   self.player = None

    def setupAndRun(self, stdscr):
        self.stdscr = stdscr
        try: curses.curs_set(0)
        except: pass
        curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK)
    self.player = Player()
   response = None
   while response != -1:
                response = self.keypress(self.stdscr.getch())

    def keypress(self, inchar):
   if inchar in cursorKeysDict.keys(): self.player.sendCommand(cursorKeysDict.get(inchar)); return
        if char in allowedKeysList: self.player.sendCommand(char)
        if char == 'q': return -1

class Player(object):

    def __init__(self):
   self.process = None

    def play(self, filename):
        opts = ["omxplayer", "-olocal", filename]
        self.process = subprocess.Popen(opts, shell=False,
        thread.start_new_thread(self.nullProcess, ())

    def nullProcess(self):

    def sendCommand(self, command):
        if(self.process is not None):
            try: self.process.stdin.write(command)
            except: pass

    def close(self):
        if self.process is not None: os.kill(, 15); self.process.wait()
        self.process = None

if __name__ == '__main__':

To 'install' and execute the code, just copy the code to your home directory under the name (for example) '', run 'chmod a+x' to make it executeable, and then you can call it with './' followed by the full path to your video file as a single parameter. I apologise in advance if any of my instructions are unclear as I'm a little new to all this 'stuff' myself!

Posts: 3
Joined: Fri Nov 09, 2012 1:59 pm
by SmeeMalc » Fri Nov 09, 2012 4:56 pm
Duh, I'm having to provide an update to my own post as it suddenly dawned on me that the code I provided could easily be adapted to endlessly replay a single video with a hard-wired path/name, and without the need for a bash script based loop, literally an extra couple of lines to loop around the curses.wrapper function/method (unless I'm missing something!). It could then be called/autorun from the command line (so no need to boot into the desktop) and left to it's own devices, never to return, so to speak. One issue might be a very brief display of the command line between the video ending and restarting, but to resolve that would be only slightly more difficult. Additionally, as sound output is not an issue in your kiosk scenario there'd be no need to worry about the audio settings for omxplayer.

Posts: 3
Joined: Fri Nov 09, 2012 1:59 pm
by denjell » Tue Feb 12, 2013 12:29 pm
here is a solution i posted yesterday to this problem.

will release a second (more interactive) version soon.
Posts: 25
Joined: Sun Feb 10, 2013 4:00 pm
by KenT » Tue Feb 12, 2013 2:38 pm
Probably more than you need but you could try
Pi Presents - A toolkit to produce multi-media interactive display applications for museums, visitor centres, and more
Download from
Posts: 759
Joined: Tue Jan 24, 2012 9:30 am
Location: Hertfordshire, UK
by socialdefect » Wed Feb 13, 2013 8:23 am
Headless video is a great job for cVLC, it will not be more scripting than
Code: Select all
cvlc /location/to/video.mp4
and trow in a --loop or --repeat option.

I was working on OpenCommerciallast year but I had to quit since the company I was creating it for decided they rather have a Windows PC running Powderpoint because they wanted to use it's default animations which the FOSS tools I included did not support.
You might be interested in the included scripts that start the Xserver from the CLI.

I am working on some projects atm that will bring OpenCommercial back to life too so I might be continuing working on it soon.

Hope it can help you out too..
== If it's not broke... I'm not done fixing it! ==
User avatar
Posts: 108
Joined: Mon Jun 25, 2012 9:02 pm
Location: Tilburg, the Netherlands