FluidMotion » NaibsPages » News » USB based video looper for RaspberryPi

USB based video looper for RaspberryPi

07 April 2015 20:45

A query was placed...  How can corporate video's be played in a loop & be easily updated by HR etc...

A smart TV comes to mind, but they really are not that smart. A RaspberryPi can easily perform the required tasks to play a default video, loop over all the video's found on an inserted USB & revert to a default video upon removal of a USB. Equally the RaspberryPi and the TV can be put to sleep during the evening's and weekends

 

Configure RaspberryPi

 

BootSplash

Install fbi

sudo apt-get install fbi

copy desired image to /etc/splash.png

create splash init script & save it as:  /etc/init.d/asplashscreen

#! /bin/sh
### BEGIN INIT INFO
# Provides: asplashscreen
# Required-Start:
# Required-Stop:
# Should-Start:
# Default-Start: S
# Default-Stop:
# Short-Description: Show custom splashscreen
# Description: Show custom splashscreen
### END INIT INFO


do_start () {

/usr/bin/fbi -T 1 -noverbose -a /etc/splash.png
exit 0
}

case "$1" in
start|"")
do_start
;;
restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
stop)
# No-op
;;
status)
exit 0
;;
*)
echo "Usage: asplashscreen [start|stop]" >&2
exit 3
;;
esac

:

enable the service

sudo chmod a+x /etc/init.d/asplashscreen
sudo insserv /etc/init.d/asplashscreen

 

 

(bootsplash, silent)

Hide NOOBS bootsplash

create a autoboot.txt file in the root of the flashdrive 

 

Configure an RCT module

Using an RCT module such as: http://thepihut.com/products/mini-rtc-module-for-raspberry-pi

First the i2c bus needs to be enabled by default

edit /etc/modules and add

i2c-bcm2708
i2c-dev
rtc-ds1307 # rtc driver

 

edit /boot/config.txt and add

dtparam=i2c1=on
dtparam=i2c_arm=on

reboot

List the devices attached to the i2cbus

i2cdetect -y 1

0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

edit /etc/rc.local and add:

ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device

reboot

The rtc should now be active. a "hwclock -r" should list Jan 1 2000.  Sync the RTC with the present time (confirmed via 'date' that should have been set via network time) with hwclock -w

 

 

VidLooper script

The vidlooper consists of 4 parts

  1. udev rule # manage usb insert/removal events
  2. cronjob  # manage interupts due to time
  3. interuption script # to ensure udev & cronjob reliably execute the same command
  4. main vidlooper

 

Not yet rated