├── LICENSE ├── README.md ├── autostart.sh ├── install.sh ├── looper.png ├── looperconfig.txt ├── startfullscreen.sh ├── startvideos.sh ├── videoloop └── videoloop_starter /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Steven Hickson 4 | There is a slight caveat, that if you enjoy my software and meet me, you can buy me a drink. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | RPiVideoLooper 2 | ============== 3 | ![alt tag](https://raw.github.com/StevenHickson/RPiVideoLooper/master/looper.png) 4 | 5 | Video Looper for the Raspberry Pi 6 | 7 | There are 3 main scripts. 8 | 9 | startfullscreen.sh starts the looper script whether X is running or not. So it can work with SSH or headless. It also uses the xterm fullscreen hack to make a black fullscreen no matter the video resolution. It should be in the /home/pi/ directory 10 | 11 | startvideos.sh loops through all the videos in the /home/pi/videos/ directory. It should be in the /home/pi/ directory. 12 | 13 | videoloop sets up the service and starts it on boot. It calls startfullscreen.sh. It should be in the /etc/init.d/ directory. 14 | You will have to use the update-rc.d script to set it to start on boot if you are not using the install script. 15 | 16 | The install script is available if you don't want to download the image. 17 | 18 | The image can be downloaded here: 19 | https://mega.nz/#!5IsgnSja!UaEbsc3byFuMD6psgz3CuxcwB0x8SfdqgcDxqgK1gE4 20 | -------------------------------------------------------------------------------- /autostart.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #check to see if autostart is enabled 4 | autostart=`cat /boot/looperconfig.txt | grep autostart | cut -c 11- | tr -d '\r' | tr -d '\n'` 5 | if [[ $autostart -eq 1 ]]; then 6 | `service videoloop start` 7 | fi 8 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | # Make sure only root can run this script 2 | if [ "$(id -u)" != "0" ]; then 3 | echo "This script must be run as root" 1>&2 4 | exit 1 5 | fi 6 | 7 | cp -a startvideos.sh /home/pi/ 8 | cp -a startfullscreen.sh /home/pi/ 9 | cp -a videoloop /etc/init.d/ 10 | cp -a autostart.sh /home/pi/ 11 | cp -a videoloop_starter /etc/cron.d/ 12 | cp -a looperconfig.txt /boot/ 13 | update-rc.d videoloop defaults 14 | 15 | echo "Use NTFS USB Key? y/n" 16 | read option 17 | if [ $option == "y" ] || [ $option == "Y" ] ; then 18 | apt-get update && apt-get install ntfs-3g 19 | mkdir /media/USB 20 | chmod a+r /media/USB 21 | echo "/dev/sda1 /media/USB ntfs-3g defaults,noatime,nodiratime 0 0" >> /etc/fstab 22 | echo "Done!" you will need to reboot after this 23 | fi 24 | -------------------------------------------------------------------------------- /looper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StevenHickson/RPiVideoLooper/e9eca673094f7560c196548f9da61c74497506fe/looper.png -------------------------------------------------------------------------------- /looperconfig.txt: -------------------------------------------------------------------------------- 1 | autostart=1 2 | usb=0 3 | -------------------------------------------------------------------------------- /startfullscreen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [ -z $DISPLAY ] ; then 3 | DISPLAY=:0 4 | `/home/pi/startvideos.sh` 5 | else 6 | `xterm -fullscreen -fg black -bg black -e /home/pi/startvideos.sh` 7 | fi 8 | -------------------------------------------------------------------------------- /startvideos.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | declare -A vids 4 | 5 | #Make a newline a delimiter instead of a space 6 | SAVEIFS=$IFS 7 | IFS=$(echo -en "\n\b") 8 | 9 | configs=`cat /boot/looperconfig.txt` 10 | usb=`echo "$configs" | grep usb | cut -c 5- | tr -d '\r' | tr -d '\n'` 11 | audio_source=`echo "$configs" | grep audio_source | cut -c 14- | tr -d '\r' | tr -d '\n'` 12 | seamless=`echo "$configs" | grep seamless | cut -c 10- | tr -d '\r' | tr -d '\n'` 13 | 14 | FILES=/home/pi/videos/ 15 | 16 | if [[ $usb -eq 1 ]]; then 17 | FILES=/media/USB/videos/ 18 | fi 19 | 20 | if [ -n "$seamless" ] && [[ ! "$seamless" -eq 0 ]]; then 21 | #run the seamless looper 22 | echo "seamless isn't 0" 23 | `/opt/vc/src/hello_pi/hello_video/hello_video.bin "$FILES$seamless"` 24 | exit 0 25 | fi 26 | 27 | current=0 28 | for f in `ls $FILES | grep ".mp4$\|.avi$\|.mkv$\|.mp3$\|.mov$\|.mpg$\|.flv$\|.m4v$"` 29 | do 30 | vids[$current]="$f" 31 | let current+=1 32 | echo "$f" 33 | done 34 | max=$current 35 | current=0 36 | 37 | #Reset the IFS 38 | IFS=$SAVEIFS 39 | 40 | while true; do 41 | if pgrep omxplayer > /dev/null 42 | then 43 | echo 'running' 44 | else 45 | /usr/bin/omxplayer -r -o "$audio_source" "$FILES${vids[$current]}" 46 | let current+=1 47 | if [ $current -ge $max ] 48 | then 49 | current=0 50 | fi 51 | fi 52 | done 53 | -------------------------------------------------------------------------------- /videoloop: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # /etc/init.d/videoloop 3 | 4 | ### BEGIN INIT INFO 5 | # Provides: videoloop 6 | # Required-Start: $remote_fs $syslog 7 | # Required-Stop: $remote_fs $syslog 8 | # Default-Start: 2 3 4 5 9 | # Default-Stop: 0 1 6 10 | # Short-Description: Simple script to start a program at boot 11 | # Description: A simple script from www.stuffaboutcode.com which will start / stop a program a boot / shutdown. 12 | ### END INIT INFO 13 | 14 | DISPLAY=:0 15 | 16 | # Change the next 3 lines to suit where you install your script and what you want to call it 17 | DIR=/home/pi/ 18 | DAEMON=$DIR/startfullscreen.sh 19 | DAEMON_NAME=videoloop 20 | 21 | # This next line determines what user the script runs as. 22 | # Root generally not recommended but necessary if you are using the Raspberry Pi GPIO from Python. 23 | DAEMON_USER=pi 24 | 25 | # The process ID of the script when it runs is stored here: 26 | PIDFILE=/var/run/$DAEMON_NAME.pid 27 | 28 | . /lib/lsb/init-functions 29 | 30 | do_start () { 31 | log_daemon_msg "Starting system $DAEMON_NAME daemon" 32 | start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile $PIDFILE --user $DAEMON_USER --startas $DAEMON 33 | log_end_msg $? 34 | } 35 | do_stop () { 36 | log_daemon_msg "Stopping system $DAEMON_NAME daemon" 37 | start-stop-daemon --stop --pidfile $PIDFILE --retry 10 38 | log_end_msg $? 39 | killall startvideos.sh 40 | killall omxplayer.bin 41 | } 42 | 43 | case "$1" in 44 | 45 | start|stop) 46 | do_${1} 47 | ;; 48 | 49 | restart|reload|force-reload) 50 | do_stop 51 | do_start 52 | ;; 53 | 54 | status) 55 | status_of_proc "$DAEMON_NAME" "$DAEMON" && exit 0 || exit $? 56 | ;; 57 | *) 58 | echo "Usage: /etc/init.d/$DEAMON_NAME {start|stop|restart|status}" 59 | exit 1 60 | ;; 61 | 62 | esac 63 | exit 0 64 | -------------------------------------------------------------------------------- /videoloop_starter: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # cron script to save a update local database. 4 | # 5 | # Written by Steven Hickson for the playvideo project. 6 | # 7 | PATH=/usr/sbin:/usr/bin:/sbin:/bin:$PATH 8 | 9 | @reboot root /home/pi/autostart.sh 10 | --------------------------------------------------------------------------------