Class

AVAsynchronousCIImageFilteringRequest

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

Declaration

@interface AVAsynchronousCIImageFilteringRequest : NSObject

Overview

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];
    }];

Topics

Getting the Image to be Filtered

sourceImage

The current video frame image.

Getting Contextual Information for Filtering

compositionTime

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

renderSize

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.

Relationships

Inherits From

Conforms To

See Also

Video Composition

AVVideoComposition

An object that represents an immutable video composition.

AVMutableVideoComposition

An object that represents a mutable video composition.

AVAsynchronousVideoCompositionRequest

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

AVMutableVideoCompositionInstruction

An operation performed by a compositor.

AVMutableVideoCompositionLayerInstruction

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

AVVideoCompositionCoreAnimationTool

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

AVVideoCompositionInstruction

An operation performed by a compositor.

AVVideoCompositionLayerInstruction

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

AVVideoCompositionRenderContext

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