sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install omxplayer (this can take about 10 minutes..)
sudo apt-get install screen
— Create a file called videoloop in the /etc/init.ddirectory: sudo nano /etc/init.d/videoloop — Copypaste the content for the script below — Change the permissions of the script to allow writing and execution: sudo chmod 755 /etc/init.d/videoloop
— Start the video loop:
/etc/init.d/videoloop start
— Close the video loop:
/etc/init.d/videoloop stop
— Re-open the video loop if it closes:
/etc/init.d/videoloop repair
Last step: Enable auto play whenever the Pi boots:
sudo update-rc.d videoloop defaults
Now reboot your Pi to see if the video plays automatically:
sudo reboot
#!/bin/bash
### BEGIN INIT INFO
# Provides: omxplayer
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Displays video file in a loop using omxplayer
# Description: Starts and stops video playback in a loop using omxplayer.
### END INIT INFO
# Video file path (update accordingly)
video_path="/home/pi/video.mp4"
# Ensure screen and omxplayer exist
if ! command -v screen &>/dev/null || ! command -v omxplayer &>/dev/null; then
echo "Error: Required packages (screen, omxplayer) are missing."
exit 1
fi
# Start or stop video playback
case "$1" in
start)
echo "Starting video playback..."
screen -dmS videoloop sh -c "omxplayer -o both '$video_path' -b --loop --no-osd"
echo "Video playback started."
;;
stop)
echo "Stopping video playback..."
screen -S videoloop -X quit
sudo killall omxplayer.bin 2>/dev/null
echo "Video playback stopped."
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
;;
esac