title: GPUImage Video Recording
body: <p>I have been trying to create use the GPUImage library to record a video from camera, filter it and save to camera roll.</p>
  
  <p>The GPUImageMovieWriter is causing me some issues. Here is my code:</p>
  
  <pre><code>    //Set up the GPUImageVideoCamera
      videoCamera = GPUImageVideoCamera(sessionPreset: AVCaptureSessionPreset640x480, cameraPosition: .Back)
      videoCamera.outputImageOrientation = .Portrait;
      videoCamera.horizontallyMirrorFrontFacingCamera = true
      videoCamera.horizontallyMirrorRearFacingCamera = false
  
      //Create filter with view
      filter = GPUImageFilter()
      filterView = GPUImageView(frame: self.view.frame)
      filterView.fillMode = kGPUImageFillModePreserveAspectRatioAndFill;
      self.view.addSubview(filterView)
  
      pathToMovie = NSHomeDirectory().stringByAppendingPathComponent("stream.mp4")
      unlink((pathToMovie as NSString).UTF8String)
      var movieURL = NSURL.fileURLWithPath(pathToMovie)
      movieWriter = GPUImageMovieWriter(movieURL: movieURL, size: CGSizeMake(640, 480))
      movieWriter.encodingLiveVideo = true
  
      //Attach targets
      videoCamera.addTarget(filter)
      filter.addTarget(filterView)
      filter.addTarget(movieWriter)
  
      //Start capture
      videoCamera.startCameraCapture()
      movieWriter.startRecording()
  </code></pre>
  
  <p>The app crashes with the following debugger output (when startRecording() method is called ):</p>
  
  <blockquote>
    <p>[AVAssetWriter startWriting] Cannot call method when status is 3</p>
  </blockquote>
  
  <p>Any clues as to why this is occurring? Why is the AVAssetWriter's Status being .Failed?</p>
  
  <p>Note that all variables are properties of my class.</p>