# 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/pages/BVX89LL3HSWuDVvGUadK#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/pages/BVX89LL3HSWuDVvGUadK#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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.ozforensics.com/oz-knowledge/guides/developer-guide/sdk/oz-mobile-sdk/ios/capturing-videos.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
