<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVAssetImageGenerator",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVAssetImageGenerator"
  },
  "title" : "AVAssetImageGenerator"
}
-->

# AVAssetImageGenerator

An object that generates images from a video asset.

```
class AVAssetImageGenerator
```

## Overview

Use an image generator to extract images from a video asset at particular times within its timeline.

## Topics

### Creating an image generator

[`+ (instancetype) assetImageGeneratorWithAsset:(AVAsset *) asset;`](/documentation/AVFoundation/AVAssetImageGenerator/assetImageGeneratorWithAsset:)

Returns a new object that generates images for times within a video asset.

[`init(asset: AVAsset)`](/documentation/AVFoundation/AVAssetImageGenerator/init(asset:))

Creates an object that generates images for times within a video asset.

### Configuring image generation

[`var maximumSize: CGSize`](/documentation/AVFoundation/AVAssetImageGenerator/maximumSize)

The maximum size of images to generate.

[`var requestedTimeToleranceBefore: CMTime`](/documentation/AVFoundation/AVAssetImageGenerator/requestedTimeToleranceBefore)

A maximum length of time before the requested time to allow image generation to occur.

[`var requestedTimeToleranceAfter: CMTime`](/documentation/AVFoundation/AVAssetImageGenerator/requestedTimeToleranceAfter)

A maximum length of time after the requested time to allow image generation to occur.

[`var dynamicRangePolicy: AVAssetImageGenerator.DynamicRangePolicy`](/documentation/AVFoundation/AVAssetImageGenerator/dynamicRangePolicy-swift.property)

The dynamic range policy to use when generating images.

[`struct DynamicRangePolicy`](/documentation/AVFoundation/AVAssetImageGenerator/DynamicRangePolicy-swift.struct)

A type that specifies the dynamic range policy to apply when generating images.

[`var appliesPreferredTrackTransform: Bool`](/documentation/AVFoundation/AVAssetImageGenerator/appliesPreferredTrackTransform)

A Boolean value that specifies whether to apply the track matrix or matrices when generating an image from the asset.

[`var apertureMode: AVAssetImageGenerator.ApertureMode?`](/documentation/AVFoundation/AVAssetImageGenerator/apertureMode-swift.property)

Specifies the aperture mode for the generated image.

[`struct ApertureMode`](/documentation/AVFoundation/AVAssetImageGenerator/ApertureMode-swift.struct)

Constants that define aperture modes to use when generating images.

### Configuring compositing

[`var videoComposition: AVVideoComposition?`](/documentation/AVFoundation/AVAssetImageGenerator/videoComposition)

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

[`var customVideoCompositor: (any AVVideoCompositing)?`](/documentation/AVFoundation/AVAssetImageGenerator/customVideoCompositor)

A custom video compositor to use when extracting images from assets with multiple video tracks.

### Generating images

[`func image(at: CMTime) async throws -> (image: CGImage, actualTime: CMTime)`](/documentation/AVFoundation/AVAssetImageGenerator/image(at:))

Generates an image for a requested time.

[`func images(for: [CMTime]) -> sending AVAssetImageGenerator.Images`](/documentation/AVFoundation/AVAssetImageGenerator/images(for:))

Generates images for times within the video timeline.

[`struct Images`](/documentation/AVFoundation/AVAssetImageGenerator/Images)

An asynchronous sequence of images created by an image generator.

[`func generateCGImageAsynchronously(for: CMTime, completionHandler: (CGImage?, CMTime, (any Error)?) -> Void)`](/documentation/AVFoundation/AVAssetImageGenerator/generateCGImageAsynchronously(for:completionHandler:))

Generates an image asynchronously for a requested time, and returns the result in a callback.

[`func generateCGImagesAsynchronously(forTimes: [NSValue], completionHandler: AVAssetImageGeneratorCompletionHandler)`](/documentation/AVFoundation/AVAssetImageGenerator/generateCGImagesAsynchronously(forTimes:completionHandler:))

Generates images asynchronously for an array of requested times, and returns the results in a callback.

[`typealias AVAssetImageGeneratorCompletionHandler`](/documentation/AVFoundation/AVAssetImageGeneratorCompletionHandler)

A type alias for a closure that provides the result of an image generation request.

[`func cancelAllCGImageGeneration()`](/documentation/AVFoundation/AVAssetImageGenerator/cancelAllCGImageGeneration())

Cancels all pending image generation requests.

[`func copyCGImage(at: CMTime, actualTime: UnsafeMutablePointer<CMTime>?) throws -> CGImage`](/documentation/AVFoundation/AVAssetImageGenerator/copyCGImage(at:actualTime:))

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

### Accessing the asset

[`var asset: AVAsset`](/documentation/AVFoundation/AVAssetImageGenerator/asset)

The asset that initialized the image generator.

## Relationships

### Conforms To

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

[`CVarArg`](/documentation/Swift/CVarArg)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Hashable`](/documentation/Swift/Hashable)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)