I have a python script that needs to run the omxplayer after the pi is finished booting on the latest version of Raspbian whit Pixel.

I have tried the 3 different methods from the accepted answer here : Execute script on start-up

The script does execute, but the video player won't start. (Nothing appears on the screen)

If I run the script by hand, the video works. I have tried with both LXDE enabled and disabled.

How can I get omxplayer to display the video when executing after a reboot?

os.system(`killall omxplayer.bin`)
omxc = subprocess.Popen([`omxplayer`, `-b`, `dronesunset.mp4`])
  • 1
    Can you try passing the full path to the mp4 file ? maybe its a issue of wrong working directory ... also noticed the first line says osxplayer.bin. i am assuming you mean omxplayer.bin (note the 's' instead of 'm') Commented May 26, 2017 at 18:42
  • good catch for the path! I changed it to absolute path and still same behavior. Works when launching manually, but not on login. the osxplayer was just a typo when I wrote the question.
    – ESD
    Commented May 26, 2017 at 18:58

5 Answers 5


You can absolutely do this without the need for a GUI desktop or logging in. I used this technique to have a RPi Zero 1.3 (no network) boot directly into omxplayer continually looping a video -- a 2 hour aquarium loop in my case. Here's how I did it using systemd:

  1. Create a file in /etc/systemd/system/omxplayer.service containing:

    Description=Ambient scenery display
    ExecStart=/usr/bin/omxplayer -r --loop --vol -6000 -o hdmi "/path/to/video.mp4"
    ExecStop=/usr/bin/killall omxplayer
  2. Enable the service with sudo systemctl enable omxplayer.

The RPi should boot and launch omxplayer early in the boot process. The console is useless at this point, and the Pixel desktop inaccessible unless you add something to kill omxplayer when needed. The player runs in the background, so pressing [esc] won't exit it. If the RPi is networked, you can access it via the network normally.

Note the use of the omxplayer parameters: --vol -6000 for silent (change to suit), -r to adjust the framerate to the video, --loop to loop continuously (with a short blank between loops, unfortunately), and -o hdmi to force HDMI output.


omxplaer requires lxterminal to run, so:

In ~/.config/autostart/omxplayer.desktop:

[Desktop Entry]
Exec=lxterminal -l -e "omxplayer --loop --no-osd -o hdmi /home/pi/Videos/vid.mp4 > /dev/null"


  • I'm working on an app that runs on boot instead of desktop environment (fullscreen app that is the only purpose of this RPi), and I couldn't get video playing from there. I just edited .xsessionrc and replaced exec /path/to/myapp with exec lxterminal -e /path/to/myapp and everything runs fine. Thanks !
    – psycho
    Commented Feb 9, 2020 at 22:15

I don't think that you can play videos without logging into an account first. However, you can create a new account with autologin to do it:

Add a new user if you don't want to put autologin on your personal account:
sudo adduser videouser

If your script needs root permissions: (skip if you are using your account)
sudo visudo

Then navigate to bottom and add/edit: (skip if you are using your account)
videouser ALL=(ALL) ALL

Once that's done, type nano ~/.bashrc (may need sudo). Go to the very bottom. Any valid bash that you put here will be run when the account has logged in:

omxplayer -b /absolute/path/to/video.mp4

  • One of the methods I tried to auto-start the script waits for the pi to auto-login into the user pi.
    – ESD
    Commented May 26, 2017 at 16:55
  • What exactly did you try? To help you further we need more info. Can you show us the exact command you are using to launch your python script?
    – otoomey
    Commented May 26, 2017 at 16:58
  • In my original question I state that I tried all the methods of the accepted answer with a link...
    – ESD
    Commented May 26, 2017 at 16:58
  • What command did you add to your bashrc file? Because if you are using the same one as from the link then it might not work, because he's trying to launch a browser and you're trying to launch a python script.
    – otoomey
    Commented May 26, 2017 at 17:02
  • python /absolute/path/to/script.py and in my python script there are the lines I posted in my question.
    – ESD
    Commented May 26, 2017 at 17:03

What I had to do to get it to work : instead of using .bashrc to start it, I had to :

run when booted into the LXDE environment see : Execute script on start-up

and thanks to Shreyas comment, make sure that the path to the video is absolute to prevent working directory confusion.


Put the script in .config/lxsession/LXDE-pi/autostart

I've done something similar but with a bash script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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