Created
March 7, 2016 19:13
-
-
Save ivanlesko/2ff0695e18f15ae08c55 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func configureSlomoCaptureFormats(formats: [AVCaptureDeviceFormat]) { | |
var bestFormat: AVCaptureDeviceFormat? | |
var bestFrameRateRange: AVFrameRateRange? | |
for format in device.formats as! [AVCaptureDeviceFormat] { | |
// We only want to use 420f media sub types to get the best dynamic range. | |
let mediaSubtype = CMFormatDescriptionGetMediaSubType(format.formatDescription) | |
if mediaSubtype == k420f { | |
// let dimensions = CMVideoFormatDescriptionGetDimensions(format.formatDescription) | |
let ranges = format.videoSupportedFrameRateRanges as! [AVFrameRateRange] | |
let range = ranges.first! | |
let someFormat = CameraFormat(format: format, range: range) | |
print(someFormat) | |
for range in format.videoSupportedFrameRateRanges as! [AVFrameRateRange] { | |
if bestFormat == nil { | |
bestFormat = format | |
bestFrameRateRange = range | |
} | |
if range.maxFrameRate > bestFrameRateRange?.maxFrameRate { | |
bestFormat = format | |
bestFrameRateRange = range | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment