2
我想了解爲什麼我的AVCaptureOutput丟幀。在captureOutput(_ output: AVCaptureOutput, didDrop sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection)
委託方法,我得到的是應該包含一個附件解釋框架被丟棄的原因(doc)一CMSampleBuffer
Swift - 從CMSampleBuffer獲取kCMSampleBufferAttachmentKey_DroppedFrameReason
原因是預計這些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字符串常量