# 这可能是最详细的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

### 推荐阅读更多精彩内容

• 国家电网公司企业标准（Q/GDW）- 面向对象的用电信息数据交换协议 - 报批稿：20170802 前言： 排版 ...
庭说阅读 7,004评论 6 13
• 最近看到一篇关于CMTime的文章，感觉讲得通俗易懂，就想着翻译一下，我尽量在语义正确的情况下按照原著来翻译，原文...
鐵甲陳小寶阅读 4,763评论 3 7
• 教程一:视频截图(Tutorial 01: Making Screencaps) 首先我们需要了解视频文件的一些基...
90后的思维阅读 3,337评论 0 3
• 江梅梅找出放在玫瑰中的卡片，上边写着：“祝梅梅天天开心”，落款是YH,她无奈的笑了笑，这是马一鸿送来的，心中却有一...
默默幽幽阅读 76评论 0 0
• 今天的太阳， 像瘫痪的卡车， 在遍布沙粒的荒野， 扯着喉咙不能唱歌。 阴郁盗取了灵魂， 树叶挤出欢乐。 许多昏暗重...
暮雨激潭阅读 73评论 0 6