---
title: "CMSampleBufferGetSampleSize(_:at:)"
framework: coremedia
role: symbol
role_heading: Function
path: "coremedia/cmsamplebuffergetsamplesize(_:at:)"
---

# CMSampleBufferGetSampleSize(_:at:)

Returns the size in bytes of a specified sample in a sample buffer.

## Declaration

```swift
func CMSampleBufferGetSampleSize(_ sbuf: CMSampleBuffer, at sampleIndex: CMItemIndex) -> Int
```

## Parameters

- `sbuf`: The sample buffer to inspect.
- `sampleIndex`: The zero-based sample index.

## Return Value

Return Value The size in bytes of the specified sample in the sample buffer. If the sample index is not in the range 0 to numSamples-1, a size of 0 will be returned.If there are no sample sizes in this sample buffer, a size of 0 will be returned.This will be true, for example, if the samples in the buffer are non-contiguous (eg. non-interleaved audio, where the channel values for a single sample are scattered through the buffer), or if this sample buffer contains a CVImageBuffer.

## See Also

### Inspecting Size Information

- [CMSampleBufferGetNumSamples(_:)](coremedia/cmsamplebuffergetnumsamples(_:).md)
- [CMSampleBufferGetTotalSampleSize(_:)](coremedia/cmsamplebuffergettotalsamplesize(_:).md)
- [CMSampleBufferGetSampleSizeArray(_:entryCount:arrayToFill:entriesNeededOut:)](coremedia/cmsamplebuffergetsamplesizearray(_:entrycount:arraytofill:entriesneededout:).md)
