[FFmpeg-devel] Samples frames and PTS inter/extrapolation
Michael Niedermayer
michaelni at gmx.at
Sun Jul 1 16:39:41 CEST 2012
On Sun, Jul 01, 2012 at 11:23:08AM +0200, Nicolas George wrote:
> Hi.
>
> I am considering the problem of computing the timestamps of frames when
> samples have to be re-grouped in a different pattern. For example, if we
> have frames with 384 samples as input and want 960 samples as output, we may
> be in this situation:
>
> 384 + 384 + 384 + 384 = 320 + 64 + 384 + 384 + 128 + 256
> in1 in2 in3 in4 prv --------out--------- nxt
>
> The code I wrote for lavfi two days ago does:
>
> out.pts = in1.pts + rescale(320, 1/sample_rate, time_base)
>
> The corresponding code from libav does:
>
> out.pts = in4.pts - rescale(64 + 384 + 384, 1/sample_rate, time_base)
>
> If the PTS do not match the number of samples exactly, it will give a
> different result.
>
> Since out.pts is the timestamp of the beginning of out, I believe using the
> timestamp of the first input frame, the one that gave the beginning, is more
> logical.
>
> But if there is a constant error ratio between PTS and samples, the rescale
> is wrong.
>
> What I think may be right: interpolating between in1.pts and in2.pts:
>
> out.pts = in1.pts + rescale(320, 1/384, 1/(in2.pts-in1.pts)
>
> If I do not have in2.pts (because in1 was large enough to provide the whole
> frame and more; or if it is absurd or undefined), I can use
> in1.pts+in1.duration.
interpolation has to be used carefully because of timestamp
discontinuities and possibly damaged timestamps.
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad
-------------- 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/20120701/1b9b651b/attachment.asc>
More information about the ffmpeg-devel
mailing list