I created an AVCaptureSession and attached to it the front facing camera
do {
try captureSession.addInput(AVCaptureDeviceInput(device: captureDevice))
}catch{print("err")}
Now I want to start and stop recording on touche events. How do I do this?
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
print("touch")
//Start Recording
}
override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
print("release");
//End Recording and Save
}
You didn't mention if you're using
AVCaptureMovieFileOutput
orAVCaptureVideoDataOutput
as an output for your session. The former is well suited for recording a video quickly and without further coding the later is used for more advanced recording by getting chunks ofCMSampleBuffer
during the recording session.For the scope of this answer I'll go with
AVCaptureMovieFileOutput
, here is some minimalist starting code:For more informations on Camera Capture refer to WWDC 2014 - Session 508