AVOutputSettingsAssistant Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AVFoundation.framework
Availability
Available in iOS 7.0 and later.
Declared in
AVOutputSettingsAssistant.h

Overview

The AVOutputSettingsAssistant class specifies a set of parameters for configuring objects that use output settings dictionaries—so that the resulting media file conforms to a specific criteria.

For example, instances of AVOutputSettingsAssistant are often created using a string constant representing a specific preset configuration, such as AVOutputSettingsPreset1280x720. After an instance is configured, its properties are used as a guide for creating and configuring an AVAssetWriter object and one or more AVAssetWriterInput objects. The preset configuration properties can be used as a “base” configuration, which can be customized to suit your individual needs.

The suggested output settings improve as more information is provided about the format of the source data. For example, by setting the sourceVideoFormat property, the videoSettings property value ensures that video frames are not scaled up from a smaller size.

Tasks

Creating an Output Settings Assistant

Getting Output Settings Recommendations

Properties

audioSettings

A dictionary containing the values to be used when creating an AVAssetWriterInput instance. (read-only)

@property(nonatomic, readonly) NSDictionary *audioSettings
Discussion

The value of this property may change as a result of setting a new value for the sourceAudioFormat property. See AV Foundation Audio Settings Constants for keys and values.

This property does not support key-value observing.

Availability
  • Available in iOS 7.0 and later.
Declared In
AVOutputSettingsAssistant.h

outputFileType

A UTI indicating the type of file to be written. (read-only)

@property(nonatomic, readonly) NSString *outputFileType
Discussion

To get a suitable file extension for a given file type, use the UTTypeCopyPreferredTagWithClass function with the kUTTagClassFilenameExtension constant.

This property does not support key-value observing.

Availability
  • Available in iOS 7.0 and later.
Declared In
AVOutputSettingsAssistant.h

sourceAudioFormat

A CMAudioFormatDescriptionRef object describing the format of the audio data.

@property(nonatomic, retain) CMAudioFormatDescriptionRef sourceAudioFormat
Discussion

Setting this property will allow the output settings assistant to make a more informed recommendation for the audio settings that should be used. After setting this property, you should re-query the audioSettings property to get the new recommendation. The default value is NULL, which means that the output settings assistant does not know anything about the format of the audio data.

When setting a non-NULL value for this property and using the output settings assistant to initialize an AVAssetWriterInput instance, the same format description should be used to initialize the AVAssetWriterInput, along with the dictionary from the audioSettings property.

Availability
  • Available in iOS 7.0 and later.
Declared In
AVOutputSettingsAssistant.h

sourceVideoAverageFrameDuration

A time describing the average frame duration, the reciprocal of the average frame rate) of the video data.

@property(nonatomic) CMTime sourceVideoAverageFrameDuration
Discussion

Setting this property allows the output settings assistant to make a more informed recommendation for the video settings that should be used. After setting this property, you should re-query the videoSettings property to get the new recommendation.

The default value is 1/30, which means that the output settings assistant is assuming that your source video has a frame rate of 30fps.

Availability
  • Available in iOS 7.0 and later.
Declared In
AVOutputSettingsAssistant.h

sourceVideoFormat

A core media video format description object describing the format of the video data

@property(nonatomic, retain) CMVideoFormatDescriptionRef sourceVideoFormat
Discussion

Setting this property will allow the output settings assistant to make a more informed recommendation for the video settings that should be used. After setting this property, you should re-query the videoSettings property to get the new recommendation. The default value is NULL, which means that the output settings assistant does not know anything about the format of your video data.

When setting a non-NULL value for this property and using the output settings assistant to initialize an AVAssetWriterInput instance, the same format description should be used to initialize the AVAssetWriterInput, along with the dictionary from the videoSettings property.

Availability
  • Available in iOS 7.0 and later.
Declared In
AVOutputSettingsAssistant.h

sourceVideoMinFrameDuration

A time describing the minimum frame duration, the reciprocal of the maximum frame rate, of the video data.

@property(nonatomic) CMTime sourceVideoMinFrameDuration
Discussion

Setting this property allows the output settings assistant to make a more informed recommendation for the video settings that should be used. After setting this property, you should re-query the videoSettings property to get the new recommendation.

If the source of video data is an instance of AVAssetReaderOutput, you can discover the minimum frame duration of your source asset using the AVAssetTrack instance’s minFrameDuration property.

The default value is 1/30, which means that the output settings assistant is assuming that the source video has a maximum frame rate of 30fps.

Availability
  • Available in iOS 7.0 and later.
Declared In
AVOutputSettingsAssistant.h

videoSettings

A dictionary containing the values to be used when creating an AVAssetWriterInput instance. (read-only)

@property(nonatomic, readonly) NSDictionary *videoSettings
Discussion

The value of this property may change as a result of setting a new value for the sourceVideoFormat property. See Video Settings for the supported keys and values.

This property does not support key-value observing.

Availability
  • Available in iOS 7.0 and later.
Declared In
AVOutputSettingsAssistant.h

Class Methods

availableOutputSettingsPresets

Returns the array of presets that should be used to create an output settings assistant.

+ (NSArray *)availableOutputSettingsPresets
Return Value

An array of strings , each of which is a preset identifier.

Discussion

Each preset in the returned list can be passed in to the outputSettingsAssistantWithPreset: class method to create a new instance of the class.

Special Considerations

On iOS, the returned array may differ according to the device model.

Availability
  • Available in iOS 7.0 and later.
Declared In
AVOutputSettingsAssistant.h

outputSettingsAssistantWithPreset:

Creates and initializes an output setting assistant with the given preset.

+ (instancetype)outputSettingsAssistantWithPreset:(NSString *)presetIdentifier
Parameters
presetIdentifier

The preset identifier.

Return Value

An initialized AVOutputSettingsAssistant instance with the presetIdentifier value.

Discussion

The properties of the returned object can be used as a guide for creating and configuring an AVAssetWriter object and one or more AVAssetWriterInput objects. If all the suggested properties are respected in creating the AVAssetWriter, the resulting media file will conform to the criteria implied by the preset.

Availability
  • Available in iOS 7.0 and later.
Declared In
AVOutputSettingsAssistant.h

Constants

AVOutputSettingsPreset Values

Preset output sizes.

NSString * const AVOutputSettingsPreset640x480;
NSString * const AVOutputSettingsPreset960x540;
NSString * const AVOutputSettingsPreset1280x720;
NSString * const AVOutputSettingsPreset1920x1080;
Constants
AVOutputSettingsPreset640x480

Sets the output size to 640 x 480 pixels.

Available in iOS 7.0 and later.

Declared in AVOutputSettingsAssistant.h.

AVOutputSettingsPreset960x540

Sets the output size to 960 x 540 pixels.

Available in iOS 7.0 and later.

Declared in AVOutputSettingsAssistant.h.

AVOutputSettingsPreset1280x720

Sets the output size to 1280 x 720 pixels.

Available in iOS 7.0 and later.

Declared in AVOutputSettingsAssistant.h.

AVOutputSettingsPreset1920x1080

Sets the output size to 1920 x 1080 pixels.

Available in iOS 7.0 and later.

Declared in AVOutputSettingsAssistant.h.

Discussion

When source format information is supplied with these presets, the resulting video settings will not scale up the video from a smaller size. These constants are for use with outputSettingsAssistantWithPreset:.