Home CAVE-MPlayer

Mon Nov 12 21:02:21 CET 2007


CAVE-MPlayer (formerly "cmplayer") is a patch for MPlayer which lets you synchronise several players running on several computers connected to a dedicated LAN.

So, every host will load a movie from its internal storage media, and all of them will be played at the same speed, i.e., all of them will start at the same moment and after some time, all of them will have played the same number of frames at a fixed framerate.

Applications include:

Note:There is already some unrelated projects named "cmplayer":

so I had to choose a different name: cave-mplayer.

Note: Since 2010, Jason Holt <jholt [at] google.com> patches for UDP network synchronization were included in mplayer code, so CAVE-Mplayer is no longer needed.


Working. Not too much tested.

Alpha status. Mostly for developers.

Feedback welcome!.


Should work on any Linux/Unix system, tested on:

How it works:

First, you need to get the system clocks of all of your computers synchronised. I'd sugest to use NTP for this purpose.

According to my experiments, using NTP, gettimeofday() returns differences below 40 ms; which is good enough for the usual 25 fps movies:

    # sec:usec = 1069231417:653136
    # sec:usec = 1069231417:653433
    # sec:usec = 1069231417:656074
    # sec:usec = 1069231417:653073
    # sec:usec = 1069231417:653663
    # sec:usec = 1069231417:653664

Then, you need a modified mplayer which can:

So, in short, cave-mplayer project patches mplayer so it will be able to behave this way.

The cave-mplayer session:

We will use a computer as "master". This computer will take care of


    master                          slave1  slave2   ...  slaveN

    runs cmplayers

    runs remote mplayer --- rsh --> mplayer1    mplayer2    mplayerN

        |                               |           |           |

    [cmplayers waits]  <-- [ready tcp/ip packet ]
        |              <----------------------- [ready tcp/ip packet ]
        |              <------------- [ready tcp/ip packet ]
        |                               |           |           |
    we have N answers                   |           |           |
    so cmplayers exits                [wait]      [wait]      [wait]
        |                               .           .           .
    runs cmplayerc                      .           .           .
        |                               .           .           .
        ---[ start TCP/UDP bcast ] -->----------->----------->
                                        |           |           |
                             <------             |           |
    [ OK || Too Late answer ]<-------------------            |
        |                               |           |           |

    cmplayerc exits                   [play]      [play]      [play]


Before the "READY" packet, the "mplayer" instance has its movie loaded and ready to play.

So, when the master gets "N" answers, it broadcasts a "start" command which includes the start date, computed as the next second boundary unless the difference is less than 0.5 sec, if this is the case, another second will be added.

When every "mplayer" instance receives the "start" command, compares the start time with current time, and returns "OK" or "Too Late" packet.

If is ok, "mplayer" will wait for start time, and then is will play the file.



This patch will make mplayer open a network port (when "-udp" option is used), and no access control is done on it; so, you should use this only on trusted networks.

The same applies to "cmplayers" auxiliar program


Used in:

See also:

e-mail: spd@daphne.cps.unizar.es