<!--
{
  "availability" : [
    "macOS: 10.10.0 - 13.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVSampleBufferGenerator/createSampleBuffer(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVSampleBufferGenerator(im)createSampleBufferForRequest:"
  },
  "title" : "createSampleBuffer(for:)"
}
-->

# createSampleBuffer(for:)

Creates a new sample buffer reference for the specified buffer request.

```
func createSampleBuffer(for request: AVSampleBufferRequest) -> CMSampleBuffer?
```

## Parameters

`request`

The sample buffer request.

## Return Value

Returns a new `CMSampleBufferRef`.

## Discussion

It is an error to use an `AVSampleBufferRequest` object with mode set to `AVSampleBufferRequestModeScheduled` when the `AVSampleBufferGenerator` was created with a `NULL` timebase.

---

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)