[Libav-user] Frame number

Jonas Elofsson jelofsson at gmail.com
Tue Jul 3 11:53:54 CEST 2012


Hi,

This is most helpful, thanks a lot! I whish I had more time for this
project...

Best regards, Jonas

On Sat, Jun 30, 2012 at 3:12 AM, Michael Zucchi <notzed at gmail.com> wrote:

>
> 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));
>>
>> }
>>
> ______________________________**_________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/**listinfo/libav-user<http://ffmpeg.org/mailman/listinfo/libav-user>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20120703/c6586351/attachment.html>


More information about the Libav-user mailing list