Thank you, this is exactly the type of clear answer I was hoping for!

A couple follow-up questions:

  - I seem to be able to, with the calculation on line 371 linked below, get 
frame-inaccurate results, i.e. dropped or added frames. For example, with the 
simple timecode "01:01:00.1" at 23.976 fps: I think the un-rounded value should 
be 87754.5576, so I'd expect the rounded value to be either 87754 or 87755. 
However, it's 87753! [0] I think this may be caused by using "floor" for the 
hours and minutes, in combination with the fractional frame rate.

  - It seems `lrint` determines its rounding direction depending on values in 
the current environment. That seems to mean a user can also lose sample 
accuracy if, for example, `lrint` rounds one way on my machine and then a 
friend reads my .mlt file with a different rounding direction. Is this true?

Thanks,
Tom

[0] My code:

#include <stdio.h>
#include <math.h>

void main(void) {
   double fps = 23.976;
   int hours = 1;
   int minutes = 1;
   double seconds = 0.1;
   printf("%f\n", floor( fps * hours * 3600 ) + floor( fps * minutes * 60 ) + 
lrint( fps * seconds ));
}


On Sat, Aug 21, 2021 at 02:25:43AM +0000, Brian Matherly wrote:
>  > Am I correct that MLT translates from these clock times to frame numbers 
> and uses frame numbers for everything internally?
> Yes. "frame number" is often referred to as "position" in the code. I think 
> the two terms are used interchangably.
> >  How does rounding work?
> The code is 
> here:https://github.com/mltframework/mlt/blob/master/src/framework/mlt_property.c#L371
> It uses lrint() for rounding the seconds part.
> ~Brian
> 
>     On Thursday, August 19, 2021, 11:45:00 PM CDT, amindfv--- via Mlt-devel 
> <mlt-devel@lists.sourceforge.net> wrote:  
>  
>  From reading the "time properties" doc 
> (https://www.mltframework.org/blog/time_properties), it seems any number with 
> a radix is interpreted as a clock time - e.g. "00:00:00.5" means half a 
> second.
> 
> A couple questions:
> 
>   - Am I correct that MLT translates from these clock times to frame numbers 
> and uses frame numbers for everything internally?
>   - How does rounding work? If I'm working at 24fps, frame number 8 has clock 
> time 0.3333... and frame 9 has clock time 0.375. If I say "00:00:00.334", is 
> that identical to saying "00:00:00.374"? And thus "00:00:00.333" would refer 
> to the earlier frame 7? (I.e. the frame number is always rounded down?) Or is 
> there some other simple and consistent translation from these clock times to 
> frame numbers?
> 
> Thanks,
> Tom
> 
> 
> 
> _______________________________________________
> Mlt-devel mailing list
> Mlt-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mlt-devel
>   


_______________________________________________
Mlt-devel mailing list
Mlt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlt-devel

Reply via email to