video-processingmlt

MLT time specification format


I'm looking for documentation on how MLT parses time specification strings. I see what appears to be two styles:

I think the number to the right of the decimal in m:s format is a fraction of a second, i.e., 1.5 at 24fps means 36 frames rather than 29. I'm looking for authoritative documentation. I haven't seen an answer here https://www.mltframework.org/docs/ though it's possible I'm looking right through it.

Separately, I'm curious how MLT rounds timespecs to the nearest frame. If my clip is 23.976 fps and I specify out=0:10, that works out to 239.76 frames. Does MLT round up, down or to the nearest integer?


Solution

  • There is an explanation of the time format here: https://www.mltframework.org/blog/time_properties/

    Your understanding is correct. If there is a decimal point, it represents fractions of seconds and would convert to frames as you described.

    MLT uses lrint to round the seconds to frames: https://github.com/mltframework/mlt/blob/master/src/framework/mlt_property.c#L334

    The default mode for lrint is "round to nearest".

    ADDITIONAL INFORMATION:

    MLT can also parse SMPTE timecodes. Timecodes are parsed from right to left with the right most value being frames: https://github.com/mltframework/mlt/blob/master/src/framework/mlt_property.c#L377

    Colon separators are used to separate different units. Also, Semicolon can be used to separate the frames field to indicate drop frame. Units can be excluded from the left side. Examples: