An object that supprts using Core Image filters to process an individual video frame in a video composition.


@interface AVAsynchronousCIImageFilteringRequest : NSObject


You use this class when creating a composition for Core Image filtering with the videoCompositionWithAsset:applyingCIFiltersWithHandler: method. In that method call, you provide a block to be called by AVFoundation as it processes each frame of video, and the block’s sole parameter is a AVAsynchronousCIImageFilteringRequest object. Use that object both to the video frame image to be filtered and allows you to return a filtered image to AVFoundation for display or export. Listing 1 shows an example of applying a filter to an asset.

Listing 1

Applying Core Image filters to a video asset

CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur"];
AVVideoComposition *composition = [AVVideoComposition videoCompositionWithAsset: asset
    applyingCIFiltersWithHandler:^(AVAsynchronousCIImageFilteringRequest *request){
        // Clamp to avoid blurring transparent pixels at the image edges
        CIImage *source = [request.sourceImage imageByClampingToExtent];
        [filter setValue:source forKey:kCIInputImageKey];
        // Vary filter parameters based on video timing
        Float64 seconds = CMTimeGetSeconds(request.compositionTime);
        [filter setValue:seconds * 10.0 forKey:kCIInputRadiusKey];
        // Crop the blurred output to the bounds of the original image
        CIImage *output = [filter.outputImage imageByCroppingToRect:request.sourceImage.extent];
        // Provide the filter output to the composition
        [request finishWithImage:output context:nil];


Getting the Image to be Filtered


The current video frame image.

Getting Contextual Information for Filtering


The time in the video composition corresponding to the frame being processed.


The width and height, in pixels, of the frame being processed.

Returning the Filtered Image

- finishWithImage:context:

Provides the filtered video frame image to AVFoundation for further processing or display.

- finishWithError:

Notifies AVFoundation that you cannot fulfill the image filtering request.


Inherits From

Conforms To

See Also

Video Composition


An object that represents an immutable video composition.


An object that represents a mutable video composition.


An object that contains the information necessary for a video compositor to render an output pixel buffer.


An operation performed by a compositor.


An object used to modify the transform, cropping, and opacity ramps applied to a given track in a mutable composition.


An object used to incorporate Core Animation into a video composition.


An operation performed by a compositor.


An object used to modify the transform, cropping, and opacity ramps applied to a given track in a composition.


An object that defines the context within which custom compositors render new output pixel buffers.