decodeFrame(from:options:completionHandler:)
Requests the extension to decode a video frame.
Declaration
func decodeFrame(from sampleBuffer: CMSampleBuffer, options: MEDecodeFrameOptions, completionHandler: @escaping @Sendable (CVImageBuffer?, MEDecodeFrameStatus, (any Error)?) -> Void)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
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.