[Libav-user] Frame number

Hector Alonso halonso at vpod.tv
Fri Jun 29 14:21:53 CEST 2012


Hi,
I've made myself one LibAvUtils class with this two functions implemented
like this:


int64_t LibAvUtils::frameNumberToPts(uint uiFrameNum, float fFps)

{

    if (fFps <= 0) return 0;

    return (int64_t)uiFrameNum * (int64_t)(((float)AV_TIME_BASE) / fFps);

}

 //-----------------------------------------------------------------------------

 uint LibAvUtils::ptsToFrameNumber(int64_t iPts, float fFps)

{

    if (fFps <= 0) return 0;

    return (uint)(iPts / (((float)AV_TIME_BASE) / fFps));

}


You will have to get a good calculation of the FPS by using the
time_base from each stream, as they will probably have different
units.


pts = Presentation Time Stamp or the moment this frame (or first
sample of the chunk if it is an audio packet) must be presented.

dts = Decoding Time Stamp or the moment this frame must be decoded
(have a look to Key,P and B frames and you will understand it better)


In some audiostreams, these parameters are not filled enterily, so
you'd better use the dts.

Any way, I think you should study Dranger's tutorial:
http://dranger.com/ffmpeg/tutorial01.html





On Fri, Jun 29, 2012 at 12:11 PM, Kalileo <kalileo at universalx.net> wrote:

>
> On Jun 29, 2012, at 15:00 , Jonas Elofsson wrote:
>
> > Hi,
> >
> > Thanks. I guess this means "pts"?
> >
> > I have no time to check again at the moment, but I did some tests with
> this as well.
> >
> > The video I tested with reported 25 frames per second and the timebase
> 1/25. Shouldn't this give me the pts 1,2,3,4... etc for each frame?
>
> No.
>
> > Instead i got (if my memory serves me right) 1200, 2400 etc (step of
> 1200 for each frame). Is there some documentation describing the FFMpeg
> timebase system?
>
> Have a look at the famous Dranger player example, there is a nice
> explanation how its is calculated.
>
>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20120629/321459ec/attachment.html>


More information about the Libav-user mailing list