feat: Video Stabilization (#160)

* Set video stabilization mode

* Fix video stabilization below iOS 13

* swift format
This commit is contained in:
Marc Rousavy
2021-06-03 15:42:02 +02:00
committed by GitHub
parent e5fe5ab175
commit 0b5d277514
5 changed files with 53 additions and 2 deletions

View File

@@ -0,0 +1,28 @@
//
// AVCaptureSession+setVideoStabilizationMode.swift
// VisionCamera
//
// Created by Marc Rousavy on 02.06.21.
// Copyright © 2021 Facebook. All rights reserved.
//
import AVFoundation
import Foundation
extension AVCaptureSession {
/**
Set the given video stabilization mode for all capture connections.
*/
func setVideoStabilizationMode(_ mode: String) {
if #available(iOS 13.0, *) {
guard let mode = try? AVCaptureVideoStabilizationMode(withString: mode) else {
return
}
connections.forEach { connection in
if connection.isVideoStabilizationSupported {
connection.preferredVideoStabilizationMode = mode
}
}
}
}
}