CMSampleBufferGetOutputPresentationTimeStamp(_:)
Returns the output presentation timestamp of a sample buffer.
Declaration
func CMSampleBufferGetOutputPresentationTimeStamp(_ sbuf: CMSampleBuffer) -> CMTimeParameters
- sbuf:
The
CMSampleBufferbeing interrogated.
Return Value
The output presentation timestamp of the CMSampleBuffer or kCMTimeInvalid if there is an error.
Discussion
The output presentation timestamp is the time at which the decoded, trimmed, stretched, and possibly reversed samples should start being presented. If CMSampleBufferGetOutputPresentationTimeStamp(_:) has been called to explicitly set the output PTS, CMSampleBufferGetOutputPresentationTimeStamp(_:) returns it. If not, CMSampleBufferGetOutputPresentationTimeStamp(_:) calculates its result as (PresentationTimeStamp + TrimDurationAtStart) unless kCMSampleBufferAttachmentKey_Reverse is kCFBooleanTrue, in which case it calculates the result as (PresentationTimeStamp + Duration - TrimDurationAtEnd). These are generally correct for un-stretched, un-shifted playback.
For general forward playback in a scaled edit, the OutputPresentationTimeStamp should be set to:
((PresentationTimeStamp + TrimDurationAtStart - EditStartMediaTime) / EditSpeedMultiplier) + EditStartTrackTime
For general reversed playback:
((PresentationTimeStamp + Duration - TrimDurationAtEnd - EditStartMediaTime) / EditSpeedMultiplier) + EditStartTrackTime
See Also
Inspecting Duration and Timing
CMSampleBufferGetDuration(_:)CMSampleBufferGetDecodeTimeStamp(_:)CMSampleBufferGetPresentationTimeStamp(_:)CMSampleBufferGetOutputDuration(_:)CMSampleBufferGetOutputDecodeTimeStamp(_:)CMSampleBufferSetOutputPresentationTimeStamp(_:newValue:)CMSampleBufferGetSampleTimingInfo(_:at:timingInfoOut:)CMSampleBufferGetSampleTimingInfoArray(_:entryCount:arrayToFill:entriesNeededOut:)CMSampleBufferGetOutputSampleTimingInfoArray(_:entryCount:arrayToFill:entriesNeededOut:)