Contents

videoRotationAngle

A rotation angle the connection applies to a video flowing through it.

Declaration

var videoRotationAngle: CGFloat { get set }

Discussion

Your app can set a video rotation angle that it gets from an AVCaptureDevice.RotationCoordinator instance’s videoRotationAngleForHorizonLevelCapture or videoRotationAngleForHorizonLevelPreview property. The rotation angle only applies to video or depth connections, similar to isVideoMirrored, and can be any angle that isVideoRotationAngleSupported(_:) returns true for.

Not all capture connections rotate each frame. For example, a video connection to an AVCaptureMovieFileOutput or AVCapturePhotoOutput instance applies a rotation with a QuickTime track matrix or with EXIF tags, respectively.

Capture connections to AVCaptureVideoDataOutput and AVCaptureDepthDataOutput instances rotate video frames they provide to their captureOutput(_:didOutput:from:) and depthDataOutput(_:didOutput:timestamp:connection:) delegate methods, respectively. Each AVCaptureVideoDataOutput instance uses hardware acceleration to rotate every frame.

You can rotate the video of a movie file you record with an AVAssetWriter instance by applying the rotation to an AVAssetWriterInput instance’s transform property. This approach avoids the performance costs that come with rotating each video frame.

See Also

Rotating a video