Instance Method

startRecordingToOutputFileURL:recordingDelegate:

Starts recording to a given URL.

Declaration

- (void)startRecordingToOutputFileURL:(NSURL *)outputFileURL recordingDelegate:(id<AVCaptureFileOutputRecordingDelegate>)delegate;

Parameters

outputFileURL

An NSURL object containing the URL of the output file.

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

delegate

A object to serve as delegate for the recording session.

Discussion

The method sets the file URL to which the receiver is currently writing output media. If a file at the given URL already exists when capturing starts, recording to the new file will fail.

In macOS, you do not need 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. In iOS, you must call stopRecording before calling this method again to avoid any errors.

When recording is stopped either 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.

In macOS, 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.

Note: AVCaptureAudioFileOutput does not support startRecordingToOutputFileURL:recordingDelegate:. Use startRecordingToOutputFileURL:outputFileType:recordingDelegate: instead.

See Also

Starting, Stopping, Pausing, and Resuming Playback

- stopRecording

Tells the receiver to stop recording to the current file.

- pauseRecording

Pauses recording to the current output file.

- resumeRecording

Resumes recording to the current output file after it was previously paused using pauseRecording.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software