The methods that custom video compositors must implement.


protocol AVVideoCompositing


For each AVFoundation object of class AVPlayerItem, AVAssetExportSession, AVAssetImageGenerator, or AVAssetReaderVideoCompositionOutput that has a non-nil value for its videoComposition property, and the value of the customVideoCompositorClass property of the AVVideoComposition is not nil, AVFoundation creates and uses an instance of that custom video compositor class to process the instructions contained in the AVVideoComposition.

The system creates a custom video compositor instance when you assign videoComposition an instance of AVVideoComposition that's associated with a different custom video compositor class than the object was previously using.

When creating instances of custom video compositors, AVFoundation initializes them by calling init and then makes them available as the value of the customVideoCompositor property of the object. You then can do any additional setup or configuration to the custom compositor.

The AVFoundation object retains the custom video compositor instances for as long as the value of the videoComposition property indicates that there is an instance of the same custom video compositor class. This is true even when the value changes from one instance of AVVideoComposition to another associated instance with the same custom video compositor class.


Rendering the Composition

func startRequest(AVAsynchronousVideoCompositionRequest)

Directs a custom video compositor object to create a new pixel buffer composed asynchronously from a collection of sources.


func cancelAllPendingVideoCompositionRequests()

Directs a custom video compositor object to cancel or finish all pending video composition requests.

Render Context Settings

func renderContextChanged(AVVideoCompositionRenderContext)

Notifies the custom compositor that a composition will switch to a different render context.


var supportsWideColorSourceFrames: Bool

A Boolean value that indicates whether the client can handle frames that contain wide color properties.

Pixel Buffer Attributes

var requiredPixelBufferAttributesForRenderContext: [String : Any]

The pixel buffer attributes required by the video compositor for new buffers created for processing.


var sourcePixelBufferAttributes: [String : Any]?

The types of source frame pixel buffer attributes a video compositor can accept as input.


Instance Methods

func anticipateRendering(using: AVVideoCompositionRenderHint)

Informs a custom video compositor about upcoming rendering requests.

func prerollForRendering(using: AVVideoCompositionRenderHint)

Tells a custom video compositor to perform any work in the prerolling phase.


Inherits From

See Also

Configuring an Item's Settings

var audioMix: AVAudioMix?

The audio mix parameters to be applied during playback.

var videoComposition: AVVideoComposition?

The video composition settings to be applied during playback.

var seekingWaitsForVideoCompositionRendering: Bool

A Boolean value that indicates whether the item’s timing follows the displayed video frame when seeking with a video composition.

var audioTimePitchAlgorithm: AVAudioTimePitchAlgorithm

The processing algorithm used to manage audio pitch for scaled audio edits.

var videoApertureMode: AVVideoApertureMode

The video aperture mode to apply during playback.

struct AVVideoApertureMode

A value that describes how a video is scaled or cropped.