大佬教程收集整理的这篇文章主要介绍了如何从iOS中的CMSampleBufferRef获取相机数据当前捕获的时间戳,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
(void) captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection
捕获CMSampleBufferRef,并将编码为H264格式,帧将使用AVAssetWriter保存到文件.
我遵循示例源代码来创建此应用程序:
http://www.gdcl.co.uk//2013/02/20/iOS-Video-Encoding.html
为此@R_667_10673@下事情
CMSampleBufferRef sample = [asset_reader_output copyNextSampleBuffer]; CMSampleBufferRef buffer; while ( [assestReader status]==AVAssetReaderStatusReading ){ buffer = [asset_reader_output copyNextSampleBuffer]; //CMSampleBufferGetPresentationtimestamp(buffer); CMTime presentationtimestamp = CMSampleBufferGetPresentationtimestamp(buffer); UInt32 timestamp = (1000*presentationtimestamp.value) / presentationtimestamp.timescale; NSLog(@"timestamp %u",(unsigned int)timestamp); NSLog(@"reading"); // CFRelease(buffer);
有没有办法获得帧捕获的时间戳,
我已阅读以下链接以获取时间戳,但它没有正确地阐述我的问题在How to set timestamp of CMSampleBuffer for AVWriter writing以上
更新
presentationtimestamp = fileFramePresentationTime + firstFrameCaptureTime
所以当从文件读取时,这应该计算你想要的捕获时间戳:
CMTime firstCaptureFrametimestamp = // the first capture timestamp you see CMTime presentationtimestamp = CMTimeAdd(CMSampleBufferGetPresentationtimestamp(buffer),firstCaptureFrametimestamp);
如果您在应用程序启动之间进行此计算,则需要对第一帧捕获时间进行序列化和反序列化,您可以使用CMTimeCopyAsDictionary和CMTimeMakeFromDictionary进行操作.
以上是大佬教程为你收集整理的如何从iOS中的CMSampleBufferRef获取相机数据当前捕获的时间戳全部内容,希望文章能够帮你解决如何从iOS中的CMSampleBufferRef获取相机数据当前捕获的时间戳所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。