1

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

  • hh:mm:ss.fraction
  • frames

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?

iter
  • 4,171
  • 8
  • 35
  • 59

1 Answers1

2

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:

  • FFFFFFF - Frames only (this can be as big as you want)
  • SS:FF - Second and frame (non-drop frame)
  • HH:MM:SS:FF - Hour, minute, second, frame (non-drop frame)
  • HH:MM:SS;FF - Hour, minute, second, frame (drop frame)
Brian
  • 1,200
  • 6
  • 8
  • Thank you @Brian. The link to source is very helpful. The function you link to, `time_clock_to_frames()`, appears to assume the input is in seconds. Another function in the same file, `mlt_property_atoi()`, has logic to chose between SMIL (if input contains `':'`) and SMPTE. Does this mean that when I specify a raw integer for an `in` attribute, the code runs it through the SMPTE parser, and that no code path ever parses SMPTE values with colons, i.e. `HH:MM:SS:FF`? – iter Jan 18 '18 at 15:26
  • 1
    I updated my answer with some information about SMPTE timecodes. I think you read the code wrong. If a decimal point or comma is found, then it is parsed as SMIL time, otherwise it is parsed as SMPTE timecode – Brian Jan 18 '18 at 19:38