在 iOS 中使用 CMSampleBufferGetPresentationTimeStamp 时如何创建 CMTime?它与系统正常运行时间有关吗?
How does the CMTime created when use CMSampleBufferGetPresentationTimeStamp in iOS? Is it related to systemUptime?
当我使用 CMSampleBufferGetPresentationTimeStamp 获取视频帧的呈现时间戳时:
CMTime pts = CMSampleBufferGetPresentationTimeStamp(sampleBuffer);
NSLog(@"pts: %+.3f", CMTimeGetSeconds(pts));
打印的时间戳不是从0开始,而是几乎等于[[NSProcessInfo processInfo] systemUptime]
。这是否意味着时间戳是通过 iOS 中较低的实现从 systemUptime 生成的?或者,如果不是,时间戳从何而来?
我认为它来自 mach_absolute_time()
iOS。
但是,您可以通过从所有缓冲区中减去第一个 CMSampleBufferGetPresentationTimeStamp(firstBuffer)
来使时间戳从零开始。
当我使用 CMSampleBufferGetPresentationTimeStamp 获取视频帧的呈现时间戳时:
CMTime pts = CMSampleBufferGetPresentationTimeStamp(sampleBuffer);
NSLog(@"pts: %+.3f", CMTimeGetSeconds(pts));
打印的时间戳不是从0开始,而是几乎等于[[NSProcessInfo processInfo] systemUptime]
。这是否意味着时间戳是通过 iOS 中较低的实现从 systemUptime 生成的?或者,如果不是,时间戳从何而来?
我认为它来自 mach_absolute_time()
iOS。
但是,您可以通过从所有缓冲区中减去第一个 CMSampleBufferGetPresentationTimeStamp(firstBuffer)
来使时间戳从零开始。