<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 10.7.0 -",
    "tvOS: 17.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVCaptureConnection/init(inputPort:videoPreviewLayer:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVCaptureConnection(im)initWithInputPort:videoPreviewLayer:"
  },
  "title" : "init(inputPort:videoPreviewLayer:)"
}
-->

# init(inputPort:videoPreviewLayer:)

Creates a capture connection that represents a connection between an input port and a video preview layer.

```
init(inputPort port: AVCaptureInput.Port, videoPreviewLayer layer: AVCaptureVideoPreviewLayer)
```

## Parameters

`port`

An [`AVCaptureInput.Port`](/documentation/AVFoundation/AVCaptureInput/Port) instance that relates to an [`AVCaptureInput`](/documentation/AVFoundation/AVCaptureInput) instance.

`layer`

An [`AVCaptureVideoPreviewLayer`](/documentation/AVFoundation/AVCaptureVideoPreviewLayer) instance.

## Return Value

A capture connection that represents a connection between `port` and `layer`.

## Discussion

You can add the connection this method returns to an [`AVCaptureSession`](/documentation/AVFoundation/AVCaptureSession) instance with the [`addConnection(_:)`](/documentation/AVFoundation/AVCaptureSession/addConnection(_:)) method.

The [`addInput(_:)`](/documentation/AVFoundation/AVCaptureSession/addInput(_:)): or [`addOutput(_:)`](/documentation/AVFoundation/AVCaptureSession/addOutput(_:)) methods automatically form connections between all compatible inputs and outputs. You don’t need to manually create and add connections to the session unless you use the primitive [`addInputWithNoConnections(_:)`](/documentation/AVFoundation/AVCaptureSession/addInputWithNoConnections(_:)) and [`addOutputWithNoConnections(_:)`](/documentation/AVFoundation/AVCaptureSession/addOutputWithNoConnections(_:)) methods.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)