<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreMedia",
  "identifier" : "/documentation/CoreMedia/CMSampleBuffer/sampleSize(at:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Media",
      "CoreMedia"
    ],
    "preciseIdentifier" : "s:So17CMSampleBufferRefa9CoreMediaE10sampleSize2atS2i_tF"
  },
  "title" : "sampleSize(at:)"
}
-->

# sampleSize(at:)

Returns the size of a sample in bytes.

```
func sampleSize(at sampleIndex: Int) -> Int
```

## Parameters

`sampleIndex`

The index of the sample to query.

## Return Value

The size of the sample.

## Discussion

If you specify a sample index that isn’t in the range, the system returns `0`. It also returns `0` if the sample buffer contains no sizes, which occurs if the samples in the buffer are noncontiguous, such as noninterleaved audio, or if the sample buffer contains a <doc://com.apple.documentation/documentation/CoreVideo/cvimagebuffer-q40>.

---

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)