title: captureOutput: didFinishRecordingToOutputFileAtURL is not called
body: <p>I'm a new IOS developer. I create a simple app to record video using back camera. Everything look well but the function <code>captureOutput(captureOutput: AVCaptureFileOutput!, didFinishRecordingToOutputFileAtURL outputFileURL: NSURL!, fromConnections connections: [AnyObject]!, error: NSError!)</code> is never called.</p>
  
  <p>I'm looking forward your helps, thanks! Sorry, my English is not good.
  Here's my whole code:</p>
  
  <pre><code>    import UIKit
  import AVFoundation
  
  class MovieRecordingController: UIViewController, AVCaptureFileOutputRecordingDelegate{
      @IBOutlet var frameForCapture: UIView!
      @IBOutlet var buttonRecord: UIButton!
  
  let aVCaptureDevicePosition = AVCaptureDevicePosition.Back
  let captureSession = AVCaptureSession()
  var previewLayer : AVCaptureVideoPreviewLayer?
  var captureDevice : AVCaptureDevice?
  var captureAudioDevice: AVCaptureDevice?
  var fileOutput : AVCaptureMovieFileOutput!
  
  override func viewDidLoad() {
      super.viewDidLoad()
      captureSession.sessionPreset = AVCaptureSessionPreset640x480
      let devices = AVCaptureDevice.devices()
      for device in devices {
          if (device.hasMediaType(AVMediaTypeVideo)) {
              if(device.position == aVCaptureDevicePosition) {
                  captureDevice = device as? AVCaptureDevice
              }
          }else if device.hasMediaType(AVMediaTypeAudio){
              captureAudioDevice = device as? AVCaptureDevice
          }
      }
      if captureDevice != nil &amp;&amp; captureAudioDevice != nil{
          beginSession()
      }else{
          println("Video or Audio device not found")
      }
  }
  
  func beginSession() {
      configureDevice()
  
      var err : NSError? = nil
      var avCaptureInput = AVCaptureDeviceInput(device: captureDevice, error: &amp;err)
      var audtioCaptureInput = AVCaptureDeviceInput(device: captureAudioDevice, error: &amp;err)
  
      captureSession.addInput(avCaptureInput)
      captureSession.addInput(audtioCaptureInput)
      if err != nil {
          println("error: \(err?.localizedDescription)")
      }
  
      previewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
      self.view.layer.addSublayer(previewLayer)
      previewLayer?.frame = self.frameForCapture.frame
  
      fileOutput = AVCaptureMovieFileOutput()
      var maxDuration = CMTimeMakeWithSeconds(10, 30)
      fileOutput.maxRecordedDuration = maxDuration
      fileOutput.minFreeDiskSpaceLimit = 1024 * 2014
      captureSession.startRunning()
  
      if captureSession.canAddOutput(fileOutput) {
          captureSession.addOutput(fileOutput)
      }else{
          println("Can not add video output")
      }
  }
  
  func configureDevice() {
      if let device = captureDevice {
          device.lockForConfiguration(nil)
          if aVCaptureDevicePosition == AVCaptureDevicePosition.Back{
              device.focusMode = .Locked
          }
          device.unlockForConfiguration()
      }
  }
  
  var isRecording = false;
  @IBAction func record(sender : UIButton) {
      if isRecording {
          isRecording = false
          buttonRecord.setTitle("Record", forState: UIControlState.Normal)
          fileOutput.stopRecording()
      }else{
          isRecording = true
          buttonRecord.setTitle("Stop", forState: UIControlState.Normal)
          let paths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
  
          let documentsDirectory = paths[0] as String
  
          var filePath:String = "file:/\(documentsDirectory)/abc-xyz.mp4"
          var deleteExistFileErr : NSErrorPointer! = nil
          if NSFileManager.defaultManager().fileExistsAtPath(filePath) {
              NSFileManager.defaultManager().removeItemAtPath(filePath, error: deleteExistFileErr)
          }
          var fileUrl = NSURL(string: filePath)
          self.fileOutput.startRecordingToOutputFileURL(fileUrl, recordingDelegate: self)
      }
  }
  
  func captureOutput(captureOutput: AVCaptureFileOutput!, didStartRecordingToOutputFileAtURL fileURL: NSURL!, fromConnections connections: [AnyObject]!) {
      println("Started")
  }
  func captureOutput(captureOutput: AVCaptureFileOutput!, didFinishRecordingToOutputFileAtURL outputFileURL: NSURL!, fromConnections connections: [AnyObject]!, error: NSError!){
      println("Stoped")
  }
  </code></pre>
  
  <p>}</p>