Way back in 2006, Andy Wingo wrote some small scripts for GStreamer 0.10 to demonstrate what was (back then) a fairly new feature in GStreamer – the ability to share a clock across the network and use it to synchronise playback of content across different machines.
Since GStreamer 1.x has been out for over 2 years, and we get a lot of questions about how to use the network clock functionality, it’s a good time for an update. I’ve ported the simple examples for API changes and to use the gobject-introspection based Python bindings and put them up on my server.
To give it a try, fetch play-master.py and play-slave.py onto 2 or more computers with GStreamer 1 installed. You need a media file accessible via some URI to all machines, so they have something to play.
Then, on one machine run play-master.py, passing a URI for it to play and a port to publish the clock on:
./play-master.py http://server/path/to/file 8554
The script will print out a command line like so:
Start slave as: python ./play-slave.py http://server/path/to/file [IP] 8554 1071152650838999
On another machine(s), run the printed command, substituting the IP address of the machine running the master script.
After a moment or two, the slaved machine should start playing the file in synch with the master:
If they’re not in sync, check that you have the port you chose open for UDP traffic so the clock synchronisation packets can be transferred.
This basic technique is the core of my Aurena home media player system, which builds on top of the network clock mechanism to provide file serving and a simple shuffle playlist.
For anyone still interested in GStreamer 0.10 – Andy’s old scripts can be found on his server: play-master.py and play-slave.py