iOS Developer Library

Developer

AVFoundation Framework Reference AVAssetReaderVideoCompositionOutput Class Reference

Options
Deployment Target:

On This Page
Language:

AVAssetReaderVideoCompositionOutput

AVAssetReaderVideoCompositionOutput is a subclass of AVAssetReaderOutput you use to read video frames that have been composited together from the frames in one or more tracks of an AVAssetReader object's asset.

You can read the video frames composited from one or more asset tracks by adding an instance of AVAssetReaderVideoCompositionOutput to an AVAssetReader object using the addOutput: method.

AVAssetReaderVideoCompositionOutput can only produce uncompressed output.  This means that the videoSettings dictionary must follow the rules for uncompressed video output.  In addition, the following keys are not supported: AVVideoCleanApertureKey, AVVideoPixelAspectRatioKey, AVVideoScalingModeKey, and AVVideoColorPropertiesKey.

Inheritance


Conforms To


Import Statement


Swift

import AVFoundation

Objective-C

@import AVFoundation;

Availability


Available in iOS 4.1 and later.
  • Returns an instance of AVAssetReaderVideoCompositionOutput for reading composited video from the specified video tracks, using optional video settings.

    Declaration

    Objective-C

    + (instancetype)assetReaderVideoCompositionOutputWithVideoTracks:(NSArray *)videoTracks videoSettings:(NSDictionary *)videoSettings

    Parameters

    videoTracks

    An array of AVAssetTrack objects from which the created object should read video frames for compositing.

    It is an error to include tracks of media types other than AVMediaTypeVideo.

    videoSettings

    A dictionary of video settings to be used for sample output, or nil if you want to receive decoded samples in a convenient uncompressed format, with properties determined according to the properties of the specified video tracks.

    You use keys from CVPixelBufferRef, depending on the output format you want.

    Initialization will fail if the video settings cannot be used with the specified video tracks.

    Return Value

    An instance of AVAssetReaderVideoCompositionOutput wrapping videoTracks, using the settings specified by videoSettings, or nil if initialization failed.

    Import Statement

    Objective-C

    @import AVFoundation;

    Availability

    Available in iOS 4.1 and later.

  • Initializes an instance of AVAssetReaderVideoCompositionOutput for reading composited video from the specified video tracks, using optional video settings.

    Declaration

    Swift

    init!(videoTracks videoTracks: [AnyObject]!, videoSettings videoSettings: [NSObject : AnyObject]!)

    Objective-C

    - (instancetype)initWithVideoTracks:(NSArray *)videoTracks videoSettings:(NSDictionary *)videoSettings

    Parameters

    videoTracks

    An array of AVAssetTrack objects from which the created object should read video frames for compositing.

    Each track must be one of the tracks owned by the target asset reader’s asset and must be of media type AVMediaTypeVideo.

    videoSettings

    A dictionary of video settings to be used for sample output, or nil if you want to receive decoded samples in a convenient uncompressed format, with properties determined according to the properties of the specified video tracks.

    You use keys from CVPixelBufferRef, depending on the output format you want.

    Initialization will fail if the video settings cannot be used with the specified video tracks.

    Return Value

    An instance of AVAssetReaderVideoCompositionOutput wrapping videoTracks, using the settings specified by videoSettings, or nil if initialization failed.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.1 and later.

  • The video composition to use for the output.

    Declaration

    Swift

    @NSCopying var videoComposition: AVVideoComposition!

    Objective-C

    @property(nonatomic, copy) AVVideoComposition *videoComposition

    Discussion

    The value is an AVVideoComposition object that can be used to specify the visual arrangement of video frames read from each source track over the timeline of the source asset.

    See AVVideoComposition for options for configuring a video composition.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.1 and later.

  • Returns the custom video compositor instance used by the receiver, if any. (read-only)

    Declaration

    Swift

    var customVideoCompositor: AVVideoCompositing! { get }

    Objective-C

    @property(nonatomic, readonly) id< AVVideoCompositing > customVideoCompositor

    Discussion

    The custom video compositor instance that is used during image generation is accessible via this property after the value of videoComposition is set to an AVVideoComposition instance that specifies a custom video compositor class. Any additional communication between the application and that instance of the custom video compositor, if any is required for configuration or other purposes, can only occur once that has happened.

    If the value of videoComposition is changed from an AVVideoComposition that specifies a custom video compositor class to another instance of AVVideoComposition that specifies the same custom video compositor class, the instance of the custom video compositor that was previously created will receive the renderContextChanged: message and remain in use for subsequent image generation.

    This property is nil if there is no video compositor, or if the internal video compositor is in use.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.

  • The video settings used by the output. (read-only)

    Declaration

    Swift

    var videoSettings: [NSObject : AnyObject]! { get }

    Objective-C

    @property(nonatomic, readonly) NSDictionary *videoSettings

    Discussion

    The dictionary’s keys are specified in CVPixelBufferRef.

    A value of nil indicates that the receiver will return video frames in a convenient uncompressed format, with properties determined according to the properties of the receiver's video tracks.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.1 and later.

  • The tracks from which the output reads composited video. (read-only)

    Declaration

    Swift

    var videoTracks: [AnyObject]! { get }

    Objective-C

    @property(nonatomic, readonly) NSArray *videoTracks

    Discussion

    The array contains AVAssetTrack objects owned by the target asset reader’s asset.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.1 and later.