【问题标题】:what methods of SampleBuffer do I must use for measurement of frame rate?我必须使用哪些 SampleBuffer 方法来测量帧速率?
【发布时间】:2016-09-24 06:26:37
【问题描述】:

我与 AvFoundation 合作。我需要从 ios 相机准确测量帧速率。

算法:

帧速率 = 1/(time(f2)-time(f1)) = __ (每秒帧数);

其中 time(f2) – 第二帧的时间,(f1) – 第一帧的时间。 如何使用 sampleBuffer?

【问题讨论】:

    标签: ios camera frame cmsamplebuffer


    【解决方案1】:

    您需要致电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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-06-23
      • 1970-01-01
      • 2014-03-23
      • 1970-01-01
      • 2018-01-26
      • 2023-03-11
      • 1970-01-01
      相关资源
      最近更新 更多