---
title: "CMSampleBufferCreateCopy(allocator:sampleBuffer:sampleBufferOut:)"
framework: coremedia
role: symbol
role_heading: Function
path: "coremedia/cmsamplebuffercreatecopy(allocator:samplebuffer:samplebufferout:)"
---

# CMSampleBufferCreateCopy(allocator:sampleBuffer:sampleBufferOut:)

Creates a copy of a sample buffer.

## Declaration

```swift
func CMSampleBufferCreateCopy(allocator: CFAllocator?, sampleBuffer sbuf: CMSampleBuffer, sampleBufferOut: UnsafeMutablePointer<CMSampleBuffer?>) -> OSStatus
```

## Parameters

- `allocator`: The allocator to use for allocating the CMSampleBuffer object. Pass kCFAllocatorDefault to use the default allocator.
- `sbuf`: CMSampleBuffer being copied.
- `sampleBufferOut`: On output, points to the newly created copy of CMSampleBuffer.

## Return Value

Return Value A result code. See Sample Buffer Error Codes.

## Discussion

Discussion The copy is shallow: scalar properties (sizes and timing) are copied directly, the data buffer and format description are retained, and the attachments that can be propagated are retained by the copy’s dictionary. If sbuf’s data isn’t ready, the copy will be set to track its readiness.

## See Also

### Copying Sample Buffers

- [CMSampleBufferCreateCopyWithNewTiming(allocator:sampleBuffer:sampleTimingEntryCount:sampleTimingArray:sampleBufferOut:)](coremedia/cmsamplebuffercreatecopywithnewtiming(allocator:samplebuffer:sampletimingentrycount:sampletimingarray:samplebufferout:).md)
- [CMSampleBufferCopySampleBufferForRange(allocator:sampleBuffer:sampleRange:sampleBufferOut:)](coremedia/cmsamplebuffercopysamplebufferforrange(allocator:samplebuffer:samplerange:samplebufferout:).md)
