Skip to main content

ULCKRecorderSubsystem

The recorder subsystem manages the complete recording lifecycle as a UTickableWorldSubsystem.

Class Definition

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

SetupRecorder
function
Initializes the recorder with parameters and optional capture component.
UFUNCTION(Category="LCK", BlueprintCallable)
void SetupRecorder(
    const FLCKRecorderParams& RecorderParams,
    USceneCaptureComponent2D* InitialCaptureComponent = nullptr
);
SetSceneCaptureComponent
function
Sets or changes the scene capture component used for video source.
UFUNCTION(Category="LCK", BlueprintCallable)
void SetSceneCaptureComponent(USceneCaptureComponent2D* NewSceneCaptureComponent);

Recording Control

StartRecording
function
Begins recording. Returns false if already recording or encoder unavailable.
UFUNCTION(Category="LCK", BlueprintCallable)
bool StartRecording();
StopRecording
function
Stops recording and finalizes the video file.
UFUNCTION(Category="LCK", BlueprintCallable)
bool StopRecording();
TakePhoto
function
Captures a single frame as a photo.
UFUNCTION(Category="LCK", BlueprintCallable)
bool TakePhoto();

Async Methods

For non-blocking operations with callbacks:
// Start recording with callback
void StartRecordingAsync(FOnLCKRecorderBoolResult OnResult);

// Stop recording with progress callback
void StopRecordingAsync(
    FOnLCKRecorderBoolResult OnResult,
    FOnLCKRecorderProgress OnProgress
);
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"));
    })
);

State Queries

IsRecording
function
Returns true if currently recording.
UFUNCTION(BlueprintCallable, Category = "LCK")
bool IsRecording() const;
GetTime
function
Returns current recording duration in seconds.
UFUNCTION(BlueprintCallable, Category = "LCK")
float GetTime() const;
GetMicrophoneVolume
function
Returns current microphone input level (0.0 - 1.0).
UFUNCTION(BlueprintCallable, Category = "LCK")
float GetMicrophoneVolume() const;

Microphone Control

SetMicrophoneEnabled
function
Enables or disables microphone audio in recordings.
UFUNCTION(BlueprintCallable, Category = "LCK")
void SetMicrophoneEnabled(bool bEnabled);
IsMicrophoneEnabled
function
Returns whether microphone audio is enabled.
UFUNCTION(BlueprintPure, Category = "LCK")
bool IsMicrophoneEnabled() const;

FLCKRecorderParams

Recording configuration structure.
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
};
QualityResolutionVideo BitrateAudio Bitrate
SD1280 x 7202-4 Mbps128-256 Kbps
HD1920 x 10804-8 Mbps256 Kbps
2K2560 x 14408-12 Mbps256 Kbps
4K3840 x 216012-20 Mbps320 Kbps
Higher resolutions significantly impact performance, especially on mobile VR devices. Test thoroughly on target hardware.

Delegates

FOnLCKRecorderBoolResult

Result callback for async operations.
DECLARE_DELEGATE_OneParam(FOnLCKRecorderBoolResult, bool /*bSuccess*/);

FOnLCKRecorderProgress

Progress callback for save operations.
DECLARE_DELEGATE_OneParam(FOnLCKRecorderProgress, float /*Progress*/);

Preview Mode

For live camera preview without recording:
// Start preview (capture frames but don't encode)
Recorder->StartPreview();

// Stop preview
Recorder->StopPreview();
Preview mode is useful for camera composition and settings adjustment before recording.