Class

AVCaptureVideoPreviewLayer

A Core Animation layer that displays the video as it’s captured.

Declaration

@interface AVCaptureVideoPreviewLayer : CALayer

Overview

AVCaptureVideoPreviewLayer is a subclass of CALayer that you use to display video as it’s captured by an input device.

You use this preview layer in conjunction with a capture session, as shown in the following code fragment.

// Create a preview layer.
let previewLayer = AVCaptureVideoPreviewLayer()

// Connect the preview layer with the capturing session.
previewLayer.session = captureSession

// Add the preview layer into the view's layer hierarchy.
view.layer.addSublayer(previewLayer)

Topics

Creating a Preview Layer

+ layerWithSession:

Returns a preview layer initialized with a given capture session.

- initWithSession:

Initializes a preview layer with a given capture session.

- initWithSessionWithNoConnection:

Initializes a preview layer using a given capture session but without making any connections.

+ layerWithSessionWithNoConnection:

Returns a preview layer using a given capture session but without making any connections.

Layer Configuration

videoGravity

Indicates how the layer displays the video content within its bounds.

orientation

The layer’s orientation.

Deprecated
orientationSupported

Indicates whether the layer display supports changing the orientation.

Deprecated
mirrored

Indicates whether the layer display is mirrored.

Deprecated
mirroringSupported

Indicates whether the layer display supports mirroring.

Deprecated
automaticallyAdjustsMirroring

Indicates whether the layer display automatically adjusts mirroring.

Deprecated
previewing

A Boolean value that indicates whether the layer is rendering video frames from its source.

Beta

Session Configuration

session

The previewed capture session.

connection

The capture connection describing the AVCaptureInputPort to which the preview layer is connected.

- setSessionWithNoConnection:

Attaches the layer to a given session without implicitly forming a connection.

Converting Between Coordinate Systems

- captureDevicePointOfInterestForPoint:

Converts a point from layer coordinates to the coordinate space of the capture device.

- pointForCaptureDevicePointOfInterest:

Converts a point from the coordinate space of the capture device to the coordinate space of the layer.

- rectForMetadataOutputRectOfInterest:

Converts a rectangle in the coordinate system used for metadata outputs to one in the preview layer’s coordinate system.

- metadataOutputRectOfInterestForRect:

Converts a rectangle in the preview layer’s coordinate system to one in the coordinate system used for metadata outputs.

- transformedMetadataObjectForMetadataObject:

Converts a metadata object’s visual properties to layer coordinates.

Relationships

Inherits From

See Also

Media Capture Preview

AVCaptureAudioPreviewOutput

A capture output that provides preview playback for audio being recorded in a capture session.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software