[FFmpeg-devel] [PATCH] libavdevice: JACK demuxer
Luca Abeni
lucabe72
Fri Feb 27 22:06:24 CET 2009
Olivier Guilyardi wrote:
[...]
>>> I have a simple question here: must the pts be absolute (number of seconds since
>>> the epoch) or can it be relative (for example 0 for the first audio sample).
>>> Luca you already told me it must be absolute, but I still have doubts about this.
>> If it is relative to the first audio sample, how do you synchronise with
>> a different stream (that does not know when this stream's first audio
>> sample is)?
>
> First, I suspect that ffmpeg already treats pts as relative, because when you
> start it, it prints "Duration: .., start: .., bitrate: .." for all of its input
> streams. With an avi file as input I get start: 0.0000, while with an oss input
> it prints an absolute epoch-based value (1235767507 or so).
I do not know what ffmpeg does, but it is not the only program using
libavformat. A program using libavformat for grabbing audio and video
needs absolute timestamps to synchronise them.
> However, when I use two inputs, one relative (a file) and the other absolute (a
> jack input for example), the audio and the video are in sync.
If you use a file and a live source, it's difficult to say what "in
sync" means... I am referring to a live audio source (alsa, or jack) and
a live video source (v4l2). This is the case where synchronisation is
more an issue.
> Second, to answer your question, some sort of syncing is just matter of
> substracting the start time (the time in the first AVPacket) from the pts in the
> subsequent packets. And of course adjust possible delays with -itsoffset.
Of course you can do that; but this means that for live sources you have
to "calibrate" this delay every time you start capturing...
> I'm not saying this is a good approach. I'm just trying to understand how it's
> (and must be) done in ffmpeg. So, absolute or relative?
Well, let's see Michael's opinion. If he says "relative" I'll trust him
but right now I believe that for live inputs timestamps are absolute.
Luca
More information about the ffmpeg-devel
mailing list