Contents

videoComposition(withPropertiesOf:completionHandler:)

Returns a new video composition that’s configured to present the video tracks of the specified asset.

Declaration

class func videoComposition(withPropertiesOf asset: AVAsset, completionHandler: @escaping  @Sendable (AVMutableVideoComposition?, (any Error)?) -> Void)
class func videoComposition(withPropertiesOf asset: AVAsset) async throws -> AVMutableVideoComposition

Parameters

  • asset:

    An asset to create a video composition for.

  • completionHandler:

    A callback the system invokes with the created video composition, or an error if a failure occurs.

Discussion

This method creates the video composition object and configures it with the values and instructions suitable for presenting the video tracks of the specified asset. The returned object contains instructions that respect the spatial properties and time ranges of the specified asset’s video tracks. It also configures the object properties in the following way:

  • The value of the frameDuration property is short enough to accommodate the greatest nominal frame rate value among the asset’s video tracks, as indicated by the nominalFrameRate property of each track. If all its tracks have a nominal frame rate of 0, it uses a frame rate of 30 frames per second, with the frame duration set accordingly.

  • The value of the renderSize property depends on whether the asset is an AVComposition object. For an AVComposition, the render size is the composition’s naturalSize value, and for other assets, its a size large enough to encompass all of its video tracks.

  • The value of the renderScale property is 1.0.

  • The value of the animationTool property is nil.

See Also

Creating a video composition