Class: AVAssetExportSession

Inherits:
NSObject show all

Overview

An AVAssetExportSession object transcodes the contents of an AVAsset source object to create an output of the form described by a specified export preset.

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from NSObject

#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version

Constructor Details

This class inherits a constructor from NSObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NSObject

Instance Attribute Details

- (AVAsset) asset (readonly)

The asset with which the export session was initialized. (read-only)

Returns:

- (AVAudioMix) audioMix

Indicates whether non-default audio mixing is enabled for export, and supplies the parameters for audio mixing. You can observe this property using key-value observing.

Returns:

- (NSError) error (readonly)

Describes the error that occurred if the export status is AVAssetExportSessionStatusFailed or AVAssetExportSessionStatusCancelled. (read-only) If there is no error to report, the value of this property is nil.

Returns:

- (Integer) estimatedOutputFileLength (readonly)

Indicates the estimated size in bytes of the exported file. (read-only)

Returns:

- (Integer) fileLengthLimit

The maximum number of bytes that the session is allowed to write to the output URL. The export will stop when the output reaches this size regardless of the duration of the source or the value of timeRange.You can observe this property using key-value observing.

Returns:

- (CMTime) maxDuration (readonly)

The maximum duration that is allowed for export. (read-only) You can observe this property using key-value observing.

Returns:

  • (CMTime)

- (Array) metadata

The metadata to be written to the output file by the export session. The metadata is an array of AVMetadataItem objects.If the value of this key is nil, any existing metadata in the exported asset will be translated as accurately as possible into the appropriate metadata key space for the output file and written to the output.You can observe this property using key-value observing.

Returns:

- (String) outputFileType

The type of file to be written by the session. The value is a UTI string corresponding to the file type to use when writing the asset. For a list of constants specifying UTIs for standard file types, see AV Foundation Constants Reference.You can observe this property using key-value observing.

Returns:

- (NSURL) outputURL

The URL of the export session’s output. You can observe this property using key-value observing.

Returns:

- (String) presetName (readonly)

The name of the preset with which the session was initialized. (read-only) For possible values, see “Export Preset Names for Device-Appropriate QuickTime Files,” “Export Preset Names for QuickTime Files of a Given Size,” AVAssetExportSessionStatusCancelled, “Export Preset Name for iTunes Audio,” and “Export Preset Name for Pass-Through.”You can observe this property using key-value observing.

Returns:

- (Float) progress (readonly)

The progress of the export on a scale from 0 to 1. (read-only) A value of 0 means the export has not yet begun, 1 means the export is complete.

Returns:

- (Boolean) shouldOptimizeForNetworkUse

Indicates whether the movie should be optimized for network use. You can observe this property using key-value observing.

Returns:

  • (Boolean)

- (AVAssetExportSessionStatus) status (readonly)

The status of the export session. (read-only) For possible values, see “AVAssetExportSessionStatus.”You can observe this property using key-value observing.

Returns:

  • (AVAssetExportSessionStatus)

- (Array) supportedFileTypes (readonly)

The types of files the session can write. (read-only) The types of files the session can write are determined by the asset and and export preset with which the session was initialized. If you need to determine the compatible file formats before initiating the export operation, use the determineCompatibleFileTypesWithCompletionHandler: method.You can observe this property using key-value observing.

Returns:

- (CMTimeRange) timeRange

The time range to be exported from the source. The default time range of an export session is kCMTimeZero to kCMTimePositiveInfinity, meaning that (modulo a possible limit on file length) the full duration of the asset will be exported.You can observe this property using key-value observing.

Returns:

  • (CMTimeRange)

- (Object) videoComposition

Indicates whether video composition is enabled for export, and supplies the instructions for video composition. You can observe this property using key-value observing.

Returns:

Class Method Details

+ (Array) allExportPresets

Returns all available export preset names. Not all presets are compatible with all assets.

Returns:

  • (Array)

    An array containing a string constant for each of the available preset names.For possible values, see “Export Preset Names for Device-Appropriate QuickTime Files,” “Export Preset Names for QuickTime Files of a Given Size,” AVAssetExportSessionStatusCancelled, “Export Preset Name for iTunes Audio,” and “Export Preset Name for Pass-Through.”

+ (Object) determineCompatibilityOfExportPreset(presetName, withAsset:asset, outputFileType:outputFileType, completionHandler:handler)

Reports the compatibility of an export present, asset, and output file type to the specified block. Because not all export presets are compatible with all assets and file types, you can use this method to query the compatibility of specific combos before using them. To ensure that the export operation succeeds, you should not make any significant changes to the asset between the time of calling this method and performing the export operation. This method performs its checks asynchronously on a secondary thread and returns immediately. The results are similarly reported to the specified block on a secondary thread.

Parameters:

  • presetName

    The name of the preset template for the export operation.For possible values, see “Export Preset Names for Device-Appropriate QuickTime Files,” “Export Preset Names for QuickTime Files of a Given Size,” AVAssetExportSessionStatusCancelled, “Export Preset Name for iTunes Audio,” and “Export Preset Name for Pass-Through.”

  • asset

    The asset object that you are planning to export.

  • outputFileType

    The UTI string corresponding to the file type. For example, to specify a QuickTime movie file format, you could specify the constant AVFileTypeQuickTimeMovie. For a list of constants specifying UTIs for standard file types, see AV Foundation Constants Reference.

  • handler

    The block to execute with the results. This method makes a copy of the specified block. This parameter must not be nil.This block takes a single Boolean parameter and returns no result. The parameter contains the value YES if the combination of options is compatible or NO if they are not.

Returns:

+ (Array) exportPresetsCompatibleWithAsset(asset)

Returns the identifiers compatible with a given asset. Not all export presets are compatible with all assets. For example, a video-only asset is not compatible with an audio-only preset. This method returns only the identifiers for presets that are compatible with the given asset. In order to ensure that the setup and running of an export operation will succeed using a given preset, you should not make significant changes to the asset (such as adding or deleting tracks) between retrieving compatible identifiers and performing the export operation.If the asset’s tracks are not currently loaded, they may be loaded by this method before any checks are performed.

Parameters:

  • asset (AVAsset)

    An asset that is ready to be exported.

Returns:

  • (Array)

    An array of NSString objects representing the identifiers compatible with asset.The array is a complete list of the valid identifiers that can be used with exportSessionWithAsset:presetName: with the specified asset. For possible values, see “Export Preset Names for Device-Appropriate QuickTime Files,” “Export Preset Names for QuickTime Files of a Given Size,” AVAssetExportSessionStatusCancelled, “Export Preset Name for iTunes Audio,” and “Export Preset Name for Pass-Through.”

+ (Object) exportSessionWithAsset(asset, presetName:presetName)

Returns an asset export session configured with a specified asset and preset.

Parameters:

  • asset (AVAsset)

    The asset you want to export.

  • presetName (String)

    A string constant specifying the name of the preset template for the export.For possible values, see “Export Preset Names for Device-Appropriate QuickTime Files,” “Export Preset Names for QuickTime Files of a Given Size,” AVAssetExportSessionStatusCancelled, “Export Preset Name for iTunes Audio,” and “Export Preset Name for Pass-Through.”

Returns:

  • (Object)

    An asset export session initialized to export asset using preset presetName.

Instance Method Details

- (Object) cancelExport

Cancels the execution of an export session. You can invoke this method when the export is running.

Returns:

- (Object) determineCompatibleFileTypesWithCompletionHandler(handler)

Reports the compatible file types for the current export session to the specified block. This method operates on the asset object and preset information that was used to initialize the export session. It uses this information to determine the file types that the export session can write. This method performs its checks asynchronously on a secondary thread and returns immediately. The results are similarly reported to the specified block on a secondary thread. Because this method actually inspects the asset’s tracks, the tracks are loaded if they have not been already.

Parameters:

  • handler

    The block to execute with the results. This method makes a copy of the specified block. This parameter must not be nil.This block takes an array parameter and returns no result. The array contains zero or more NSString objects with the UTIs of the compatible file types. The file types are in no particular order. For a list of constants specifying UTIs for standard file types, see AV Foundation Constants Reference.

Returns:

- (Object) exportAsynchronouslyWithCompletionHandler(handler)

Starts the asynchronous execution of an export session. This method starts an asynchronous export operation and returns immediately. status signals the terminal state of the export session, and if a failure occurs, error describes the problem.If internal preparation for export fails, handler is invoked synchronously. The handler may also be called asynchronously, after the method returns, in the following cases:If a failure occurs during the export, including failures of loading, re-encoding, or writing media data to the output.If cancelExport is invoked.After the export session succeeds, having completely written its output to the outputURL.

Parameters:

  • handler

    A block that is invoked when writing is complete or in the event of writing failure.

Returns:

- (Object) initWithAsset(asset, presetName:presetName)

Initializes an asset export session with a specified asset and preset.

Parameters:

  • asset (AVAsset)

    The asset you want to export.

  • presetName (String)

    A string constant specifying the name of the preset template for the export.For possible values, see “Export Preset Names for Device-Appropriate QuickTime Files,” “Export Preset Names for QuickTime Files of a Given Size,” AVAssetExportSessionStatusCancelled, “Export Preset Name for iTunes Audio,” and “Export Preset Name for Pass-Through.”

Returns:

  • (Object)

    An asset export session initialized to export asset using preset presetName.