---
title: "createMetadataSampleBuffer(from:associatedWithPresentationTimeStamp:)"
framework: AVFoundation
role: symbol
role_heading: Type Method
platforms: [iOS 26.0+, iPadOS 26.0+, Mac Catalyst 26.0+, macOS 26.0+, tvOS 26.0+]
path: "avfoundation/avcapturetimecode/createmetadatasamplebuffer(from:associatedwithpresentationtimestamp:)"
---

# createMetadataSampleBuffer(from:associatedWithPresentationTimeStamp:)

Creates a sample buffer containing Timecode Media Description metadata for integration with a video track.

## Declaration

```swift
static func createMetadataSampleBuffer(from timecode: AVCaptureTimecode, associatedWithPresentationTimeStamp presentationTimeStamp: CMTime) -> Unmanaged<CMSampleBuffer>?
```

## Parameters

- `timecode`: The doc://com.apple.avfoundation/documentation/AVFoundation/AVCaptureTimecode instance providing the timecode details to encode.
- `presentationTimeStamp`: The presentation time stamp that determines the exact moment in the media timeline where the metadata should be applied. It is embedded in the sample timing info (CMSampleTimingInfo) and ensures that the packaged metadata synchronizes accurately with the corresponding video frame.

## Return Value

Return Value A CMSampleBufferRef with the encoded Timecode Media Description metadata for video synchronization, or nil if sample buffer creation fails.

## See Also

### Timecode generation

- [AVCaptureTimecodeGenerator](avfoundation/avcapturetimecodegenerator.md)
- [AVCaptureTimecodeGeneratorDelegate](avfoundation/avcapturetimecodegeneratordelegate.md)
- [AVCaptureTimecodeGenerator.SynchronizationStatus](avfoundation/avcapturetimecodegenerator/synchronizationstatus.md)
- [AVCaptureTimecode.Source](avfoundation/avcapturetimecode/source.md)
- [AVCaptureTimecode.SourceType](avfoundation/avcapturetimecode/sourcetype-swift.enum.md)
- [AVCaptureTimecode](avfoundation/avcapturetimecode.md)
- [advanced(_:by:)](avfoundation/avcapturetimecode/advanced(_:by:).md)
- [createMetadataSampleBuffer(from:forDuration:)](avfoundation/avcapturetimecode/createmetadatasamplebuffer(from:forduration:).md)
