This document describes the API for creating and manipulating
CMTime structs are non-opaque mutable structs representing times (either timestamps or durations).
CMTime is represented as a rational number, with a numerator (an
int64_t value), and a denominator (an
int32_t timescale). Conceptually, the timescale specifies the fraction of a second each unit in the numerator occupies. Thus if the timescale is 4, each unit represents a quarter of a second; if the timescale is 10, each unit represents a tenth of a second, and so on. In addition to a simple time value, a CMTime can represent non-numeric values: +infinity, -infinity, and indefinite. Using a flag CMTime indicates whether the time been rounded at some point.
CMTimes contain an epoch number, which is usually set to 0, but can be used to distinguish unrelated timelines: for example, it could be incremented each time through a presentation loop, to differentiate between time N in loop 0 from time N in loop 1.
You can convert
CMTimes to and from immutable CFDictionaries (see
CMTimeMakeFromDictionary(_:), for use in annotations and various Core Foundation containers.
Additional functions for managing dates and times are described in Time Utilities. Note that
CMTime is designed for media timelines whereas functions in
Time Utilities Reference are designed for working with wall-clock time in Core Foundation framework; see also AVFoundation Constants.