Automatically play and loop fullscreen videos on a Raspberry Pi (Tested on Pi 1, Pi Zero).
This system uses a basic bash script to play videos with omxplayer, it simply checks if omxplayer isn't running and then starts it again. This simple method seems to work flawlessly for weeks on end without freezing or glitches. The only caveat of this method is that there are approximately 2-3 seconds of black between each video. If you are looking to do something with gapless looping on Raspberry Pi, try Slooper by Matthias Dörfelt, though currently it needs a few updates to work without a remote (as of May 15, 2016).
There is a videolooper written in python that uses omxplayer by Adafruit, but unfortunately on testing looping videos for more than a day it froze (as of May 15, 2016).
The script will look for videos either in:
- the
video
directory in the home directory of the pi user - a usb stick plugged in before startup (this will not be remounted if you pull it out and plug it back in)
Start with a raspbian img (lite), install it on the pi, and follow the steps below to install the videolooper.
Insert or update the following parameters in the /boot/config.txt
disable_overscan=1
hdmi_force_hotplug=1
disable_splash=1
gpu_mem=128
- Select option: "3 Boot Options"
- Select option: "B1 Desktop / CLI"
- Select option: "B2 Console Autologin"
- Select option: "3 Boot Options"
- Select option: "B2 Wait for Network at Boot"
- Select option: "No"
- Select option: "1 Expand Filesystem"
Also look at the "Localisation Options"
If your screen goes black during command line after 30 minutes or so, you have screen blanking enabled most likely. If you want to turn it off:
Edit the file /etc/kbd/config
Change these lines:
BLANK_TIME=0
BLANK_DPMS=off
POWERDOWN_TIME=0
sudo apt update
sudo apt -y install omxplayer git-core
sudo mkdir -p /mnt/usbdisk
Choose one of the following lines. The diffrence is, that the first mounts the USB Drive Read Only. This will prevent the Drive from damage if it is removed wihout unmounting. The second mounts the USB Drive writable.
sudo echo "/dev/sda1 /mnt/usbdisk auto ro,nofail 0 0" | sudo tee -a /etc/fstab #read only
sudo echo "/dev/sda1 /mnt/usbdisk auto user,umask=000,utf8,nofail 0 0" | sudo tee -a /etc/fstab #writable
mkdir /home/pi/video
cd /home/pi
git clone https://github.com/herbetom/videolooper-raspbian.git
chmod uga+rwx videolooper-raspbian/startvideo.sh videolooper-raspbian/startvideo_random.sh
echo \"/home/pi/videolooper-raspbian/startvideo_random.sh" | tee -a /home/pi/.bashrc
If you get the following Error 'COMXAudio::Decode timeout' add the following to the file /boot/config.txt
gpu_mem=128
.
This will give the GPU more memory.