Recycling: rpi + tv = Video and Photo Billboard

This is going to be a bit wordy so if you like skip to the Implementation

I have an old laptop attached to my piano as a sort of turnkey machine for Synthsia it runs Manjaro Linux, a derivative of Arch. So I was updating this laptop when it kind of occurred to me to try to make the tv attached to it have an AppleTV Aerial like video display, jealous as I was of my mate Simon's setup. Luckily arch had an aur package that downloaded the videos.

Using xscreensaver and a custom command with mplayer, which was really easy to google, thanks random ubuntu forum user marric for the info. I'll reproduce here:

$HOME/.xscreensaver
--snip--
programs: \
        "My Movies" mplayer -shuffle -nosound -really-quiet \
        -nolirc -nostop-xscreensaver -wid \
        $XSCREENSAVER_WINDOW -fs -loop 0 \
        $HOME/Path/to/my/movies/* \n\
         maze -root \n\

--snip--

So that worked perfectly.

Fast forward a week, and I was walking through the shed at my share-house, where there is a spare tv which my housemates are wanting to get rid of. I remembered that I had an original raspberry pi which my best mate had given me to play with, and I thought why shouldn't I be able to setup a digital billboard.

It so happens that I dance at Salsa and Latin dance studio called Latino Grooves which has been wanting something like this for a while. It wouldn't cost me much other than time and could be a fun little project which uses some previously wasted electronics.

Now it turns out that the rpi that I have doesn't have a network port, and only one usb. which means that to boot and install software I need to get a usb hub, and a usb ethernet adapter.

The stores were all closed already, so I guess some prototyping on my regular laptop would have to suffice. using xscreensaver with a combination of mplayer for videos and the inbuilt photopile screensaver did exactly what I wanted.

1 day later...

I also figured out that the 1gb memory card I had floating around was too small to hold a library of video's and images so au$70 later and I have the extra parts I required.

After installing the previously mentioned software, I booted it up and  ugh... the rpi is too slow for this :(. After some frustration I put the project down for a few hours.

Later that same day...

I gave up on my expectations, I figured I would just do as much as was possible, which I hoped was a simple slideshow of images with animations or transitions.

I googled randomly for rpi video player, because my intuition said that there's no way that it wouldn't have some hardware acceleration to make it useful for people, and if I can find the software that takes advantage of the hardware I might get at least get something more than the simple slideshow.

Thankfully Omxplayer exists, and it plays video's just fine and it doesnt use X :D yay, video billboard is totally doable, which also means that I should be able to find a framebuffer image viewer too, and sure enough the fbida project exists, and neither of them need the xserver, which is great!

It wont be as pretty as photopile from the xscreensaver list, but it will do just fine.

With all the pieces of the puzzle now gathered I can now make it work.

Implementation

hardware: Raspberry Pi
Software: Omxplayer, fbida, pretty sure there wasn't anything else.

I ripped down some pictures and videos from facebook and youtube as some test source material, I found DownloadAlbum to be of use for facebook images, facebook video's however were a PITA, and i'm not going to recommend any tool for that job, just avoid it if you can. And I'm afraid google will cause me trouble if I mention a way to download from youtube since blogger is their platform too.

I created two folders( /Videos and /Pictures) and set their permissions for all read write, because this thing doesn't have a network, there isnt any real security concerns. Now I don't own a mac, so I'm not sure if they will be able to modify the ext4 partitions to add their own videos and pictures, but we can work something out when it comes to it. obviously I put all the source material in those folders.

I had to add the user to the video group so that fbi can write the frame buffer device

I found this gist to be very helpful in getting a user to auto login on tty1, thanks computayla aka Atilla Gündüz.

I created a .bashrc that does the work:

$HOME/.bashrc
--snip--
echo -e '\e[?17;0;0c'
clear

shopt -s nullglob
VIDEOS=(/Videos/*)
VLENGTH=${#VIDEOS[@]}
PICTURES=(/Pictures/*)
PLENGTH=${#PICTURES[@]}

while true; do
 SELECTION=
 for i in {1..20}
 do
  SELECTION+="${PICTURES[ $(($RANDOM % $PLENGTH))]} "
 done
 fbi -a -u -t 1 -1 -noverbose -blend 1000 $SELECTION &>/dev/null
 omxplayer -o local -b ${VIDEOS[ $(($RANDOM % $VLENGTH)) ]} &>/dev/null
done

If I were to break it down, I guess it would go something like

  • stop the cursor from blinking
  • get a list of all pictures and videos and their lengths
  • loop forever this:
    • select randomly 20 pictures
    • display them
    • display one random video

And the last thing that needed fixing was that the tv would take some time to boot compared to the raspberry pi, so I added a boot delay, and disabled console blanking to the /boot/config.txt and /boot/cmdline.txt respectively. Otherwise the tv showed no signal, I guess because at the time of boot there was no hdmi available.

Pretty simple stuff overall, good for an afternoon project.

EDIT:
you remember that doubt I had about mac being able to read ext4, well turns out that by default they can't, and that the macfuse driver thingo only has experimental write. Not that that matters because I can't require them to mess about on their own pc. This will teach me to not pursue all avenues of doubt.

So I resized the ext4 root partition using resize2fs, and then changed the partition table with fdisk, and that worked as advertised. then I filled up the remaining space with a FAT32 partition, relabeling the old one with fatlabel and the root partition with e2label copied across the files and edited the fstab to mount on boot, modified the scripts for the new location and it worked as expected with no hiccups.

I did go and uninstall all the xorg stuff I had been experimenting with, which actually broke fbida because it needed a monospace font. so I installed ttf-dejavu and that solved that.

Fingers crossed that's all. although I might tweak the scripts to not get a divide by zero if there are no files in either of the folders.