<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreMedia",
  "identifier" : "/documentation/CoreMedia/CMSampleBufferCreateReadyWithImageBuffer(allocator:imageBuffer:formatDescription:sampleTiming:sampleBufferOut:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Media"
    ],
    "preciseIdentifier" : "c:@F@CMSampleBufferCreateReadyWithImageBuffer"
  },
  "title" : "CMSampleBufferCreateReadyWithImageBuffer(allocator:imageBuffer:formatDescription:sampleTiming:sampleBufferOut:)"
}
-->

# CMSampleBufferCreateReadyWithImageBuffer(allocator:imageBuffer:formatDescription:sampleTiming:sampleBufferOut:)

Creates a sample buffer with image data.

```
func CMSampleBufferCreateReadyWithImageBuffer(allocator: CFAllocator?, imageBuffer: CVImageBuffer, formatDescription: CMVideoFormatDescription, sampleTiming: UnsafePointer<CMSampleTimingInfo>, sampleBufferOut: UnsafeMutablePointer<CMSampleBuffer?>) -> OSStatus
```

## Parameters

`allocator`

The allocator to use for allocating the `CMSampleBuffer` object. Pass `kCFAllocatorDefault` to use the default allocator.

`imageBuffer`

`CVImageBuffer` already containing the media data. Must not be `NULL`.

`formatDescription`

A description of the media data’s format. See discussion below for constraints. May not be `NULL`.

`sampleTiming`

A `CMSampleTimingInfo` struct that provides the timing information for the media represented by the `CVImageBuffer`.

`sampleBufferOut`

Returned newly created `CMSampleBuffer`.

## Discussion

Unlike a `CMBlockBuffer`, which can reference many samples, a `CVImageBuffer` is defined to reference only one sample; therefore this routine has fewer parameters than `CMSampleBufferCreate`.

Sample timing information, which is a vector for `CMSampleBufferCreate`, consists of only one value for this routine.

The concept of sample size doesn’t apply to `CVImageBuffers`. As such, `CMSampleBufferGetSampleSizeArray` returns `kCMSampleBufferError_BufferHasNoSampleSizes`, and `CMSampleBufferGetSampleSize` returns 0.

Because `CVImageBuffers` hold visual data, the format description provided is a `CMVideoFormatDescription`. The format description must be consistent with the attributes and formatting information attached to the `CVImageBuffer`. The `width`, `height`, and `codecType` must match (for `CVPixelBuffers` the codec type is given by `CVPixelBufferGetPixelFormatType(pixelBuffer)`; for other `CVImageBuffers`, the `codecType` must be 0). The format description extensions must match the image buffer attachments for all the keys in the list returned by `CMVideoFormatDescriptionGetExtensionKeysCommonWithImageBuffers` (if absent in either they must be absent in both).

`CMSampleBufferCreateReadyWithImageBuffer` is identical to `CMSampleBufferCreateForImageBuffer` except that `dataReady` is always `true`, and so no `makeDataReadyCallback` or `refcon` needs to be passed.

---

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)