[MPlayer-dev-eng] [PATCH] Network synchronized playback using UDP
Uoti Urpala
uoti.urpala at pp1.inet.fi
Tue Mar 17 23:46:59 CET 2009
On Tue, 2009-03-17 at 14:46 -0700, Jason Holt wrote:
> I hacked in a simple mechanism to synchronize playback between multiple
> instances of mplayer over a network. The master sends a UDP datagram to
> announce its position in the video each time it plays a frame. The slaves
> check to see if they're within epsilon of the master. If they are, they
> just advance by a frame. If not, they seek to where the master is.
>
> This works out nicely because I can dynamically tweak frame rate, seek and
> pause on the master and the slaves all follow along.
>
> The patch is not compliant with your coding standards. Before I do that
> work, I wanted to make sure it's a patch you're interested in, and see if
> you have any particular guidance on things I should move or change.
Well I'm not sure if anyone else has a use for such functionality, and
it needs to touch central enough parts of the code that you can't just
harmlessly add it there and forget about it.
It could be implemented better, though exactly how depends on what your
goals are (how general it should be about working with all files etc).
Some problems I noticed reading through it:
- The UDP packets are sent without any real timing, at whatever point
the master finishes decoding the next frame. The clients base their
timing on the packets. So the client frame timing will not be accurate
even if network latencies are negligible.
- After you seek once the clients will lag one frame behind (they'll
seek one frame later). If there is a frame interval greater than the
0.15 seconds limit you used this can trigger extra seeks later.
- Since seeking only goes to keyframes, a seek does not necessarily
return a client to sync. A scenario like the following is possible: a
client is out of sync and seeks every frame. If the seeks go to the
nearest keyframe it'll keep seeking until the master arrives to 0.15
seconds before keyframe and the client is within the error window after
seeking to that. Now if the frame intervals vary a bit it's possible the
difference goes from 0.145 to 0.155 and the same seeking repeats again.
More information about the MPlayer-dev-eng
mailing list