5

The objective is to start an Raspberry PI, auto-login into a user account and auto-play a video in fullscreen mode (using omxplayer) in endless mode.

So questions are:

  • how to auto-login into LXPanel
  • how to start omxplayer afterwards automatically?
  • how to run the video in an end-less loop? I know I can write a script but there is always some "flash"ing of the screen between two video runs.
  • 1
    omxplayer will play video from the command line, without the need of LXDE. Its really simple and works great. You can even control it over SSH, as long as you have a HDMI (VGA or anything) display connected – Piotr Kula Feb 3 '14 at 11:40
2

While I realise that this is a bit old now, I have been doing just this and thought I'd share the method I used as it was really straight forward:

  1. I copied the mp4 file into the /home/pi/Videos folder.
  2. I created an autostart folder here: /home/pi/.config/autostart
  3. In this autostart folder, I created a file called .desktop and put in the following:

    [Desktop Entry]
    Type=Application
    Exec=lxterminal -e "omxplayer -b --loop --no-osd /home/pi/Videos/MyVideoFile.mp4"
    
  4. Save the file and make it executable.

  5. Reboot.

That's it.

Because we are opening up a terminal window and then running the omxplayer from there, all of the keyboard shortcuts will still work.

If you have a headless display then the video will just start and keep looping till you pull the power.

Hope that this will help.

2

http://www.akeric.com/blog/?p=1976

Tutorial for auto login and auto start a sh script.

http://www.cenolan.com/2013/03/looping-video-playlist-omxplayer-raspberry-pi/

And here a sh script wich auto loop video and play them with omxplayer.

1

I know that this has been sitting here for a while, but as a new Pi user trying to implement a headless display system for a client I know that an answer to this would have vastly sped up my implementation of it. Below I will detail the setup that I arrived at. It is not going to be the best way I am sure, and I can guarantee that it is not pretty. But here it is in case it helps anyone else in the same situation.

1) To auto-login to LXDE you can just use the raspi-config tool and select boot to desktop - this will automatically log you in as the user 'pi'.

2) To start omxplayer automatically (within the LXDE session) I had to do a bit of a botch job. Basically, because omxplayer is a command line player when I just added it to the LXDE autostart list it would boot it in the console running behind the desktop. As in, my processor would show that it was active doing it but it was not shown. And then when I went to shutdown the pi as soon as the desktop closed suddenly the video would be playing on the screen instead.

So the way around this is to launch omxplayer within a terminal instance running inside the LXDE session. To do this I installed xterm (apt-get install xterm).

Once xterm is installed I then created an entry in the LXDE autostart file to boot it up (for my purposes I had a script to check if a suitable movie file existed in the desired directory and then, if it did, to launch it in omxplayer running in xterm. Assuming that you have a movie file already on the pi then you can skip this part - if requested I can provide details of how I did this).

To boot xterm (running omxplayer) on start I added a listing in the /etc/xdg/lxsession/LXDE-pi/autostart file. I added the line:

@xterm -fn fixed /etc/init.d/USBMp4Check

I used the -fn fixed parameter to suppress an error in xterm to do with a font file (no known fix for raspberry pi).

Within the /etc/init.d/USBMp4Check file I then had it check for a suitable file to open (a requirement of the setup the client wanted) and then, if it existed, open and play it on an endless loop.

The file check was created from the VNC autostart tutorial on the Raspberry Pi website (http://www.raspberrypi.org/documentation/remote-access/vnc/README.md). I changed the lines after "export USER HOME" to read:

if [ -e /tmp/*.mp4 ] #checks if an mp4 file exists at the temp directory
then
    /usr/local/bin/vplay.sh /tmp/*.mp4 #calls vplay.sh targeting the file
else
    echo "No movie found"
fi

I did this by checking the existence of the file and then, if it existed, opening the file via a shell script. The contents of this shell script are:

#! /bin/bash
sleep 5  #This ensures that the LXDE session has started up fully before attempting to open the file
exec xterm -fn fixed -fullscreen -fg black -bg black -e omxplayer -o hdmi --no-osd --loop -r "$1""

The parameters called here suppress the font error and opens xterminal in fullscreen with a black foreground and background. It then executes omxplayer within xterminal passing audio to hdmi, with on screen display turned off (otherwise you get an annoying seek message when the file loops back to the beginning), with the file looped, at the resolution of the video. I called the script vplay.sh as per the tutorial that I was gutting. Both of the files I created had to be executable (chmod 755). I know that it is not an ideal setup, but this is just a basic setup for the client to use immediately while I sort out a better setup.

Thus by autostarting the xterm calling the file check, the command was then passed to use/open this shell script pointing at the video file. This makes it play as desired.

3) I've covered the endless loop part in the above (use --loop as a parameter when opening omxplayer). I cannot speak for any flash as I do not get one here (using the latest version of omxplayer).

Apologies for the meaty write-up. If anything is not clear then let me know and I can provide further details.

Wanted to list the walkthroughs I used but apparently don't have enough rep to post multiple links yet. The parameters came from the github page for omxplayer, the rest from a whole load of other websites, lots of googling and too much trial and error. But it works (well enough for the moment)!

Hope that it helps someone else (or at least points them in the right direction).

protected by Ghanima Mar 29 '16 at 20:21

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.