react-native-vision-camera/ios/Extensions/AVCaptureVideoDataOutput+setOrientation.swift
Marc Rousavy 9c579c65aa
try: Improvements from WWDC 2021 1:1 workshop (#197)
* perf: Automatically determine Pixel Format depending on active format. (More efficient video recording 🚀)
* perf: Skip `AVAssetWriter` transform by directly correctly orienting the Video Output connection
* feat: Support camera flipping while recording
* feat: Run frame processor on separate queue, avoids stutters in video recordigns
* feat: Automatically drop late frame processor frames
2021-06-11 21:06:19 +02:00

25 lines
665 B
Swift

//
// AVCaptureVideoDataOutput+setOrientation.swift
// Cuvent
//
// Created by Marc Rousavy on 18.01.21.
// Copyright © 2021 mrousavy. All rights reserved.
//
import AVFoundation
extension AVCaptureVideoDataOutput {
func setOrientation(forCameraPosition position: AVCaptureDevice.Position) {
let isMirrored = position == .front
connections.forEach { connection in
if connection.isVideoMirroringSupported {
connection.automaticallyAdjustsVideoMirroring = false
connection.isVideoMirrored = isMirrored
}
if connection.isVideoOrientationSupported {
connection.videoOrientation = .portrait
}
}
}
}