Inherits from AVAssetWriterInput
Declared in AVAssetWriterHapInput.h
AVAssetWriterHapInput.m

Overview

This class is the main interface for using AVFoundation to encode and output video tracks that use the hap codec. You create an instance of this class and add it to an AVAssetWriter just as you would any other instance of AVAssetWriterInput. Any frames you want to encode must then be passed to this class as CVPixelBufferRefs containing pixel data formatted as either RGBA or BGRA (8 bits per channel).

Instance Methods

appendPixelBuffer:withPresentationTime:

Begins encoding the passed pixel buffer asynchronously and appends the encoded frame to this input when complete. This method is equivalent to calling appendPixelBuffer:withPresentationTime:asynchronously: with an asynch value of YES, and is generally appropriate for realtime encoding of video data.

- (BOOL)appendPixelBuffer:(CVPixelBufferRef)pb withPresentationTime:(CMTime)t

Parameters

pb

The passed pixel buffer must be either 8-bit BGRA or RGBA, and will be retained for as long as necessary

t

The time at which this pixel buffer should appear as a frame

Declared In

AVAssetWriterHapInput.h

appendPixelBuffer:withPresentationTime:asynchronously:

Begins encoding the passed pixel buffer and appends the encoded frame to this input when complete.

- (BOOL)appendPixelBuffer:(CVPixelBufferRef)pb withPresentationTime:(CMTime)t asynchronously:(BOOL)a

Parameters

pb

The passed pixel buffer must be either 8-bit BGRA or RGBA, and will be retained for as long as necessary

t

The time at which this pixel buffer should appear as a frame

a

If YES, the pixel buffer will be encoded and appended asynchronously (the method will return immediately, and encoding will happen on another thread). If NO, the pixel buffer will be encoded and appended before this method returns.

Declared In

AVAssetWriterHapInput.h

finishedEncoding

It’s not necessary to check this- but for best results, you should mark the AVAssetWriterHapInput as finished, wait until “finishedEncoding” returns a YES, and then tell your AVAssetWriter to finish writing. If you don’t wait for this method to return YES, the last X pixel buffers may get dropped (depends how long it takes to wrap up, could be no dropped frames, could be a couple).

- (BOOL)finishedEncoding

Declared In

AVAssetWriterHapInput.h

initWithOutputSettings:

Functionally similar to the same method in its superclass- initializes the returned AVAssetWriterInput based on the settings in the passed dictionary.

- (id)initWithOutputSettings:(NSDictionary *)vidOutSettings

Parameters

vidOutSettings

An NSDictionary such as you would pass to any other instance of AVAssetWriterInput- the only difference is that this dict must specify a hap video codec using AVVideoCodecHap, AVVideoCodecHapAlpha, or AVVideoCodecHapQ (defined in this header file). Like the JPEG codec, the hap codec recognizes the AVVideoQualityKey- if the corresponding value > 0.80, a slower, high-quality encoder is used. if the value is <= 0.80 or isn’t specified at all, a fast low-quality encoder is used (the default).

Return Value

Returns nil if the passed dict doesn’t describe a hap video track, otherwise it returns the initialized writer input.

Declared In

AVAssetWriterHapInput.h