iOS Developer Library

Developer

AVFoundation Framework Reference AVOutputSettingsAssistant Class Reference

Options
Deployment Target:

On This Page
Language:

AVOutputSettingsAssistant

Inheritance


Conforms To


Import Statement


Swift

import AVFoundation

Objective-C

@import AVFoundation;

Availability


Available in iOS 7.0 and later.

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.

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

    Declaration

    Swift

    convenience init!(preset presetIdentifier: String!)

    Objective-C

    + (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.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.

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

    Declaration

    Swift

    class func availableOutputSettingsPresets() -> [AnyObject]!

    Objective-C

    + (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.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.

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

    Declaration

    Swift

    var outputFileType: String! { get }

    Objective-C

    @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.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.

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

    Declaration

    Swift

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

    Objective-C

    @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.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.

  • A CMAudioFormatDescriptionRef object describing the format of the audio data.

    Declaration

    Swift

    var sourceAudioFormat: CMAudioFormatDescription!

    Objective-C

    @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.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.

    See Also

    audioSettings

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

    Declaration

    Swift

    var sourceVideoAverageFrameDuration: CMTime

    Objective-C

    @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.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.

    See Also

    videoSettings

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

    Declaration

    Swift

    var sourceVideoFormat: CMVideoFormatDescription!

    Objective-C

    @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.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.

    See Also

    videoSettings

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

    Declaration

    Swift

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

    Objective-C

    @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.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.

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

    Declaration

    Swift

    var sourceVideoMinFrameDuration: CMTime

    Objective-C

    @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.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.

    See Also

    videoSettings

  • Preset output sizes.

    Declaration

    Swift

    let AVOutputSettingsPreset640x480: String let AVOutputSettingsPreset960x540: String let AVOutputSettingsPreset1280x720: String let AVOutputSettingsPreset1920x1080: String

    Objective-C

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

    Constants

    • AVOutputSettingsPreset640x480

      AVOutputSettingsPreset640x480

      Sets the output size to 640 x 480 pixels.

      Available in iOS 7.0 and later.

    • AVOutputSettingsPreset960x540

      AVOutputSettingsPreset960x540

      Sets the output size to 960 x 540 pixels.

      Available in iOS 7.0 and later.

    • AVOutputSettingsPreset1280x720

      AVOutputSettingsPreset1280x720

      Sets the output size to 1280 x 720 pixels.

      Available in iOS 7.0 and later.

    • AVOutputSettingsPreset1920x1080

      AVOutputSettingsPreset1920x1080

      Sets the output size to 1920 x 1080 pixels.

      Available in iOS 7.0 and later.

    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:.