[FFmpeg-devel] [PATCH] ALSA for libavdevice
Mon Dec 15 15:01:46 CET 2008
Le quintidi 25 frimaire, an CCXVII, Reimar D?ffinger a ?crit?:
> Hm. The problem I see with that is that you have a sample rate, and you
> can count the number of samples. This gives you a time.
> As you say it, there is also another time.
> What happens when those times diverge? If it is based on some real-time
> clock they can easily diverge by 10 - 20 %, with regular "resets" (the
> timing base frequencies of both PCs and soundcards can be truly bad).
The fact that these times will diverge is precisely the reason why we also
need the system time.
Suppose we are recording something from an ALSA microphone and a
video4linux2 camera: if the sound card is 2% faster and the camera is 3%
slower than they sould be with regard to real-world time, and if we only use
the theoretical timestamps (number of samples or frames), the video and
audio will very quickly be completely out of sync.
We absolutely need a common source of timestamps for all streams. The most
obvious solution is to use the sample count from the audio to set the
timestamps of the video, but I do not think ffmpeg allows that. Furthermore,
this is not suitable if there are several sound cards, for example for live
streaming: if the playback card is slower than the recording one, it will
> If this divergence ends up in the encoded file, is it certain that most
> (all?) players can interpret/handle it right?
As far as I understand, ffmpeg with its default settings do not let these
timestamps into the output file, so this is not a problem.
As for the library, the point is that it is necessary to fix the lack of
accuracy in the real-world timers, but the best place to fix things depends
on the situation. Therefore, all the library can do is provide the useful
information (real system time of the samples), and let the software decide
what to do with it (which may be ignoring it) and how.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 197 bytes
Desc: Digital signature
More information about the ffmpeg-devel