<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVSampleBufferGenerator/makeSampleBuffer(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVSampleBufferGenerator(im)createSampleBufferForRequest:error:"
  },
  "title" : "makeSampleBuffer(for:)"
}
-->

# makeSampleBuffer(for:)

Creates a sample buffer, and attempts to load its data asynchronously if requested.

```
func makeSampleBuffer(for request: AVSampleBufferRequest) throws -> sending CMSampleBuffer
```

## Parameters

`request`

A sample buffer creation request.

## Return Value

A sample buffer object.

## Discussion

If you created the generator with a `nil` timebase, any associated [`AVSampleBufferRequest`](/documentation/AVFoundation/AVSampleBufferRequest) objects default to using a request mode of [`AVSampleBufferRequest.Mode.immediate`](/documentation/AVFoundation/AVSampleBufferRequest/Mode-swift.enum/immediate).

Call the [`notifyOfDataReady(for:completionHandler:)`](/documentation/AVFoundation/AVSampleBufferGenerator/notifyOfDataReady(for:completionHandler:)) class method to have the system notify you when sample buffer data is available.

The request may fail based on generator configuration or file format.

---

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)