videoRotationAngle
A rotation angle the connection applies to the video flowing through it.
Declaration
var videoRotationAngle: CGFloat { get set }Discussion
Set this property to an angle that an AVCaptureDevice.RotationCoordinator instance provides to keep video level relative to gravity. Only 0, 90, 180, and 270 are valid angles. Setting any other value raises an NSInvalidArgumentException, so confirm that a connection supports an angle with isVideoRotationAngleSupported(_:). The property applies only to video and depth connections.
Setting an angle doesn’t always rotate pixels. A connection to an AVCaptureMovieFileOutput instance records the rotation in a QuickTime track matrix, and a connection to an AVCapturePhotoOutput instance records it in Exif tags. Connections to AVCaptureVideoDataOutput and AVCaptureDepthDataOutput instances deliver physically rotated buffers instead, which costs work on every frame. Setting an angle on those connections also reconfigures the capture render pipeline, so set it before calling startRunning().
If your app rotates buffers itself, set videoRotationAngle to 0 to keep the connection from rotating them again. If your app applies a coordinator’s angles with its own math, account for the property’s current value. Account for it on every device rather than only the devices where the default differs, which keeps the same code correct as hardware changes.
A connection doesn’t rotate ProRes RAW buffers. When your app captures ProRes RAW, set this property to 0 and apply a coordinator’s angles to those buffers yourself.
To rotate a movie that your app writes with an AVAssetWriter instance, set transform rather than rotating through the connection, which avoids paying for a rotation on every frame.