Auto Updating Video Playback
Posted: Fri Mar 08, 2013 8:33 pm
The goal of my current project is to have Raspberry Pis replace dying DVD players in 50+ retail stores in my company, and adding the ability to update the videos they play. I want to be able to drop the video files on a server/share, and all of the Pis update themselves to the new videos automatically.
--
So far I have accomplished the following:
-Disabled X11 on boot
-Enabled auto-login in console
-Configured auto-run in bash
-Made a loop script that runs on startup
So now you turn on the PI, it boots, and immediately starts playing the video file in a loop forever, and looks great.
Then next trick is updating it. Here is my current loop script (taken from these forums originally), with no updating.
Here is my current working idea psuedo-code
In this version, if it is not running, we download a tiny pi.txt file, which contains just the time and date that the video files were updated last. It then checks if the file it last got, is the same as the file it just got. If they are the same, nothing has changed, and start omxplayer again. If something has changed, download the new ZIP, remove the old videos, unzip the new videos, and then go on. This check would happen every time omxplayer finishes playing the file, so every 5 minutes maybe.
This is pseudo code btw, it will not run obviously, I probably have a few switches wrong and im not sure how I am going to grep the output of diff to see if they were the same yet.
Thoughts? Should I fight with SSH RSA keypairs and rsync over 50 devices? Should I use a scheduled cron task and find a way for it to kill playback during update? Am I insane? Is there a much better and easier way to do this?
--
So far I have accomplished the following:
-Disabled X11 on boot
-Enabled auto-login in console
-Configured auto-run in bash
-Made a loop script that runs on startup
So now you turn on the PI, it boots, and immediately starts playing the video file in a loop forever, and looks great.
Then next trick is updating it. Here is my current loop script (taken from these forums originally), with no updating.
Code: Select all
#!/bin/sh
SERVICE='omxplayer'
while true; do
if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
echo "running" # sleep 1
else
omxplayer -o hdmi /home/pi/test.mp4 &
fi
done
Code: Select all
#!/bin/sh
SERVICE='omxplayer'
while true; do
if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
echo "running" # sleep 1
else
rm /home/pi/pi.txt.old
mv /home/pi/pi.txt.new /home/pi/pi.txt.old
wget http://www.website.net/pi.txt /home/pi/pi.txt.new
diff –s /home/pi/pi.txt.old /home/pi/pi.txt.new > result
if statement to determine if the files were different, and if they are*
wget http://www.website.net/pi.zip /home/pi/pi.zip
rm –rf /home/pi/*.mp4
unzip pi.zip
rm pi.zip
fi
omxplayer -o hdmi *.mp4 &
fi
done
This is pseudo code btw, it will not run obviously, I probably have a few switches wrong and im not sure how I am going to grep the output of diff to see if they were the same yet.
Thoughts? Should I fight with SSH RSA keypairs and rsync over 50 devices? Should I use a scheduled cron task and find a way for it to kill playback during update? Am I insane? Is there a much better and easier way to do this?