---
title: "decodeFrame(from:options:completionHandler:)"
framework: MediaExtension
role: symbol
role_heading: Instance Method
platforms: [macOS 14.0+]
path: "mediaextension/mevideodecoder/decodeframe(from:options:completionhandler:)"
---

# decodeFrame(from:options:completionHandler:)

Requests the extension to decode a video frame.

## Declaration

```swift
func decodeFrame(from sampleBuffer: CMSampleBuffer, options: MEDecodeFrameOptions, completionHandler: @escaping @Sendable (CVImageBuffer?, MEDecodeFrameStatus, (any Error)?) -> Void)
```

```swift
func decodeFrame(from sampleBuffer: CMSampleBuffer, options: MEDecodeFrameOptions) async throws -> (CVImageBuffer, MEDecodeFrameStatus)
```

## Parameters

- `sampleBuffer`: A sample buffer that contains one video frame.
- `options`: Specific decode options for the frame.
- `completionHandler`: The completion block to execute when the decode operation finishes.

## Discussion

Discussion This method calls the completion handler for every sample buffer frame when decoding completes, but not necessarily in display order. The completion handler receives a decoded pixel buffer, a decode status that indicates a frame dropped, or an error. Use MEVideoDecoderPixelBufferManager to allocate an image buffer. If an error occurs that’s external to MediaExtensionErrorDomain, the VTDecompressionSession receives it as kVTVideoDecoderUnknownErr.

## See Also

### Decoding frames

- [canAccept(_:)](mediaextension/mevideodecoder/canaccept(_:).md)
- [MEDecodeFrameStatus](mediaextension/medecodeframestatus.md)
