Skip to content

Sync video playback across multiple raspberry pi mini computers

License

Notifications You must be signed in to change notification settings

thomashollier/triptych

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Triptych

This allows you to sync video playback across multiple raspberry pi mini computers. Once this is properly setup, it is designed to be fairly simple to operate in a gallery type environment. One of the machines is designated as the master and the rest are slaves. When the program is launched on the master, it waits for all the slaves to come online, and when it is launched on a slave, it connects to the master and waits for instructions.

Hardware setup

All you need is raspberry pi each connected to a screen and to an ethernet hub. Plug a keyboard into the master machine. I've tested this with raspeberry pi2 B model. I've only used this on 3 hosts at once but it should work on any number of machines.

Keyboard controls during playback

The following controls are available from the master machine.
-space bar pauses/unpauses all the screens.
-'r' key rewinds all to the beginning
-'q' quits all the running programs
-'w' quits all programs and reboots all the machines
-'e' quits all programs and shuts down all the machines

Set up openframeworks on your raspberry pi

-Read this: http://forum.openframeworks.cc/t/raspberry-pi-2-setup-guide/18690
-This was compiled against 0.8.4
-Put ofxOMXplayer stuff in addons and make sure the directory is named ofxOMXplayer
-Add gpu_mem=384 in /boot/config.txt

Using the default settings

I've set things up to use a settings file that tells the program the machine names, the mode they are in, and the video files they each load. That's the playback_settings.xml file. As you can see, you don't have to call your machines pi1, pi2 and pi3 though if you do you will have to update all the files I mention above to reflect the new names.

Setup your host names

sudo vi /etc/hostname Change the hostname to pi2 for the second machine and pi3 for the third.

Setup the IP address of each host

sudo vi /etc/network/interfaces Set the desired IP on the "address" line (you will need to do this on all 3 machines if your network settings are different from mine)
auto lo
iface lo inet loopback

iface eth0 inet static address 192.168.11.45 netmask 255.255.255.0 gateway 192.168.11.1 network 192.168.11.1 broadcast 192.168.11.255

allow-hotplug wlan0 iface wlan0 inet manual wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf iface default inet dhcp

Setup your hosts file

sudo vi /etc/hosts Set the correct IP address for pi1, pi2, and pi3
127.0.0.1	localhost
::1		localhost ip6-localhost ip6-loopback
fe00::0		ip6-localnet
ff00::0		ip6-mcastprefix
ff02::1		ip6-allnodes
ff02::2		ip6-allrouters

192.168.11.45 pi1 192.168.11.46 pi2 192.168.11.47 pi3

Setup ssh keys

In order to be able to shutdown and reboot the slaves from the master machine, you need to setup ssh keys so you can connect back and forth between the machines without needing to enter a password.
First, on each machine:
rm .ssh/authorized_keys
then, go back to each machine and do this:
ssh-keygen -t rsa -C pi@pi2
cat ~/.ssh/id_rsa.pub | ssh [email protected] 'cat >> .ssh/authorized_keys'
cat ~/.ssh/id_rsa.pub | ssh [email protected] 'cat >> .ssh/authorized_keys'
Make sure the IP's in line 2 and 3 are the ones of whatever machines you are currently NOT logged into, and that the machine name in the first line is that of the machine you are currently logged in.

Install the media

Copy the movie files somewhere onto your SD cards and make sure the "filename" value in the xml file reflects the path.

Automatic startup at boot

Automatic login

Setup automatic login to the command line prompt during boot.
sudo vi /etc/inittab
#comment out the following line
#1:2345:respawn:/sbin/getty 115200 tty1
#add this line
1:2345:respawn:/bin/login -f pi tty1 /dev/tty1 2>&1

Using "screen"

I've been using the screen command to automatically start the process in its own shell at boot time. Add the following to the end of your .bashrc file:
if [ "$L1" == "tty1" ]
	then
	echo "about to launch..."
	sleep 1
	screen -S triptych -m /home/pi/bin/triptych
fi

Helper scripts

start_triptych, reboot_all, and poweroff_all are three utility scripts that allow the user to control all the machines at once from the master mahine.

Extra machine

While I set these up, I also usually connect another machine on the network so I can log into the various hosts to help with any setup issues.

To-do list

  • Right now, setup needs a copy of the same settings file and video clips on each machine. It would be good to only need those files on the master machine and have the binary send the data to the slaves as part of the automatic startup procedure.
  • Right now, the location of the settings file is hard coded. It would be good to have the ability pass it in as a command line argument.
  • It would be more efficient to use IP multicasting to communicate to all the salves at the same time rather than establishing individual unicast communication to each, but I don't know how to do that with OSC.

About

Sync video playback across multiple raspberry pi mini computers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published