[FFmpeg-devel] [PATCH] av_get_delay

Michael Niedermayer michaelni at gmx.at
Thu Jun 30 17:41:24 CEST 2011

On Thu, Jun 30, 2011 at 04:33:02PM +0200, Nicolas George wrote:
> Le duodi 12 messidor, an CCXIX, Michael Niedermayer a écrit :
> > you seem to missunderstand this somehow.
> > when you have 2 streams, 2 muxers, one only video and one only audio
> > and you want to sync them but the video muxer tells you as delay
> > only 0seconds or 30seconds you wont get sync better than 30seconds and
> > thats really not good for a slideshow of lets say pictures in a museum
> > that are being commented.
> I believe the crux of the problem is this: there are two different possible
> meanings for the delay:
> - The data that is being output now is the data that I wrote <delay> ago.
> - If I write data now, it will be output in <delay>.

These are both bad actually.
the reason is they are non constant and that on a normal multitasking
OS the results will be unreliable because time can pass between 2
get delay calls or any get time call.

the obvious solution would be to
* Consider a media stream to be a continuous stream not made of samples
  or frames
* Return as delay the pair of (wallclock, current presented position in
  sufficeint high precission)

The advnatage is that the (correctly scaled) difference between these
2 would be truly constant up to the drift of the (sound/video)
device clock and the system clock.

So the timing of when to do the call becomes irrelevant.
and AV sync can be achived by doing such a call for video and one for
audio and then compensating either stream by the difference. And that
works even when the 2 calls are done some time appart.

a muxer that has no native capability to obtain such a time pair
exactly could still use what it has + a call to get the wall clock.
it would be less accurate but not worse than doing seperate calls


Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110630/549efc22/attachment.asc>

More information about the ffmpeg-devel mailing list