orchetect/TimecodeKit

Negative rational values

Closed this issue · 2 comments

In Final Cut Pro XML (FCPXML) it's possible to encounter "negative" time values.

<chapter-marker start="14417/4s" duration="100/2400s" value="Chapter 1" posterOffset="-80163/720000s"/>

In this case, a chapter marker inserted on a clip has a thumbnail location (posterOffset) that is earlier on the timeline than the marker's position. It's expressed as the delta distance (offset) from the marker's position. In this case, with an additional negative "-" sign prior to it.

This would be formed in TimecodeKit by constructing Fraction(-80163, 720000)

Timecode should be able to process negative rational times and return an instance of TimecodeInterval in the event the time is negative.

  • Fraction needs isNegative, negate() and negated()
  • Timecode rational inits need inline docs updated to clarify that negative fractions are possible but may throw an error
  • TimecodeInterval needs init from Fraction
  • TimecodeInterval needs rationalValue property
  • Fraction extension could use toTimecodeInterval category method

Done. Will be in 1.6.3 release.