Wednesday, 3 February 2016

The beginnings of a new welcome screen - Raspberry Pi Adventures

In our offices' reception room, there is a wall-mounted TV. On it, we display a welcoming video that shows off our work.

This is powered by a laptop out of sight in another room, with a video playing on a loop.

New Screens 


We recently outfitted our meeting rooms with shiny new TV's, so we moved one of the existing screens to the reception room.
At this point, we decided to investigate whether we could ditch the laptop for something a little more neater, and easier to manage.

The first idea to explore was using a USB memory stick with a video on it. This could be powered by the TV itself, and would be easy to update when needed. We'd take the USB stick, take it to a computer and copy the files across. Easy!

One problem we discovered, was that the videos wouldn't loop. Therefore, we created a video that was 10 hours long, repeating the actual video. Obviously, this isn't a good solution for easy manageability.
Back to the drawing board.

The Raspberry Pi

Enter the Raspberry Pi. A small credit-card sized computer, with an HDMI port, 4 USB ports, Ethernet connection, and a micro-usb port for power.

After a bit of research, we discovered a piece of software called PiPresents. This program allows you to specifiy a collection of images, and/or videos to play in sequence, repeatedly on loop. This sounds perfect!
Specifically, there is an option for 'LiveShow', in which this can read all files from a location on disk. You don't get the ability to specify which images or videos are displayed in which order, or for how long each image is displayed for with this option, but we didn't need that level of flexibility. Also, having to do that each time the collection of images/videos are updated kind of negates the 'ease-of-use' mechanism we were after.

So, we grabbed a Raspberry Pi Model B (one of the first generation ones), and set about installing.

Raspbian

PiPresents runs on Raspbian, a linux distro based on Debian, designed to run on the Pi. - this was the first step: Get the operating system installed.

Download the NOOBS image from the Raspbian site, get that copied to your microSD card.
From here its all done from the Pi, so get it connected to a screen, and power up.
Follow the instructions for installing Raspbian, and wait for it to install.

Once its all installed, and the Pi has booted into Raspbian, we can get cracking.
You can either do the work on the Pi itself, or you can SSH/Terminal/PuTTy into it to continue the setup, but be aware, you won't be able to run the actual video/images remotely.

We need to install the various bits needed to run this application, so either open a terminal window, or remotely via your SSH/puTTy connection, and enter the following:

sudo apt-get update

PiPresents

Once that has updated, you can then install the required components:

sudo apt-get install python-imaging python-imaging-tk unclutter mplayer uzbl

We then need to install pexpect:

wget http://pexpect.sourceforge.net/pexpect-2.3.tar.gz
     tar xzf pexpect-2.3.tar.gz
     cd pexpect-2.3
     sudo python ./setup.py install

Now, we are in a position to install PiPresents:

wget https://github.com/KenT2/pipresents-gapless/tarball/master -O - | tar xz

There should now be a directory called 'KenT2-pipresents-gapless-examples-xxxx' in your home directory
Rename this to 'pipresents'

From here, you'll need to be doing your work on the Pi itself.

Run PiPresents, to make sure its all working. The first time you run this, you will get an error saying a profile doesn't exist:

python /home/pi/pipresents/pipresents.py

Now, we can create a profile. Enter the following:

python pp_editor.py

From here, select Profile >  New From Template, and select 'Liveshow'

Once you have a new profile created, select the 'liveshow' from the 'Shows' box, then click the 'Edit Show' button in the middle.

There's a few options we need to set here:

Set the Image dimensions to

warp 0 0 1920 1080

This will show images full-screen (if your screen is a FullHD, 1920x1080 display), rather than at its original size.
Do the same for the Video dimensions.

Close the window, you are done with those settings.

Edit the 'Live Tracks' directory to where you want to store your files.

Start the presentation with the following:


python ./pipresents/pipresents.py -b -f -p [profilename]


the -b switch removes the mouse cursor, and -f displays full-screen
the -p is for the profile which you created above.

Everything should be running now, displaying whatever images/video you have in the directory.

Auto-boot

Once its all up and running, we now need to edit the startup script to launch the python script when the Pi is turned on.
From a terminal window, navigate to the  /home/pi/.config/lxsession/LXDE-pi directory

Note: if you are using a Raspbian release prior to 24/12/2014, then the path is slightly different: /home/pi/.config/lxsession/LXDE

If there is a file called 'autostart', then edit that, or create one with:

sudo nano autostart


In this file, enter
sudo python /home/pi/pipresents/pipresents.py -b -f -p [profilename]


Make the autostart file executable, with


chmod +x autostart

Now, reboot the Pi. You should boot up into Raspbian, then PiPresents should start playing your media

Growing Pains

We initally set up a network share to hold the media files, so people could drop in/remove media files whenever. This worked well during testing, but when we put the Pi in-situ, occasionally after an hour or so, the screen would freeze, and the Pi crashed.

We thought that the network connection was potentially dropping out, which would cause a wobbly.
Another issue we had was when powering the Pi directly from the USB port of the screen. We'd get a small box in the top-left corner of the screen. Turns out, this is a notification that the Pi isnt drawing enough power.
So, rather than powering directly from the TV, we plugged it into the wall socket. One problem solved, but this then left us with a dilemma. We ideally wanted to be able to to just turn the TV on, and the Pi would boot up, and start playing the videos. At the end of the day, we'd just turn the TV off, and the Pi would should down. Because we now have the Pi on a seperate power source, this no longer applies. No big deal though, we can either leave it running, or switch both the TV & Pi off via the wall switch.

After testing for a couple of days, we realised we were still getting issues intermittently. At this point, we decided to change tack, and have the media stored locally on the Pi, but have a share available pointing to that directory, essentially switching it round. We can connect to the Pi via a network share, and still be able to add/remove files remotely, but now the files are stored directly on the Pi. Even during a network outage, the screen will still be working.

We wondered if the original Pi was actually powerful enough to run continuously without issues. With only a 700MHz processor, and 256mb ram, we didnt think this was quite enough grunt.
So, we switched out the Pi for a Pi 2, which comes with a 900MHz, quad-core ARM7 processor, and 1GB ram. This should be more than enough umpff to work without issues.

We've had the Pi2 in place for a week or so now, with no issues reported.

Update:


We've liked this process so much, we've decided to add a second screen on the opposite wall, that displays a collection of images in a loop. These can be tailored to be client-specific when we have guests in, to give a more personal and welcoming entrance. All with drag/drop maintainence!














No comments:

Post a Comment