<!--
{
  "availability" : [
    "iOS: 4.1.0 - 27.0.0",
    "iPadOS: 4.1.0 - 27.0.0",
    "macCatalyst: 13.1.0 - 27.0.0",
    "macOS: 10.7.0 - 27.0.0",
    "tvOS: 9.0.0 - 27.0.0",
    "visionOS: 1.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVAssetReaderOutput/copyNextSampleBuffer()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVAssetReaderOutput(im)copyNextSampleBuffer"
  },
  "title" : "copyNextSampleBuffer()"
}
-->

# copyNextSampleBuffer()

Copies the next sample buffer from the output.

```
func copyNextSampleBuffer() -> CMSampleBuffer?
```

## Return Value

The output sample buffer, or `nil` if you’ve read all samples or an error occurs.

## Discussion

This method returns `nil` when you’ve read all available sample buffers, or if there’s an error. Check the value of the asset reader’s [`status`](/documentation/AVFoundation/AVAssetReader/status-swift.property) property to determine the reason.

The order of returned sample buffers depends on the output’s configuration. For a track output with a `nil` [`outputSettings`](/documentation/AVFoundation/AVAssetReaderTrackOutput/outputSettings) dictionary, the output skips decoding and returns sample buffers in decode order. Preserve that order when working with the encoded samples directly, such as when passing them to [`AVAssetWriter`](/documentation/AVFoundation/AVAssetWriter). When the output decodes the samples, it returns them in presentation order. Playback and downstream processing operate in presentation order, so decode order no longer matters after decoding.

---

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)