Create a CMSampleBuffer from a CVPixelBuffer

后端 未结 1 1779
感情败类
感情败类 2021-01-13 18:10

I get a CVPixelBuffer from ARSessionDelegate:

func session(_ session: ARSession, didUpdate frame: ARFrame) {
    frame.capturedImage // CVPixelBufferRef
}


        
相关标签:
1条回答
  • 2021-01-13 18:41

    The sampleTiming mainly contains the presentationTimeStamp, You can easy create it by following codes:

    let scale = CMTimeScale(NSEC_PER_SEC)
    let pts = CMTime(value: CMTimeValue(frame.timestamp * Double(scale)),
                     timescale: scale)
    var timingInfo = CMSampleTimingInfo(duration: kCMTimeInvalid,
                                        presentationTimeStamp: pts,
                                        decodeTimeStamp: kCMTimeInvalid)
    
    0 讨论(0)
提交回复
热议问题