1

I am helping friend of mine with her exhibition in video arts. Right now her concept requires 6 Beamers to loop videos, distributed over three floors in an relatively large building, with one PI per Beamer. (Even more are planned)

Additionally the video playback has to start simultaneously.

My Idea was to connect all of such PIs within a WIFI network and use pssh to execute the start command on all of them in parallel. So I used this script to configure one "master" PI which creates the network and a bunch of other "slave" PIs which automatically connect to that network (WLAN). The master PI can access the slaves using ssh keys. So the final command I used for testing was:

parallel-ssh -l pi -h hosts.txt -- omxplayer test.mov

Whereby hosts.txt contains all the ip adresses of all slaves including the one of the master.

Unfortunately the playback does is delayed, by about 0.5 - 0.75 sec for the "slaves". So my question is:

  • Would it be better to use a dedicated router?
  • would a script which establishes the ssh connection first and then executes the start command be better? If so, how could that be done? Would something like screen be able to do the job?

UPDATE

Due to the comments: Ideally "simultaneously" would mean no delay here, but since all the networking and computation will take time, the delay should be as small as possible with the given setup.

philipp
  • 193
  • 2
  • 11

2 Answers2

3

You could use MQTT and use publisher(server) and subscribers(clients). core-electronics.com.au have a very good tutorial and video there also. On the publisher you could have a Realtime clock and periodically send the time out, then a "play video" command to start at a given time ie 2 seconds away to make sure they all received the command before video starts.

Dr.Rabbit
  • 1,018
  • 6
  • 10
2

To do this simultaneously you probably need to assume each Pi has a common time reference. If they are networked one can assume that they may all be synced to network time.

Rather than propagating a do now command which will be subject to random network delays I would send a do at time X command, where X is some time in the future (say 60 seconds). E.g. do at 1.00 p.m. Each Pi could then do a busy spin waiting on that time to arrive to execute the command. That method should eliminate random network delays.

joan
  • 71,024
  • 5
  • 73
  • 106
  • That is a good Idea, I have also thought about that. Those PIs wont have internet access, so NTP wont work except I can manage to setup the master as Time server. – philipp Sep 30 '17 at 09:25
  • See https://raspberrypi.stackexchange.com/questions/24338/how-to-control-multiple-raspberry-pis-at-once-over-ethernet It's pretty much your question. I give some example MQTT scripts if you decide to go that route. – joan Sep 30 '17 at 10:44
  • The suggestion with the common time frame will be my next optimization! – philipp Oct 02 '17 at 17:28
  • Actually I could set this up using ntp. – philipp Mar 28 '19 at 10:31