> ## Documentation Index
> Fetch the complete documentation index at: https://docs.liv.tv/llms.txt
> Use this file to discover all available pages before exploring further.

# Recording

> How to use the LIV Camera Kit (LCK) recording subsystem in Unreal Engine, including setup, start/stop recording, async methods, photo capture, and preview mode.

## ULCKRecorderSubsystem

The recorder subsystem manages the complete recording lifecycle as a `UTickableWorldSubsystem`. It handles scene capture, encoder coordination, and audio mixing each tick.

### Class Definition

```cpp theme={null}
UCLASS()
class LCKCORE_API ULCKRecorderSubsystem : public UTickableWorldSubsystem
{
    GENERATED_BODY()

public:
    // Scene capture component for video source
    UPROPERTY(Category = "LCK", BlueprintReadOnly)
    USceneCaptureComponent2D* CaptureComponent;

    // Render target for capture
    UPROPERTY(Category = "LCK", BlueprintReadOnly)
    UTextureRenderTarget2D* RenderTarget;
};
```

### Setup Methods

<ResponseField name="SetupRecorder" type="function">
  Initializes the recorder with parameters and optional capture component.

  ```cpp theme={null}
  UFUNCTION(Category="LCK", BlueprintCallable)
  void SetupRecorder(
      const FLCKRecorderParams& RecorderParams,
      USceneCaptureComponent2D* InitialCaptureComponent = nullptr
  );
  ```
</ResponseField>

<ResponseField name="SetSceneCaptureComponent" type="function">
  Sets or changes the scene capture component used for video source.

  ```cpp theme={null}
  UFUNCTION(Category="LCK", BlueprintCallable)
  void SetSceneCaptureComponent(USceneCaptureComponent2D* NewSceneCaptureComponent);
  ```
</ResponseField>

### Recording Control

<ResponseField name="StartRecording" type="function">
  Begins recording. Returns false if already recording or encoder unavailable.

  ```cpp theme={null}
  UFUNCTION(Category="LCK", BlueprintCallable)
  bool StartRecording();
  ```
</ResponseField>

<ResponseField name="StopRecording" type="function">
  Stops recording and finalizes the video file.

  ```cpp theme={null}
  UFUNCTION(Category="LCK", BlueprintCallable)
  bool StopRecording();
  ```
</ResponseField>

<ResponseField name="TakePhoto" type="function">
  Captures a single frame as a photo.

  ```cpp theme={null}
  UFUNCTION(Category="LCK", BlueprintCallable)
  bool TakePhoto();
  ```
</ResponseField>

### Async Methods

For non-blocking operations with callbacks:

```cpp theme={null}
// Start recording with callback
void StartRecordingAsync(FOnLCKRecorderBoolResult OnResult);

// Stop recording with progress callback
void StopRecordingAsync(
    FOnLCKRecorderBoolResult OnResult,
    FOnLCKRecorderProgress OnProgress
);
```

<CodeGroup>
  ```cpp Async Start theme={null}
  Recorder->StartRecordingAsync(
      FOnLCKRecorderBoolResult::CreateLambda([](bool bSuccess) {
          if (bSuccess)
              UE_LOG(LogTemp, Log, TEXT("Recording started"));
          else
              UE_LOG(LogTemp, Error, TEXT("Failed to start recording"));
      })
  );
  ```

  ```cpp Async Stop theme={null}
  Recorder->StopRecordingAsync(
      FOnLCKRecorderBoolResult::CreateLambda([](bool bSuccess) {
          UE_LOG(LogTemp, Log, TEXT("Recording stopped: %s"),
              bSuccess ? TEXT("Success") : TEXT("Failed"));
      }),
      FOnLCKRecorderProgress::CreateLambda([](float Progress) {
          UE_LOG(LogTemp, Log, TEXT("Save progress: %.1f%%"), Progress * 100.0f);
      })
  );
  ```
</CodeGroup>

### State Queries

<ResponseField name="IsRecording" type="function">
  Returns true if currently recording.

  ```cpp theme={null}
  UFUNCTION(BlueprintCallable, Category = "LCK")
  bool IsRecording() const;
  ```
</ResponseField>

<ResponseField name="GetTime" type="function">
  Returns current recording duration in seconds.

  ```cpp theme={null}
  UFUNCTION(BlueprintCallable, Category = "LCK")
  float GetTime() const;
  ```
</ResponseField>

<ResponseField name="GetMicrophoneVolume" type="function">
  Returns current microphone input level (0.0 - 1.0).

  ```cpp theme={null}
  UFUNCTION(BlueprintCallable, Category = "LCK")
  float GetMicrophoneVolume() const;
  ```
</ResponseField>

### Microphone Control

<ResponseField name="SetMicrophoneEnabled" type="function">
  Enables or disables microphone audio in recordings.

  ```cpp theme={null}
  UFUNCTION(BlueprintCallable, Category = "LCK")
  void SetMicrophoneEnabled(bool bEnabled);
  ```
</ResponseField>

<ResponseField name="IsMicrophoneEnabled" type="function">
  Returns whether microphone audio is enabled.

  ```cpp theme={null}
  UFUNCTION(BlueprintPure, Category = "LCK")
  bool IsMicrophoneEnabled() const;
  ```
</ResponseField>

***

## FLCKRecorderParams

Recording configuration structure.

```cpp theme={null}
USTRUCT(BlueprintType)
struct LCKCORE_API FLCKRecorderParams
{
    GENERATED_BODY()

    UPROPERTY(Category="LCK", EditAnywhere, BlueprintReadWrite)
    int32 Width = 1920;

    UPROPERTY(Category="LCK", EditAnywhere, BlueprintReadWrite)
    int32 Height = 1080;

    UPROPERTY(Category="LCK", EditAnywhere, BlueprintReadWrite)
    int32 Framerate = 30;

    UPROPERTY(Category="LCK", EditAnywhere, BlueprintReadWrite)
    int32 VideoBitrate = 2 << 20;  // 2 Mbps default

    UPROPERTY(Category="LCK", EditAnywhere, BlueprintReadWrite)
    int32 Samplerate = 48000;

    UPROPERTY(Category="LCK", EditAnywhere, BlueprintReadWrite)
    int32 AudioBitrate = 256 << 10;  // 256 Kbps default
};
```

### Recommended Settings

| Quality | Resolution  | FPS | Video Bitrate | Audio Bitrate |
| ------- | ----------- | --- | ------------- | ------------- |
| SD      | 1280 x 720  | 30  | 4 Mbps        | 128 Kbps      |
| HD      | 1920 x 1080 | 60  | 12 Mbps       | 256 Kbps      |
| 2K      | 2560 x 1440 | 60  | 20 Mbps       | 320 Kbps      |
| 4K      | 3840 x 2160 | 60  | 35 Mbps       | 320 Kbps      |

<Warning>
  Higher resolutions significantly impact performance, especially on mobile VR devices. Test thoroughly on target hardware.
</Warning>

***

## Delegates

### FOnLCKRecorderBoolResult

Result callback for async operations.

```cpp theme={null}
DECLARE_DELEGATE_OneParam(FOnLCKRecorderBoolResult, bool /*bSuccess*/);
```

### FOnLCKRecorderProgress

Progress callback for save operations.

```cpp theme={null}
DECLARE_DELEGATE_OneParam(FOnLCKRecorderProgress, float /*Progress*/);
```

***

## Preview Mode

For live camera preview without recording:

```cpp theme={null}
// Start preview (capture frames but don't encode)
Recorder->StartPreview();

// Stop preview
Recorder->StopPreview();
```

<Tip>
  Preview mode is useful for camera composition and settings adjustment before recording.
</Tip>
