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.

1
  • You have not defined your problem; What does "simultaneously" mean? 1µSec, 1mSec or 1Sec. – Milliways Sep 30 '17 at 5:56
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.

5
  • Thanks for the answer! Unfortunately that seams to be a .net library what I am not familiar with. I would prefer a solution with bash – philipp Sep 30 '17 at 7:25
  • 1
    no its not a .net. I use it with python, it runs on a bunch of stuff. Watch the video at core-electronics, 10mins trust me. – Dr.Rabbit Sep 30 '17 at 7:28
  • turns out to be really cool stuff! I will give it a shot! – philipp Oct 1 '17 at 18:42
  • Thanks, that was definitely a good advise which brought me on the right way! – philipp Oct 2 '17 at 17:27
  • yeah its awesome stuff hey! – Dr.Rabbit Oct 3 '17 at 9:28
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.

4
  • 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 9:25
  • See raspberrypi.stackexchange.com/questions/24338/… 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 2 '17 at 17:28
  • Actually I could set this up using ntp. – philipp Mar 28 '19 at 10:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.