Synchronize video on multiple clients as accurately as possible? Synchronize video on multiple clients as accurately as possible? ajax ajax

Synchronize video on multiple clients as accurately as possible?


The most accurate way would probably be to use sockets: this way you can signal to other systems what is required and don't need to wait for ajax polling. You won't be able to exactly compensate for latency, but could average things out by measuring the round trip with some test messages.

So the plan would be:

  1. all clients pre-load video ready to roll
  2. all clients open socket to server and indicate they are ready to rumble
  3. server runs some quick test messages to measure latency.
  4. server sends the "go" message to all clients, possibly delaying to account for latency (or indicate the time for the client to pause instead; either way works)
  5. if a client stops, it send message to server; server immediately send message to another clients to stop.
  6. clients reply with where they are paused
  7. When restarting, adjust the start messages to account for both latency and the fact some clients are paused fractionally later.

I used something very similar to sync 18 projectors across 3 cars for an AV display system. (https://vimeo.com/97191170). Despite Xorifelse's comments in his answer, PHP was perfectly capabale of receiving, processing and handling up to 100 sockets commands per second from a controller (jquery based application in a browser, connected by sockets), filtering out duplicates, logging them all to mySQL for a second process to poll on demand (approx 10 times per second, triggered by socket request from a Flash (Adobe Air) script and then also passed on light instructions to under-car lighting (also through sockets) or to other cars (also through sockets). In fact, the PHP/MySQL solution was far more robust than trying to pump socket instructions directly into Flash. It's very possible. Tech details for the project are here: http://labs.soapcreative.com/cars-that-feel-vivid-sydney/


I suggest to to NodeJS and sockets programming to implement. Further you can use http://www.webrtc.org


Have you tried using WebRTC, it is used for peer to peer connections, and for streaming as well. Using WebRTC you can make multy stream from one client to others, I have used it to stream videos to other people, and everyone that connects is getting the video, but I am not streaming it server does, I was only controlling the video, pause, sound, .....

You can try using it, but in your case every client can control the stream. Personally I have no tried something like that, but this way you have no issues regarding latency, pauses, and so on.