Instance Method

startRecordingToOutputFileURL:recordingDelegate:

Starts recording media to the specified output URL.

Declaration

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

Parameters

outputFileURL

An object specifying the output file URL.

This method raises an NSInvalidArgumentException if the argument isn’t a valid file URL.

delegate

A delegate object that’s notified of changes to the recording state.

Discussion

A failure occurs if you attempt to record to a URL where a file exists. To overwrite the content, delete the old file before calling this method.

In macOS, calling this method from within the captureOutput:didOutputSampleBuffer:fromConnection: method guarantees that the first samples written to the new file are those passed to the delegate method.

When you stop recording by calling stopRecording, by changing files using this method, or because of an error, the framework writes any remaining file data in the background. Therefore, for the system to notify you upon completion, you must adopt the captureOutput:didFinishRecordingToOutputFileAtURL:fromConnections:error: delegate method. The recording delegate can also optionally implement methods that inform it when the output object starts writing data, when it pauses or resumes recording, and when it’s about to finish recording.

In macOS, you don’t need to call stopRecording before calling this method while another recording is in progress. If you call this method while the output object is recording, the framework preserves media samples between the old file and the new file. In iOS, to avoid any errors, you must call stopRecording before calling this method again.

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.