<!--
{
  "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/CMSampleBufferGetSampleSizeArray(_:entryCount:arrayToFill:entriesNeededOut:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Media"
    ],
    "preciseIdentifier" : "c:@F@CMSampleBufferGetSampleSizeArray"
  },
  "title" : "CMSampleBufferGetSampleSizeArray(_:entryCount:arrayToFill:entriesNeededOut:)"
}
-->

# CMSampleBufferGetSampleSizeArray(_:entryCount:arrayToFill:entriesNeededOut:)

Retrieves an array of sample sizes that represents each sample in a sample buffer.

```
func CMSampleBufferGetSampleSizeArray(_ sbuf: CMSampleBuffer, entryCount sizeArrayEntries: CMItemCount, arrayToFill sizeArrayOut: UnsafeMutablePointer<Int>?, entriesNeededOut sizeArrayEntriesNeededOut: UnsafeMutablePointer<CMItemCount>?) -> OSStatus
```

## Parameters

`sbuf`

The `CMSampleBuffer` being interrogated.

`sizeArrayEntries`

Number of entries in `sizeArray`.

`sizeArrayOut`

Reference to an array of `size_t` values to receive the sample sizes.

`sizeArrayEntriesNeededOut`

Number of entries needed for the result.

## Return Value

A result code. See [Sample Buffer Error Codes](/documentation/CoreMedia/sample-buffer-errors).

## Discussion

If only one size entry is returned, all samples in the buffer are of this size. The `sizeArrayOut` must be allocated by the caller, and the number of entries allocated must be passed in `sizeArrayEntries`. If `sizeArrayOut` is NULL, sizeArrayEntriesNeededOut will return the required number of entries. Similarly, if `sizeArrayEntries` is too small, [`CMSampleBuffer`](/documentation/CoreMedia/CMSampleBuffer) will be returned, and `sizeArrayEntriesNeededOut` will return the required number of entries. The caller can then make an appropriately-sized `sizeArrayOut` and call again. For example, the caller might pass the address of a `size_t` variable on the stack (as sizeArrayOut), and 1 as `sizeArrayEntries`. If all samples are the same size (or there’s only one sample in the `CMSampleBuffer`), this call would succeed. If not, it will fail, and will return the number of entries required in `sizeArrayEntriesNeededOut`. Only in this case (multiple samples of different sizes) will the caller need to allocate an array. 0 entries will be returned if the samples in the buffer are non-contiguous (for example, non-interleaved audio, where the channel values for a single sample are scattered through the buffer). If there are no sample sizes in this `CMSampleBuffer`, [`CMSampleBuffer`](/documentation/CoreMedia/CMSampleBuffer) will be returned, and `*sizeArrayEntriesNeededOut` will be set to 0. This will be true, for example, if the samples in the buffer are non-contiguous (for example, non-interleaved audio, where the channel values for a single sample are scattered through the buffer), or if this `CMSampleBuffer` contains a `CVImageBuffer`.

---

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)