[FFmpeg-devel] [PATCH] ffplay: more precise audio clock based on current time

Michael Niedermayer michaelni at gmx.at
Sun Aug 14 21:08:07 CEST 2011

On Sun, Aug 14, 2011 at 08:21:25PM +0200, Marton Balint wrote:
> Since SDL has no audio buffer fullness info, one can get a much precise audio
> clock based on the last time of the audio callback and the elapsed time since.
> To achieve this I introduced the audio_current_pts and audio_current_pts_drift
> variables (similar to video_current_pts and video_current_pts_drift) and
> calculate them in the end of the audio callback, when VideoState->audio_clock
> is already updated. The reference time I use is from the start of the audio
> callback, because this way the amount of time used for audio decoding is not
> interfereing with calculation.
> I also replaced the audio_write_get_buf_size function with a calculated
> variable because when the audio frame decoding is in progress audio_buf_size
> and audio_buf_index are not stable, so using them from other threads are not a
> good idea.
> ---
>  ffplay.c |   34 +++++++++++++++-------------------
>  1 files changed, 15 insertions(+), 19 deletions(-)

Is it possible to test this somehow to see the improvment?
also has this been tested with various -sync ?

Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In a rich man's house there is no place to spit but his face.
-- Diogenes of Sinope
-------------- 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/20110814/f8529e08/attachment.asc>

More information about the ffmpeg-devel mailing list