简体   繁体   中英

How do I determine the duration of a sample buffer uses in an AVAssetWriter

I have a sample buffer that I'm using to capture video for an AVAssetWriter. I'm trying to figure out a way to determine how much video (time) I have captured. currently I am able to access the current buffer timestamp by using

CMTime pts = CMSampleBufferGetPresentationTimeStamp(sampleBuffer);

I'm looking for a way to determine the duration of the buffer, i've tried

CMTime dur = CMSampleBufferGetOutputDuration(sampleBuffer); but it seems to fluctuate 

between .002333 and nan for some reason

为什么不只为第一个样本保留一个时间戳,然后做一个非常简单的计算(最新的时间戳减去第一个)?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM