To solve this problem I changed the AVCaptureDevice's frame rate just like the last answer in this post AVCapture capturing and getting framebuffer at 60 fps in iOS 7
In order to get the captureOutput function to run at the same speed as the camera you have to add the AVCaptureDeviceInput before you change the AVCaptureDevice's frame rate.
Here's what the code ended up looking like for Swift 3:
do{
input = try AVCaptureDeviceInput(device: backCamera)
if (error == nil && (captureSession?.canAddInput(input))!)
{
captureSession?.addInput(input)
}
var finalFormat = AVCaptureDeviceFormat()
var maxFPS: Double = 0
for vformat in (backCamera?.formats)!{
var ranges = (vformat as AnyObject).videoSupportedFrameRateRanges as! [AVFrameRateRange]
let frameRates = ranges[0]
if frameRates.maxFrameRate >= maxFPS && frameRates.maxFrameRate <= 120.0{
maxFPS = frameRates.maxFrameRate
finalFormat = vformat as! AVCaptureDeviceFormat
}
}
if maxFPS != 0{
let timeValue = Int64(1200.0 / maxFPS)
let timeScale: Int64 = 1200
try backCamera!.lockForConfiguration()
backCamera!.activeFormat = finalFormat
//print("CAMER FPS: \(backCamera?.activeFormat.videoSupportedFrameRateRanges.description)\n")
backCamera!.activeVideoMinFrameDuration = CMTimeMake(timeValue, Int32(timeScale))
backCamera!.activeVideoMaxFrameDuration = CMTimeMake(timeValue, Int32(timeScale))
backCamera!.focusMode = AVCaptureFocusMode.autoFocus
backCamera!.unlockForConfiguration()
}
}catch{
print("Problem setting FPS\n")
exit(0)
}