Screen On The Green - A Raspberry Pi Cinema

screenshot of screen on the green website

I have the pleasure of being one of a small group who run a cinema night once a month in the small town of Writtle, Essex. It's my job to take care of anything remotely technical.

We didn't have any money when we started so had to go cap-in-hand to the parish council who were great and bought the screen and the projector, we use an old Hifi system I had for sound.

We didn't want to use DVDs as we wanted a pre-show slideshow, trailers and an intermission which would've been impractical using DVDs, especially since we would need Blu-ray. Another option was to use a laptop which would've worked fine, but the Raspberry Pi with it's h.264 capable GPU seemed a perfect fit.

Initially we used a Raspberry Pi 3b+ but with the recent release of the A+ we've switched due it's lower power consumption.

In order to use the hardware h.264 decoding we had to use Omxplayer which unfortunately doesn't have playlist support so I had to use a little bash magic.

First we need a playlist file containing a list of video files in the order we want them to play:

cards/30min-preroll.mp4  
trailers/theapartment.mp4  
trailers/12angrymen.mp4  
trailers/incredibleshrinkingman.mp4  
cards/comingsoon.mp4  
cards/feature.mp4  
cards/intro.mp4  
film/amelie-pt1.mp4  
cards/intermission-start.mp4  
ads/ads.mp4  
cards/intermission-end.mp4  
film/amelie-pt2.mp4  
cards/thanks-for-coming.mp4  

A simple bash script to read the playlist and line-by-line and invoke Omxplayer. The -o both parameter sets the output of audio to both the HDMI cable and phones out. -b blanks the screen first.

#!/bin/bash

PLAYER=(/usr/bin/omxplayer -o both -b)  
PLAYLIST="sotg.pls"

clear  # clear the screen

if [ -e "$PLAYLIST" ]  
then  
    IFS=$'\012'  # Set the line ending
    for file in $(cat "$PLAYLIST")
    do
        ${PLAYER[@]} "$file"
    done
fi  

In order to split the film in two for the intermission I find a suitable spot, note the time, and convert it to seconds. For example, 45m 34s in would be (45 * 60) + 34 which is 2734. I then use this in a couple of FFMpeg commands to trim the single film file in to two parts:

#!/bin/bash

FN="amelie"  
TIME=2734

ffmpeg -ss 0 -t $TIME -i $FN.mp4 -strict -2 -af "volume=12dB" $FN-pt1.mp4  
ffmpeg -ss $TIME -i $FN.mp4 -strict -2 -af "volume=12dB" $FN-pt2.mp4  

-ss sets the start time for the trimmed file, and -t sets the end time, which we can omit on the second command as we want to trim to the end. -af "volume=12dB" boosts the volume while we're at it.

Raspberry Pi Dumb Terminal And Then Some

As someone whose interest in computing struck in the early 1980s I've always loved small self-contained computers. In my teens I discovered dumb terminals. However, it wasn't until the last ten years when I found myself SSHing in to remote servers that the idea I might have a use for one made any sense.

I Googled, I pored over oldcomputers.com and terminals-wiki.org, I watched old films. I kept coming back to the DEC VT100. I scoured eBay and other sites but they rarely come up and when they do are out of my price range.

Picture of a VT100 terminal

It dawned on me, "heck! I have a 3D printer, a competency with CAD, Linux, and basic electronics, and oh, the Raspberry Pi would be perfect for this."

First things first was to source the parts so I could design my VT100 around it.

The guts would be a Raspberry Pi Zero W since all I intended to use it for would be connecting to other systems.

The screen was straightforward enough on AliExpress. A nice 8", 4:3 screen with driver board, HDMI, VGA, and AV inputs was only ~£26. It's bright and sharp and only requires 12v at 2-4amp.

8

With a big enough power supply I could power the Pi and the screen from one input. I bought a simple step-down board to convert 12v to 5v with a USB output.

12v to 5v converter

The keyboard was a bit of a headscratcher. I wasn't about to 3D print a chassis and full keyboard so I was forced to compromise on the VT100 authenticity. I bought a cheap small USB keyboard. A future upgrade might be to make a housing this 3rd party keyboard would fit in to.

I leapt in with both feet (and a set of calipers) and designed a small VT100 which would fit the screen I had nicely.

Screenshot of VT100 design

The further I got in to designing it I realized how difficult it would be to print on my printer (the case itself would require six or seven parts glued together) and that it would take up a lot of precious desk space. I decided version one should be a working machine, not a faithful reconstruction. With a coffee and a notebook I started with some sketches.

Sketches

With 3d printing in mind I selected one design and created it in CAD, but I found it wanting. Instead of a side-by-side arrangement for the circuit boards I came up with a design where the boards are stacked.

Abandoned design Abandoned design

Final design Final design

Circuit board arrangement Circuit board arrangement

In all I think it took about twenty-six hours to print. I'm happy to say it fits together nicely.

Photo of working terminal 1 Photo of working terminal 2

I realised that this was wasted as just a terminal so I put a Pi 3b+ in there and installed the desktop environment. I put a ZX Spectrum emulator on and realised I'd neglected to a put a speaker in! Something for v2. For version two I'll probably make some of the corners softer by rounding them and make it snap together tighter.

Preventing SYSLOG spam

One of my Raspberry Pis has a problem. When connected to WIFI every few seconds two lines are added to my /var/syslog:

Mar 6 10:13:15 Pi dhcpcd[764]: eth0: Router Advertisement from...  

In this particular example I could fix this by disabling the IPv6 DHCP servive in my router, or disabling IPv6 on the Pi, but for the moment I want to simply keep these messages out of my syslog.

Happily, there's a nice syntax which allows us to add lines to the /etc/rsyslog.conf to filter lines sent to the syslog and prohibit them from being added.

In the case of the example above I added the following line near the top of the configuration file:

:msg, contains, "Router Advertisement from" stop

Then restart with sudo systemctl restart rsyslog and no more junk in the syslog!

sudo in .bashrc

Due to a quirk with the Raspberry Pi's current implementation of Debian I had some trouble mounting CIFS shares at start up. The solution was to run the mount command once logged in, the easiest way to do this is in the .bashrc script.

However! To run the mount -a command to mount all shares requires elevated privileges but I didn't want to have to type password twice at login. The solution to this is add the command itself to the /etc/sudoers with the NOPASSWD flag:

pi    ALL=(ALL)    NOPASSWD: /bin/mount  

One thing to note is that it's important to provide the full path to the command.

Raspberry Pi Waveshare TFT Trouble

In order to monitor a small Raspberry Pi 3 running as a server I bought a Waveshare 3.5" TFT touchscreen which connects through the GPIO pins.

I followed the instructions that came with it and all went well. It booted in to X and I could use the touchscreen without any further configuration. I don't need X as I'm likely just to run htop most of the time. This is where the problems started.

The Pi would show the boot process on the TFT then suddenly stop. After waiting a while I hit some keys and the screen moved, but didn't change. Seems the boot process was finished but I couldn't see it.

I tried everything I could think of. It wasn't until I hit ctrl-alt-f2 and saw a login prompt that things started to click. After much Googling I found myself looking at the /etc/rc.local file which contained the following conspicuous line:

fbcp &  

It turns out this command copies the framebuffer with a small delay (~25ms). I remmed out this line, rebooted and all was well.

I suspect if I wanted to load X I might need this line back, but for now I'm happy.