gpt4 book ai didi

ios - Swift - 从 CMSampleBuffer 获取 kCMSampleBufferAttachmentKey_DroppedFrameReason

转载 作者:可可西里 更新时间:2023-11-01 01:18:07 24 4
gpt4 key购买 nike

我想了解为什么我的 AVCaptureOutput 丢帧。在 captureOutput(_ output: AVCaptureOutput, didDrop sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) 委托(delegate)方法中,我得到一个 CMSampleBuffer 应该包含一个解释框架原因的附件已删除 ( doc )

原因预计是这些 CFString 之一:

kCMSampleBufferDroppedFrameReason_FrameWasLate // "FrameWasLate"
kCMSampleBufferDroppedFrameReason_OutOfBuffers // "OutOfBuffers"
kCMSampleBufferDroppedFrameReason_Discontinuity // "Discontinuity"

从文档中确实不清楚如何获取此值。我试过使用 CMGetAttachment 但这会返回一个 CMAttachmentMode 又名 UInt32:

func captureOutput(_ output: AVCaptureOutput, didDrop sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {
var reason: CMAttachmentMode = 0
CMGetAttachment(sampleBuffer, kCMSampleBufferAttachmentKey_DroppedFrameReason, &reason)
print("reason \(reason)") // 1
}

而且我真的不知道如何将这个 UInt32 与 CFString 常量相匹配

最佳答案

我愚蠢地没有看到正确的输出:

var mode: CMAttachmentMode = 0
let reason = CMGetAttachment(sampleBuffer, kCMSampleBufferAttachmentKey_DroppedFrameReason, &mode)
print("reason \(String(describing: reason))") // Optional(OutOfBuffers)

关于ios - Swift - 从 CMSampleBuffer 获取 kCMSampleBufferAttachmentKey_DroppedFrameReason,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45336425/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com