【发布时间】:2016-09-24 06:26:37
【问题描述】:
我与 AvFoundation 合作。我需要从 ios 相机准确测量帧速率。
算法:
帧速率 = 1/(time(f2)-time(f1)) = __ (每秒帧数);
其中 time(f2) – 第二帧的时间,(f1) – 第一帧的时间。 如何使用 sampleBuffer?
【问题讨论】:
标签: ios camera frame cmsamplebuffer
我与 AvFoundation 合作。我需要从 ios 相机准确测量帧速率。
算法:
帧速率 = 1/(time(f2)-time(f1)) = __ (每秒帧数);
其中 time(f2) – 第二帧的时间,(f1) – 第一帧的时间。 如何使用 sampleBuffer?
【问题讨论】:
标签: ios camera frame cmsamplebuffer
您需要致电CMSampleBufferGetPresentationTimeStamp(sampleBuffer)
这样的事情(很快,有点尴尬,因为我找不到CMTime 1/x):
let delta = CMTimeSubtract(CMSampleBufferGetPresentationTimeStamp(buf2), CMSampleBufferGetPresentationTimeStamp(buf1))
// awkward 1/x, beware that delta.value may overflow as a timescale
// what's the right way?
let frameRate = CMTime(value: CMTimeValue(delta.timescale), timescale: CMTimeScale(delta.value))
// maybe you want floating point instead of CMTime:
let frameRateAsFloat64 = CMTimeGetSeconds(frameRate)
【讨论】: