Platforms to show: All Mac Windows Linux Cross-Platform

Back to AVAssetImageGeneratorMBS class.

AVAssetImageGeneratorMBS.cancelAllCGImageGeneration

Type Topic Plugin Version macOS Windows Linux iOS Targets
method AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Cancels all pending image generation requests.

This method calls the AVFoundationMBS.generateCGImagesAsynchronouslyForTimesCompleted event with AVAssetImageGeneratorCancelled for each image time in every previous invocation of generateCGImagesAsynchronouslyForTimes for which images have not yet been supplied.

AVAssetImageGeneratorMBS.CGImageAtTime(time as CMTimeMBS, byref actualTime as CMTimeMBS, byref error as NSErrorMBS) as Variant

Type Topic Plugin Version macOS Windows Linux iOS Targets
method AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns a CGImage for the asset at or near a specified time.
Example
// open asset
dim f as FolderItem = SpecialFolder.Desktop.Child("test.mov")
dim a as AVAssetMBS = AVAssetMBS.assetWithFile(f)

// prepare generator
dim g as new AVAssetImageGeneratorMBS(a)
dim timeRequested as CMTimeMBS = CMTimeMBS.MakeWithSeconds(5, 30)
dim actualTime as CMTimeMBS
dim error as NSErrorMBS
// ask for an image
dim c as CGImageMBS = g.CGImageAtTime(timeRequested, actualTime, error)
// and show it
dim p as Picture = c.Picture
window1.backdrop = p

requestedTime: The time at which the image of the asset is to be created.
actualTime: Upon return, contains the time at which the image was actually generated.
Error: If an error occurs, upon return contains an NSError object that describes the problem.

Returns a CGImageMBS for the asset at or near a specified time, or nil if the image could not be created.
This method returns the image synchronously.

Some examples using this method:

AVAssetImageGeneratorMBS.Constructor(asset as AVAssetMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes an image generator for use with a specified asset.

asset: The asset from which images will be extracted.
This method may succeed even if the asset possesses no visual tracks at the time of initialization.

AVAssetImageGeneratorMBS.generateCGImagesAsynchronouslyForTimes(times() as CMTimeMBS, tag as Variant = nil)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates a series of CGImage objects for an asset at or near specified times.

requestedTimes: An array of CMTimeMBS, specifying the asset times at which an image is requested.

This method uses an efficient "batch mode" to get images in time order.

The client receives exactly one event call to AVFoundationMBS.generateCGImagesAsynchronouslyForTimesCompleted for each requested time in requestedTimes. Changes to the generator's properties (snap behavior, maximum size, and so on) do not affect pending asynchronous image generation requests.

With tag you can pass any value you like to the event later. This can be for example an object reference or a number in an array. Be aware that the reference to this tag value is kept until the event is called and can cause memory reference cycles.

Some examples using this method:

AVAssetImageGeneratorMBS.maximumSize as CGSizeMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
property AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Specifies the maximum dimensions for generated image.

The default value is CGSizeZero, which specifies the asset's unscaled dimensions.

AVAssetImageGenerator scales images such that they fit within the defined bounding box. Images are never scaled up. The aspect ratio of the scaled image is defined by the apertureMode property.
(Read and Write computed property)

AVAssetImageGeneratorMBS.requestedTimeToleranceAfter as CMTimeMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
property AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
The maximum length of time after a requested time for which an image may be generated.

The default value is kCMTimePositiveInfinity.

Set the values of requestedTimeToleranceBefore and requestedTimeToleranceAfter to kCMTimeZero to request frame-accurate image generation; this may incur additional decoding delay.
(Read and Write computed property)

AVAssetImageGeneratorMBS.requestedTimeToleranceBefore as CMTimeMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
property AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
The maximum length of time before a requested time for which an image may be generated.

The default value is kCMTimePositiveInfinity.

Set the values of requestedTimeToleranceBefore and requestedTimeToleranceAfter to kCMTimeZero to request frame-accurate image generation; this may incur additional decoding delay.
(Read and Write computed property)

The items on this page are in the following plugins: MBS AVFoundation Plugin.


The biggest plugin in space...