iOS Developer Library

Developer

AVFoundation Framework Reference AVAssetWriterInputPixelBufferAdaptor Class Reference

Options
Deployment Target:

On This Page
Language:

AVAssetWriterInputPixelBufferAdaptor

You use an AVAssetWriterInputPixelBufferAdaptor to append video samples packaged as CVPixelBuffer objects to a single AVAssetWriterInput object. More...

Inheritance


  • NSObject
  • AVAssetWriterInputPixelBufferAdaptor
  • NSObject
  • AVAssetWriterInputPixelBufferAdaptor

Conforms To


Import Statement


import AVFoundation @import AVFoundation;

Availability


Available in iOS 4.1 and later.
  • Returns a new pixel buffer adaptor to receive pixel buffers for writing to the output file.

    Declaration

    Objective-C

    + (instancetype)assetWriterInputPixelBufferAdaptorWithAssetWriterInput:(AVAssetWriterInput *)input sourcePixelBufferAttributes:(NSDictionary *)sourcePixelBufferAttributes

    Parameters

    input

    The asset writer input to which the receiver should append pixel buffers.

    Currently, only asset writer inputs that accept media data of type AVMediaTypeVideo can be used to initialize a pixel buffer adaptor.

    It is an error to pass a sample buffer input that is already attached to another instance of AVAssetWriterInputPixelBufferAdaptor.

    sourcePixelBufferAttributes

    The attributes of pixel buffers that will be vended by the input's CVPixelBufferPool.

    Pixel buffer attributes keys for the pixel buffer pool are defined in <CoreVideo/CVPixelBuffer.h>. To take advantage of the improved efficiency of appending buffers created from the adaptor’s pixel buffer pool, you should specify pixel buffer attributes that most closely accommodate the source format of the video frames being appended.

    Pass nil if you do not need a pixel buffer pool for allocating buffers.

    Return Value

    A new pixel buffer adaptor to receive pixel buffers for writing to the output file.

    Discussion

    To specify the pixel format type, the pixelBufferAttributes dictionary should contain a value for kCVPixelBufferPixelFormatTypeKey. For example, use [NSNumber numberWithInt:kCVPixelFormatType_32BGRA] for 8-bit-per-channel BGRA, or use [NSNumber numberWithInt:kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange] for 2-plane YCbCr.

    Import Statement

    Availability

    Available in iOS 4.1 and later.

  • Initializes a new pixel buffer adaptor to receive pixel buffers for writing to the output file.

    Declaration

    Swift

    init!(assetWriterInput input: AVAssetWriterInput!, sourcePixelBufferAttributes sourcePixelBufferAttributes: [NSObject : AnyObject]!)

    Objective-C

    - (instancetype)initWithAssetWriterInput:(AVAssetWriterInput *)input sourcePixelBufferAttributes:(NSDictionary *)sourcePixelBufferAttributes

    Parameters

    input

    The asset writer input to which the receiver should append pixel buffers.

    Currently, only asset writer inputs that accept media data of type AVMediaTypeVideo can be used to initialize a pixel buffer adaptor.

    It is an error to pass a sample buffer input that is already attached to another instance of AVAssetWriterInputPixelBufferAdaptor.

    sourcePixelBufferAttributes

    The attributes of pixel buffers that will be vended by the input's CVPixelBufferPool.

    Pixel buffer attributes keys for the pixel buffer pool are defined in <CoreVideo/CVPixelBuffer.h>. To take advantage of the improved efficiency of appending buffers created from the adaptor’s pixel buffer pool, you should specify pixel buffer attributes that most closely accommodate the source format of the video frames being appended.

    Pass nil if you do not need a pixel buffer pool for allocating buffers.

    Return Value

    A pixel buffer adaptor initialized to receive pixel buffers for writing to the output file.

    Discussion

    To specify the pixel format type, the pixelBufferAttributes dictionary should contain a value for kCVPixelBufferPixelFormatTypeKey. For example, use [NSNumber numberWithInt:kCVPixelFormatType_32BGRA] for 8-bit-per-channel BGRA, or use [NSNumber numberWithInt:kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange] for 2-plane YCbCr.

    Import Statement

    import AVFoundation

    Availability

    Available in iOS 4.1 and later.

  • Appends a pixel buffer to the receiver.

    Declaration

    Swift

    func appendPixelBuffer(_ pixelBuffer: CVPixelBuffer!, withPresentationTime presentationTime: CMTime) -> Bool

    Objective-C

    - (BOOL)appendPixelBuffer:(CVPixelBufferRef)pixelBuffer withPresentationTime:(CMTime)presentationTime

    Parameters

    pixelBuffer

    The CVPixelBuffer to be appended.

    presentationTime

    The presentation time for the pixel buffer to be appended. This time will be considered relative to the time passed to -[AVAssetWriter startSessionAtSourceTime:] to determine the timing of the frame in the output file.

    Return Value

    YEStrue if the pixel buffer was successfully appended, otherwise NOfalse.

    Discussion

    If the operation is unsuccessful, writing the asset has failed. You must not call finishWriting.

    Special Considerations

    Do not modify a CVPixelBuffer or its contents after you have passed it to this method.

    Import Statement

    import AVFoundation

    Availability

    Available in iOS 4.1 and later.

    See Also

    pixelBufferPool

  • The asset writer input to which the adaptor should append pixel buffers. (read-only)

    Declaration

    Swift

    var assetWriterInput: AVAssetWriterInput! { get }

    Objective-C

    @property(nonatomic, readonly) AVAssetWriterInput *assetWriterInput

    Import Statement

    import AVFoundation

    Availability

    Available in iOS 4.1 and later.

  • A pixel buffer pool that will vend and efficiently recycle CVPixelBuffer objects that can be appended to the receiver. (read-only)

    Declaration

    Swift

    var pixelBufferPool: CVPixelBufferPool! { get }

    Objective-C

    @property(nonatomic, readonly) CVPixelBufferPoolRef pixelBufferPool

    Discussion

    For maximum efficiency, you should create CVPixelBuffer objects for appendPixelBuffer:withPresentationTime: by using this pool with the CVPixelBufferPoolCreatePixelBuffer function.

    This property is NULL before the first call to startSessionAtTime:on the associated AVAssetWriter object.

    This property is key value observable.

    Import Statement

    import AVFoundation

    Availability

    Available in iOS 4.1 and later.

  • The pixel buffer attributes of pixel buffers that will be vended by the adaptor’s CVPixelBufferPool. (read-only)

    Declaration

    Swift

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

    Objective-C

    @property(nonatomic, readonly) NSDictionary *sourcePixelBufferAttributes

    Discussion

    The value of this property is a dictionary containing pixel buffer attributes keys defined in <CoreVideo/CVPixelBuffer.h>.

    Import Statement

    import AVFoundation

    Availability

    Available in iOS 4.1 and later.