Instance Method

initWithMediaType:outputSettings:sourceFormatHint:

Initialize a writer input object with the specified media type, output settings, and source hint.

Declaration

- (instancetype)initWithMediaType:(AVMediaType)mediaType outputSettings:(NSDictionary<NSString *,id> *)outputSettings sourceFormatHint:(CMFormatDescriptionRef)sourceFormatHint;

Parameters

mediaType

The media type of the samples to be accepted by the input object. For a list of media types, see AVFoundation Constants.

outputSettings

Specify a dictionary containing the settings used for encoding the media appended to the output. You may pass nil for this parameter if you do not want the appended samples to be re-encoded.

Audio output settings keys are defined in AV Foundation Audio Settings Constants. Video output settings keys are defined in AVFoundation Constants. Video output settings with keys from <CoreVideo/CVPixelBuffer.h> are not currently supported.

sourceFormatHint

This parameter contains a hint of the type of the format buffers to be appended. If you specify a value for this parameter, the writer input object may be able to fill in missing output settings or perform more upfront validation. If you specify a value for this property, you should make sure that the buffers you append are of the indicated type.

Return Value

An initialized writer input object that can accept samples of the specified media type and write them to the output file.

Discussion

Each new input accepts data for a new track of the asset writer’s output file. You add an input to an asset writer using the AVAssetWriter method addInput:.

Passing nil for output settings instructs the input to pass through appended samples, doing no processing before they are written to the output file.  This is useful if, for example, you are appending buffers that are already in a desirable compressed format.  However, if not writing to a QuickTime Movie file (i.e. the AVAssetWriter was initialized with a file type other than AVFileTypeQuickTimeMovie), AVAssetWriter only supports passing through a restricted set of media types and subtypes.  In order to pass through media data to files other than AVFileTypeQuickTimeMovie, a non-NULL format hint must be provided.

See Also

Creating an Asset Writer Input Instance

+ assetWriterInputWithMediaType:outputSettings:

Returns a new writer input object initialized with the specified media type and output settings.

+ assetWriterInputWithMediaType:outputSettings:sourceFormatHint:

Returns a new writer input object initialized with the specified media type, output settings, and source format hint.

- initWithMediaType:outputSettings:

Initialize a writer input object with the specified media type and output settings.

Video Settings Dictionaries

Define output image and video formats by using the key and value constants.