[MPlayer-dev-eng] Adding threaded functionality to mplayer NODAEMON

James Courtier-Dutton James at superbug.demon.co.uk
Mon Sep 13 11:27:04 CEST 2004


Attila Kinali wrote:
> 
> 
>>Mplayer is a wonderful tool as is now, but I found a big inconvenience
>>when playing real time streams (DVB, in my case). Mplayer is always
>>too fast and empties the buffers or too slow and overflows the buffers.
> 
> 
> Hmm.. now that's an interesting problem.
> 
> 
>>I hacked a simple solution here: I monitor the cache buffers fill status
>>and skip audio sample to go faster or play audio samples twice to go slower,
>>keeping the cache at near costant level. The implementation is
>>a hack, the quality of audio is compromised and it is conceptually wrong
>>(think about VBR streams), but I solved my problem with a few lines of code
>>and I'm able to play from /dev/dvb/adapter0/dvr0 reliably.
>>(the recent patch involving faster/slower playback may help solving
>>this in a better way)
> 
> 
> Is it possible to extract a clock from the DVB stream, w/o relying on
> the bandwidth ? If so, this should be used to adjust MPlayer's
> reference. Ie implementing a PLL in software.
> 
> 

The solution to playing DVB streams without any skips, is to recover the
system clock (metronome) from the DVB stream.
All current set top boxes do this. I don't think xine does this yet, and
it appears that mplayer also does not do it.
All servers that transmit video over DVB or IP networks should include a
time stamp on each packet, with that time stamp being the contents of
the servers system clock (metronome). For DVB MPEG streams this is
called the SCR.
The client then has to take those time stamps, average them out, and
correct the clients system clock to get it to match the server's clock.
Algorithms similar to ntpd should be fine for this.
DVB PCI cards should do clock recovery in hardware, and it would then
just be a matter of getting mplayer to use the clock on the DVB card as
a reference.
The next problem is the video output device. E.g. Computer monitor, or TV.
Set top boxes run the TV output from the DVB system clock.
On PCs, I have not yet seen a video card where one can get it to sync to
the DVB system clock. On PCs, the TV output just tends to free run.
A Computer screen is not such a problem, as it is refreshed much more
often than a TV so one can do frame rate adjustments on it.

It is a shame that the requirement for different PCI cards to sync up
clocks was not designed into the PCI and PCI-X standards.
It would certainly have helped when trying to get two audio cards in
sync, and now when one really wants the DVB and Video card to be in
sync, one can't.

James





More information about the MPlayer-dev-eng mailing list