CMTime,CMTimeMake CMTimeMakeWithSeconds

来源:互联网 发布:返利商城系统源码 编辑:程序博客网 时间:2024/05/17 21:56

  1. CMTime firstframe=CMTimeMake(1,10);  
  2. CMTime lastframe=CMTimeMake(10, 10);  

“CMTime可是專門用來表示影片時間用的類別,
他的用法為: CMTimeMake(time, timeScale)

time指的就是時間(不是秒),
而時間要換算成秒就要看第二個參數timeScale了.
timeScale指的是1秒需要由幾個frame構成(可以視為fps),
因此真正要表達的時間就會是 time / timeScale 才會是秒.”

上面的代码可以这么理解,视频的fps(帧率)是10,firstframe是第一帧的视频时间为0.1秒,lastframe是第10帧视频时间为1秒。

或者换种写法   CMTime curFrame = CMTimeMake(第几帧, 帧率)

看看另一篇博客的写法:http://blog.riaproject.com/objective-c/1745.html

这么看,

  1. CMTime firstframe=CMTimeMake(32,16);  
  2. CMTime lastframe=CMTimeMake(48, 24);  

这两个都表示2秒的时间。但是帧率是完全不同的。

关于帧率说一下题外话,通常帧率是多少呢?如下:

  1. <span style="font-family: 'Lucida Grande', Geneva, Helvetica, Arial, sans-serif; font-size: 14px; ">You frequently use a timescale of 600, since this is a common multiple of several commonly-used frame-rates: 24 frames per second (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.span>  

这个地方有说明http://developer.apple.com/library/mac/#documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/05_MediaRepresentations.html#//apple_ref/doc/uid/TP40010188-CH2-SW1

CMTimeMakeWithSeconds 和CMTimeMake 区别在于,第一个函数的第一个参数可以是float,其他一样。