[Libav-user] Frame number
Michael Zucchi
notzed at gmail.com
Sat Jun 30 03:12:14 CEST 2012
I'm pretty sure you shouldn't use approximate numbers (floats or
doubles) for this.
There's a bunch of AVRational related and exact-precision arithmetic
functions in libavutil for this purpose. see libavutil/mathematics.h
libavutil/rational.h.
On 29/06/12 21:51, Hector Alonso wrote:
> 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));
>
> }
More information about the Libav-user
mailing list