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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#!/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:

1
2
3
4
5
6
7
#!/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.