在captureOutput(_:didOutput:from :)处理程序中的AVCaptureVideoDataOutputSampleBufferDelegate中,我希望获得相对于mach_absolute_time()在缓冲区中记录第一个视频样本的时间。
这是对的吗?
func captureOutput(_ captureOutput: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {
if connection === _videoConnection {
var timeBaseInfo = mach_timebase_info_data_t()
mach_timebase_info(&timeBaseInfo)
samplebufferTime = CMClockConvertHostTimeToSystemUnits(CMSampleBufferGetOutputPresentationTimeStamp(sampleBuffer)) * UInt64(timeBaseInfo.numer) / UInt64(timeBaseInfo.denom)
}
}