# 这可能是最详细的CMTime教程

``````    Float64 seconds = 5;
int32_t preferredTimeScale = 600;
CMTime inTime = CMTimeMakeWithSeconds(seconds, preferredTimeScale);
CMTimeShow(inTime);
``````

``````int64_t value = 10000;
int32_t preferredTimeScale = 600;
CMTime inTime = CMTimeMake(value, preferredTimeScale);
CMTimeShow(inTime);
``````

OK，以上其实理解起来没问题，但是当我们在处理视频的时候，常常要把后面的`timeScale`写成600：

``````let sTime = CMTime(seconds: starSeconds, preferredTimescale: 600)
``````

CMTime
is a C structure that represents time 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. You frequently use a timescale of 600, because this is a multiple of several commonly used frame rates: 24 fps for film, 30 fps for NTSC (used for TV in North America and Japan), and 25 fps for PAL (used for TV in Europe). Using a timescale of 600, you can exactly represent any number of frames in these systems.

### CMTime

``````  typedef struct
{
CMTimeValue    value;
CMTimeScale    timescale;
CMTimeFlags    flags;
CMTimeEpoch    epoch;
} CMTime;
``````
``````  public typealias CMTimeValue = Int64
public typealias CMTimeScale = Int32
``````

#### timescale

``````CMTime interval = CMTimeMakeWithSeconds(0.5, 1);
``````

#### timescale只是为了保证时间精度而设置的帧率，并不一定是视频最后实际的播放帧率。

Understanding CMTime