The front facing camera on iPhone 16 (and every model previous) gives the following values for AVCaptureDevice.RotationCoordinator.videoRotationAngleForHorizonLevelCapture:
90 degrees portrait
180 degrees landscape left
270 degrees for upside-down
0 degrees for landscape right
Using these values a transform is calculated:
var transform: CGAffineTransform {
let degrees = rotationCoordinator.videoRotationAngleForHorizonLevelCapture
let radians = degrees * .pi / 180.0
return CGAffineTransform(rotationAngle: radians)
}
And then applied to the AVAssetInput:
videoInput = AVAssetWriterInput(mediaType: .video,
outputSettings: videoSettings,
sourceFormatHint: videoFormatDescription)
videoInput.transform = transform
And this ensures the correct transform is added to the metadata so that the recorded video plays in the correct orientation.
However, with the iPhone 17 Pro and iPhone 17 Pro Max front facing cameras, AVCaptureDevice.RotationCoordinator.videoRotationAngleForHorizonLevelCapture return the different values:
0 degrees portrait
90 degrees landscape left
180 degrees for upside-down
270 degrees for landscape right
So this approach breaks down, and the video orientation is incorrect. How is this intended to be handled?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Any opinions on creating ObservableObjects as a singleton vs injecting a objects as EnvironmentObjects? Example 1, the singleton, works, but I'm not a fan
// MARK: - Example 1
class Singleton: ObservableObject {
@Published var someProperty: Bool
static var shared = Singleton()
private init() {
someProperty = true
}
}
struct SomeView: View {
@ObservedObject var singleton = Singleton.shared
var body: some View {
Text("Hello Woild")
}
}
// MARK: - Example 2
class SomeClass: ObservableObject {
@Published var someProperty: Bool
init() {
someProperty = true
}
}
struct SomeApp: App {
@StateObject var someClass = SomeClass()
var body: some Scene {
WindowGroup {
SomeView()
.environmentObject(someClass)
}
}
}
struct SomeOtherView: View {
@EnvironmentObject var someClass: SomeClass
var body: some View {
Text("Hello Woild")
}
}```