# Capturing Videos

## OzCapsula (SDK v8.22 and newer)

{% hint style="warning" %}
Please note: all required data (other than the video) must be packaged into the container before starting the Liveness screen.
{% endhint %}

Create a controller that will capture videos as follows:

```swift
getSessionToken() { sessionToken in
            DispatchQueue.main.async {
                do {
                    let action:OZVerificationMovement = .selfie
                    let mediaRequest = MediaRequest.action(action)
                    let profile = AnalysisProfile(mediaList: [mediaRequest],
                                                  type: .quality,
                                                  params: [:] )
                    let request = CaptureRequest(analysisProfileList: [profile], cameraPosition: .front)
                    let ozLivenessVC = try OZSDK.createMediaCaptureScreen(self, request, sessionToken: sessionToken)
                    self.present(ozLivenessVC, animated: true)
                } catch let error {
                    print(error.localizedDescription)
                }
            }
        }
```

The delegate object must implement the `OZLivenessDelegate` protocol:

```swift
extension ViewController: LivenessDelegate {
    func onResult(container: DataContainer) {
    }
    func onError(status: OZVerificationStatus?) {
    }
}
```

## SDK 8.21 and older

Create a controller that will capture videos as follows:

```objectivec
let actions: [OZVerificationMovement] = [.selfie]
let ozLivenessVC: UIViewController = OZSDK.createVerificationVCWithDelegate(self, actions: actions)
self.present(ozLivenessVC, animated: true)
```

`action` – a list of user’s [actions](https://doc.ozforensics.com/oz-knowledge/guides/developer-guide/sdk/oz-mobile-sdk/ios-sdk-methods-and-properties#h.20yp3ix24ijd) while capturing the video.

Once video is captured, the system calls the `onOZLivenessResult` method:

```swift
extension viewController: OZLivenessDelegate {
 func onError(status: OZVerificationStatus?) {
        // show error
   }
 }
 func onOZLivenessResult(results: [OZMedia]) {
   // proceed to the checks step
 }
}
```

The method returns the results of video capturing: the `[`[`OZMedia`](https://doc.ozforensics.com/oz-knowledge/guides/developer-guide/sdk/oz-mobile-sdk/ios-sdk-methods-and-properties#h.hizmhq9c5cq9)`]` objects. The system uses these objects to perform checks.

{% hint style="info" %}
If you use our SDK just for capturing videos, omit the Checking Liveness and Face Biometry step.
{% endhint %}

If a user closes the capturing screen manually, the `failedBecauseUserCancelled` error appears.
