> For the complete documentation index, see [llms.txt](https://docs.facephi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.facephi.com/docs.facephi-en/sdks/sdk-mobile/ios-sdk/modulos/video-grabacion.md).

# Video Recording - Videorecording

## Introduction <a href="#id-1-introduccion" id="id-1-introduccion"></a>

The *Component* the one addressed in the current document is called ***VideoRecording Component***. This is responsible for capturing the device screen in the background. It is mainly intended for recording the Onboarding process.

In the section of [Simplified Launch](/docs.facephi-en/sdks/sdk-mobile/ios-sdk/inicializacion/lanzamiento-simplificado.md) the necessary steps for the basic integration of the SDK are detailed. In this section, information is added for the launch of this component.

## Dependencies

To avoid conflicts and compatibility issues, if you want to install the component in a project that contains an old version of the Facephi libraries (*Widgets*), they must be completely removed before installing the components of the ***SDKMobile***.

### CocoaPods

* Currently, FacePhi libraries are distributed remotely through different dependency managers, in this case CocoaPods. The dependencies **required** that must have been installed beforehand (by adding them to the project's Podfile) are:

```swift
  pod 'FPHISDKMainComponent', '~> $VERSION'
```

* To install the Selphi component, the following entry must be included in the application's Podfile:

```swift
  pod 'FPHISDKVideoRecordingComponent', '~> $VERSION'
```

### SPM

* The mandatory dependencies that must have been installed previously are:

```sh
//HTTPS
https://github.com/facephi-clienters/SDK-SdkPackage-SPM.git
//SSH
git@github.com:facephi-clienters/SDK-SdkPackage-SPM.git
```

* To install the SELPHI component, it must be included in the project's modules:

```swift
//HTTPS
https://github.com/facephi-clienters/SDK-VideoRecording-SPM.git
//SSH
git@github.com:facephi-clienters/SDK-VideoRecording-SPM.git
```

## Permissions

In the client application where the components will be integrated, it is necessary to include the following element in the file **Info.plist** when the recording is going to include audio:

```
It is necessary to allow the use of the microphone (NSMicrophoneUsageDescription - Privacy - Microphone Usage Description)
```

{% hint style="info" %}
Microphone permission is only required if you enable **`enableAudio`** in **`VideoRecordingConfigurationData`**. By default **`enableAudio`** is **`false`** and the recording does not capture audio.
{% endhint %}

## Available controllers

| **Controller**           | **Description**                 |
| ------------------------ | ------------------------------- |
| VideoRecordingController | Main video recording controller |

## Simplified Launch

Once the SDK has been started and a new operation has been created, the component can be launched. Any of its controllers can be used to execute its functionality.

### Controller declaration

```swift
private var videoRecordingController: VideoRecordingController?
```

### Starting the capture

To start screen recording:

```swift
public func launchVideoRecording(viewController: UIViewController) {
    let data = VideoRecordingConfigurationData()
    let videoRecordingController = VideoRecordingController(
        data: data,
        viewController: viewController,
        output: {
            print("videoRecordingController output: \($0.errorType)")
        })
    SDKController.shared.launch(controller: videoRecordingController)
    self.videoRecordingController = videoRecordingController
}
```

### Stop the capture

To stop screen recording:

```swift
public func stopVideoRecording() {
    self.videoRecordingController?.stopVideoRecording()
}
```

### Error handling <a href="#id-61-recepcion-de-errores" id="id-61-recepcion-de-errores"></a>

Errors will be returned as a 'VideoRecordingError' object.

Error list:

* VRC\_EMPTY\_LICENSE: The License String is empty
* VRC\_INITIALIZATION\_ERROR: Initialization error
* VRC\_OPERATION\_NOT\_CREATED: There is no operation in progress
* VRC\_NETWORK\_CONNECTION: Internet connection error
* VRC\_PERMISSION\_ERROR: The user has denied the permissions
* VRC\_SOCKET\_ERROR: Error in the services connection
* VRC\_UNKNOWN\_ERROR: Unknown error
* VRC\_VIDEO\_CALL\_ACTIVE: It cannot be started because there is an active Video Call
* VRC\_VIDEO\_ERROR: Error in video processing
* VRC\_VIDEO\_RECORDING\_ACTIVE: It cannot be started because the Video Recording process is active

## Advanced information

This section expands on the component information.

### Advanced component configuration <a href="#id-51-configuracion-avanzada-del-componente" id="id-51-configuracion-avanzada-del-componente"></a>

To launch the current component, an object *VideoRecordingConfigurationData* must be created, which will be the configuration of the component controller.

Below are all the fields that are part of this class.

The fields included in the configuration, normally **do not need to be provided** since they are completed internally through the License used.

These fields are usually reported **only** when the **server** is **On-Premise**.

#### **url**

Path to the video socket

#### **apiKey**

ApiKey required to connect to the video socket

#### **tenantId**

Identifier of the tenant that refers to the current client, required to connect to the video service.

#### **enableAudio**

Flag that allows configuring whether video recording will have audio or not. By default to `false`.

{% hint style="info" %}
If **`enableAudio`** is **`true`**, you must declare the microphone permission in **Info.plist** (see the section [Permissions](#permisos)).
{% endhint %}
