I have a live stream, and CMSampleBufferGetSampleTimingInfo
gives a duration with CMTime(value=0, timescale=0)
for video.
For audio, I get 1024 samples at once, but CMSampleBufferGetSampleTimingInfo(sampleBuffer, index, &timingInfo)
gives the exact same presentationTimeStamp for every single index in the sample.
How can I accurately get duration info during a live stream for video frames, and how can I get the actual time of an audio sample in a CMSampleBufferRef
?
You can only rely on presentationTimeStamp
s, so you can't know the duration of the current video frame until the next frame arrives. This makes sense for a live stream, as capture frame rates are variable and depend on lighting, etc, but this also seems to be true when the sample buffers come from a file.
The duration can be calculated like so:
CMTimeSubtract(timingInfoNext.presentationTimeStamp, timingInfoCurrent.presentationTimeStamp)