Contents

CMSampleBufferGetOutputPresentationTimeStamp(_:)

Returns the output presentation timestamp of a sample buffer.

Declaration

func CMSampleBufferGetOutputPresentationTimeStamp(_ sbuf: CMSampleBuffer) -> CMTime

Parameters

  • sbuf:

    The CMSampleBuffer being 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