Adds support to set AVVideoCodecType, fixes uninitialized property

This commit is contained in:
Luís Silva 2019-02-14 21:36:42 +00:00
parent b0b51e346d
commit 1bbeb0da5e

View file

@ -125,7 +125,7 @@ open class SwiftyCamViewController: UIViewController {
/// Sets whether flash is enabled for photo and video capture
@available(*, deprecated, message: "use flashMode .on or .off") //use flashMode
public var flashEnabled: Bool {
public var flashEnabled: Bool = false {
didSet{
self.flashMode = self.flashEnabled ? .on : .off
}
@ -293,6 +293,10 @@ open class SwiftyCamViewController: UIViewController {
return allowAutoRotate
}
/// Sets output video codec
public var videoCodecType: AVVideoCodecType? = nil
// MARK: ViewDidLoad
/// ViewDidLoad Implementation
@ -781,6 +785,15 @@ open class SwiftyCamViewController: UIViewController {
if connection.isVideoStabilizationSupported {
connection.preferredVideoStabilizationMode = .auto
}
if #available(iOS 11.0, *) {
if let videoCodecType = videoCodecType {
if movieFileOutput.availableVideoCodecTypes.contains(videoCodecType) == true {
// Use the H.264 codec to encode the video.
movieFileOutput.setOutputSettings([AVVideoCodecKey: videoCodecType], for: connection)
}
}
}
}
self.movieFileOutput = movieFileOutput
}