The AVVideo​Compositing protocol defines properties and methods that custom video compositors must implement.


For each AV Foundation object of class AVPlayer​Item, AVAsset​Export​Session, AVAsset​Image​Generator, or AVAsset​Reader​Video​Composition​Output that has a non-nil value for its video​Composition property, and the value of the custom​Video​Compositor​Class property of the AVVideo​Composition is not nil, AV Foundation creates and uses an instance of that custom video compositor class to process the instructions contained in the AVVideo​Composition.

The custom video compositor instance will be created when you assign video​Composition an instance of AVVideo​Composition that's associated with a different custom video compositor class than the object was previously using.

When creating instances of custom video compositors, AV Foundation initializes them by calling init and then makes them available as the value of the custom​Video​Compositor property of the object to which it was assigned. You then can do any additional setup or configuration to the custom compositor.

Custom video compositor instances will then be retained by the AV Foundation object for as long as the value of its video​Composition property indicates that an instance of the same custom video compositor class should be used, even if the value is changed from one instance of AVVideo​Composition to another instance that's associated with the same custom video compositor class.


Rendering the Composition

func start​Request(AVAsynchronous​Video​Composition​Request)

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

func cancel​All​Pending​Video​Composition​Requests()

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

Render Context Settings

func render​Context​Changed(AVVideo​Composition​Render​Context)

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

Pixel Buffer Attributes

var required​Pixel​Buffer​Attributes​For​Render​Context:​ [String :​ Any]

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

var source​Pixel​Buffer​Attributes:​ [String :​ Any]?

Returns the kinds of source frame pixel buffer attributes a video compositor can accept as input.


Inherits From