Keep a reference to the AVCaptureMovieFileOutput
. That will come in handy.
Anyway, there is a method of that class that can be called like so:
[[self movieFileOutput] startRecordingToOutputFileURL:url recordingDelegate:self];
where url
is a file URL on the device, such as the documents directory. This allows it to start recording. You also might want to note that you can stop it by calling [[self movieFileOutput] stopRecording];
. You also need to implement the AVCaptureFileOutputRecordingDelegate
methods to handle callbacks. These methods are called when recording begins and ends, as so:
-(void)captureOutput:(AVCaptureFileOutput *)captureOutput
didStartRecordingToOutputFileAtURL:(NSURL *)fileURL
fromConnections:(NSArray *)connections;
-(void)captureOutput:(AVCaptureFileOutput *)captureOutput
didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL
fromConnections:(NSArray *)connections error:(NSError *)error;
You must implement these delegate methods to handle what happens when you begin and end recording. In the didFinishRecording
method, you can then mess around with AVAssetURL
s, tracks, compositions, and all sorts of things before exporting it as a final movie. Really cool stuff. However it is a decently hard framework and frustrating at times when things seem to be backwards - FYI there are three types of orientations on iOS devices, so the rotation of video will make you want to pull your hair out.
I could literally go on for days about features and frustrations, though, so just be sure to consult Apple's docs whenever possible. This should get you on the right track!