Merge pull request #200 from lm2s/master

Adds support to set AVVideoCodecType, fixes uninitialized property
This commit is contained in:
Jon Andersen 2019-02-17 18:23:05 -05:00 committed by GitHub
commit 9e9dbd370e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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
}