Synced video with Raspberry Pis and omxplayer-sync

You need at least: a couple of Raspberry 3 Model B boards, power supplies with at least 2,5A or 3A power, micro SD cards, HDMI cables, Ethernet cables. And a network router (i.e. an old home Wifi router/broadband modem).

We're using https://github.com/turingmachine/omxplayer-sync. Have a go at installing it on a fresh Raspbian Lite image. If there's no time, as usual, and you decide to trust an operating system image found on the web:

Download the preconfigured Raspberry Pi image: https://www.khm.de/~sievers/omxplayer-sync-02.gz
Note that this image contains an outdated (July 2017) version of omxplayer-sync (to use the newer code, install everything yourself using the github link above) and that this image won't run on a Raspberry Pi 4 (actually, it may possibly only run on a Raspberry 3 Model B or B+).

Clone the Raspberry Pi image to an SD card by following i.e. these instructions.

Once cloned, put it all together and connect the Raspberries to the home router, so that they get an IP address and find each other on the network. (It needs to be a router, not just a network switch. Routers such as a Fritz!Box are usually set to hand out IP addresses to all connected devices. They supply what is called a DHCP service.) (Alternatively, give your Raspis static IPs on the same subnet, i.e. 192.168.0.2 // 192.168.0.3 // 192.168.0.4. Then it should be OK to just use a network switch.)

By default a Raspberry flashed with the above omxplayer-sync image file is set to be a slave. Bees are all plain workers by DNA unless they make one of them queen. So you have to 1. make one of them a master. 2. And you have to upload your video files.

1.

Find the Raspberry that you want to make the master on the network (your router might help) and ssh into it, i.e.

ssh pi@192.168.0.2

username is pi and password is still the default "raspberry"

Edit the omxplayersync.service file with the nano editor. (nano is a simple text editor that lets you create and edit text files. Exit and save with CTRL-X, confirm with CTRL-Y). Open the file with

sudo nano /etc/systemd/system/omxplayersync.service

Find the line that says

ExecStart=/usr/bin/omxplayer-sync -luvb /home/pi/video.mp4

and change -luvb to -muvb

ExecStart=/usr/bin/omxplayer-sync -muvb /home/pi/video.mp4

now this one Raspberry is the master that broadcasts a message to all the other Raspis on the network and tells them at which position of the video they should start playback.

Also it's a good idea to give the whole system some time after boot before playback, so that the Raspberries can find each other on the network. The easiest way to do that is to edit the rc.local file.

sudo nano /etc/rc.local

Add this line just after # Print the IP address to let it wait 20 seconds.

sleep 20

2.

On all Raspberries run

sudo raspi-config

and expand the filesystem to make room for your video file (this is done automatically on later versions of the operating system). Then delete the video.mp4 file that's played by default and upload your own video file. Name it exactly video.mp4. It needs to have the same name on all Raspberries.

It's easiest to do this with an SFTP program like Cyberduck (Mac) or FileZilla (PC) (Both are free. I personally like Transmit for Mac).

It should be an mp4 file, h.264 encoded with no more than around 10 or 12 mbit bandwidth. Constant framerate and constant quality. Handbrake seems to be a good encoder for this.

-> Networkings workshop