<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVCaptureTimecode/createMetadataSampleBuffer(from:forDuration:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:@F@AVCaptureTimecodeCreateMetadataSampleBufferForDuration"
  },
  "title" : "createMetadataSampleBuffer(from:forDuration:)"
}
-->

# createMetadataSampleBuffer(from:forDuration:)

Creates a sample buffer containing Timecode Media Description metadata for a specified duration.

```
static func createMetadataSampleBuffer(from timecode: AVCaptureTimecode, forDuration duration: CMTime) -> Unmanaged<CMSampleBuffer>?
```

## Parameters

`timecode`

The [`AVCaptureTimecode`](/documentation/AVFoundation/AVCaptureTimecode) instance providing the timecode details for the metadata sample.

`duration`

The duration that the metadata sample buffer should represent.

## Return Value

A `CMSampleBufferRef` with encoded Timecode Media Description metadata for the given duration, or `nil` if sample buffer creation fails.

## Discussion

Use this function for scenarios where timecode metadata needs to span a custom interval (not just a single frame), such as non-frame-accurate workflows or for describing a segment of media with a consistent timecode.

---

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)