Class

AVAssetImageGenerator

An object that provides thumbnail or preview images of assets independently of playback.

Declaration

@interface AVAssetImageGenerator : NSObject

Overview

AVAssetImageGenerator uses the default enabled video track(s) to generate images. Generating a single image in isolation can require the decoding of a large number of video frames with complex interdependencies. If you require a series of images, you can achieve far greater efficiency using the asynchronous method, generateCGImagesAsynchronouslyForTimes:completionHandler:, which employs decoding efficiencies similar to those used during playback.

You create an asset generator using initWithAsset: or assetImageGeneratorWithAsset:. These methods may succeed even if the asset possesses no visual tracks at the time of initialization. You can test whether an asset has any tracks with the visual characteristic using the AVAsset class’s method tracksWithMediaCharacteristic:.

The actual time of a generated image is within the range [requestedTime-requestedTimeToleranceBefore, requestedTime+requestedTimeToleranceAfter] and may differ from the requested time for efficiency.

Assets that represent mutable compositions or mutable movies may gain visual tracks after initialization of an associated image generator.

Topics

Creating an Image Generator

- initWithAsset:

Creates an image generator for use with a specified asset.

+ assetImageGeneratorWithAsset:

Returns an image generator for use with a specified asset.

Generating Images

- copyCGImageAtTime:actualTime:error:

Returns an image for the asset at or near a specified time.

- generateCGImagesAsynchronouslyForTimes:completionHandler:

Creates a series of image objects for an asset at or near specified times.

AVAssetImageGeneratorCompletionHandler

A block that you use to receive thumbnail images generated from an asset.

AVAssetImageGeneratorResult

The statuses indicating the outcome of image generation.

- cancelAllCGImageGeneration

Cancels all pending image generation requests.

Managing Image-Generation Time Tolerances

requestedTimeToleranceBefore

The maximum amount of time before a requested time you can generate an image.

requestedTimeToleranceAfter

The maximum length of time after a requested time you can generate an image.

Configuring Image-Generation Behavior

apertureMode

Specifies the aperture mode for the generated image.

AVAssetImageGeneratorApertureMode

The aperture modes used when generating images.

appliesPreferredTrackTransform

Specifies whether to apply the track matrix, or matrices. when extracting an image from the asset.

asset

The asset that initialized the image generator.

maximumSize

Specifies the maximum dimensions for the generated image.

videoComposition

The video composition to use when extracting images from assets with multiple video tracks.

customVideoCompositor

Returns the custom video compositor instance used, if any.

Relationships

Inherits From

See Also

File Import

AVAssetReader

A reader object used to obtain the media data of an asset, either file-based or consisting of an assemblage of media data from multiple sources.

AVAssetReaderAudioMixOutput

An object that defines an interface for reading audio samples that result from mixing the audio from one or more tracks.

AVAssetReaderTrackOutput

An object that defines an interface for reading media data from a single track of an asset reader's asset.

AVAssetReaderSampleReferenceOutput

An object that defines an interface for reading sample references from a single asset track.

AVAssetReaderVideoCompositionOutput

An object that reads video frames composited from the frames in one or more tracks of a reader's assets.

AVAssetReaderOutput

An abstract class that defines an interface for reading a single collection of samples of a common media type from an asset reader object.

AVAssetReaderOutputMetadataAdaptor

An object that defines an interface for reading metadata.