Synced video with Raspberry Pis and omxplayer-sync

Disclaimer: these are notes from 2017. This page is providing an outdated image for Raspberry Pi, containing an outdated (July 2017) version of omxplayer-sync. This image won't run on a Raspberry Pi 4 (actually, it may possibly only run on a Raspberry 3 Model B or B+). If it's simple, un-synchronized video that you need, use my continually updated videolooper package.

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. You might be better off installing the latest version of 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

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. Home/Wifi routers are usually set to hand out IP addresses to all connected devices. They supply what is called a DHCP service. If you know what you're doing, 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 "child". (Just like bees, who are all plain workers by DNA unless they make one of them queen.) Here are the instructions to 1. make one of them a "parent", or primary player. You'll also need to upload your video files (further down).

1. Make one of them the parent player

Find the Raspberry that you want to make the parent on the network (you could log on to your router to see all connected devices) 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 so that it reads

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

now this is the "parent" that broadcasts a message to all the other "children"-Raspis on the network and tells them at which position of the video they should start playback.

Give it some time

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. Upload your video files

ssh into all Raspberries and 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, but not on the supplied image).

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