<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreMedia",
  "identifier" : "/documentation/CoreMedia/CMSampleBufferGetOutputPresentationTimeStamp(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Media"
    ],
    "preciseIdentifier" : "c:@F@CMSampleBufferGetOutputPresentationTimeStamp"
  },
  "title" : "CMSampleBufferGetOutputPresentationTimeStamp(_:)"
}
-->

# CMSampleBufferGetOutputPresentationTimeStamp(_:)

Returns the output presentation timestamp of a sample buffer.

```
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(_:)`](/documentation/CoreMedia/CMSampleBufferGetOutputPresentationTimeStamp(_:)) has been called to explicitly set the output PTS, [`CMSampleBufferGetOutputPresentationTimeStamp(_:)`](/documentation/CoreMedia/CMSampleBufferGetOutputPresentationTimeStamp(_:)) returns it. If not, [`CMSampleBufferGetOutputPresentationTimeStamp(_:)`](/documentation/CoreMedia/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`

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)