Mac Developer Library

Developer

AVFoundation Framework Reference AVCaptureAudioFileOutput Class Reference

Options
Deployment Target:

On This Page
Language:

AVCaptureAudioFileOutput

AVCaptureMovieFileOutput is a concrete sub-class of AVCaptureFileOutput that writes captured audio to any audio file type supported by CoreAudio.

AVCaptureAudioFileOutput implements the complete file recording interface declared by AVCaptureFileOutput for writing media data to audio files. In addition, you can configure options specific to the audio file formats, including writing metadata collections to each file and specifying audio encoding options. AVCaptureAudioFileOutput does not, however, support startRecordingToOutputFileURL:recordingDelegate:—use startRecordingToOutputFileURL:outputFileType:recordingDelegate: instead.

Inheritance


Conforms To


Import Statement


Swift

import AVFoundation

Objective-C

@import AVFoundation;

Availability


Available in OS X v10.7 and later.
  • Returns array containing UTIs identifying the file types AVCaptureAudioFileOutput can write.

    Declaration

    Swift

    class func availableOutputFileTypes() -> [AnyObject]!

    Objective-C

    + (NSArray *)availableOutputFileTypes

    Return Value

    An array containing UTIs identifying the file types AVCaptureAudioFileOutput can write.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

  • Tells the receiver to start recording to a new file of the specified format, and specifies a delegate that will be notified when recording is finished.

    Declaration

    Swift

    func startRecordingToOutputFileURL(_ outputFileURL: NSURL!, outputFileType fileType: String!, recordingDelegate delegate: AVCaptureFileOutputRecordingDelegate!)

    Objective-C

    - (void)startRecordingToOutputFileURL:(NSURL *)outputFileURL outputFileType:(NSString *)fileType recordingDelegate:(id<AVCaptureFileOutputRecordingDelegate>)delegate

    Parameters

    outputFileURL

    The URL of the output file.

    This method throws an NSInvalidArgumentException if the URL is not a valid file URL.

    If a file at the given URL already exists when capturing starts, recording to the new file will fail.

    fileType

    A UTI indicating the format of the file to be written.

    UTIs for common audio file types are declared in AVMediaFormat.h.

    delegate

    An object conforming to the AVCaptureFileOutputRecordingDelegate protocol.

    You must specify a delegate to be notified when recording is finished.

    Discussion

    You do not need not to call stopRecording before calling this method while another recording is in progress. If this method is invoked while an existing output file was already being recorded, no media samples will be discarded between the old file and the new file.

    When recording is stopped—by calling stopRecording, by changing files using this method, or because of an error—the remaining data that needs to be included to the file will be written in the background. Therefore, you must specify a delegate that will be notified when all data has been written to the file using the captureOutput:didFinishRecordingToOutputFileAtURL:fromConnections:error: method. The recording delegate can also optionally implement methods that inform it when data starts being written, when recording is paused and resumed, and when recording is about to be finished.

    On OS X, if this method is called within the captureOutput:didOutputSampleBuffer:fromConnection: delegate method, the first samples written to the new file are guaranteed to be those contained in the sample buffer passed to that method.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

  • The settings used to decode or re-encode audio before it is output by the receiver.

    Declaration

    Swift

    var audioSettings: [NSObject : AnyObject]!

    Objective-C

    @property(nonatomic, copy) NSDictionary *audioSettings

    Discussion

    The value of this property is a dictionary containing values for audio settings keys defined in AVAudioSettings.h. If you set the value of this property to nil, the output vends samples in their device native format.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

  • metadata metadata Property

    A collection of metadata to be written to the receiver's output files.

    Declaration

    Swift

    var metadata: [AnyObject]!

    Objective-C

    @property(nonatomic, copy) NSArray *metadata

    Discussion

    The value of this property is an array of AVMetadataItem objects representing the collection of top-level metadata to be written in each output file. Only ID3 v2.2, v2.3, or v2.4 style metadata items are supported.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.