IVideoRecordingSystem
可以实现在Game下的录制
#include "VideoRecordingSystem.h"
#include "PlatformFeatures.h"
//初始化
IVideoRecordingSystem* VideoRecordSystem = IPlatformFeaturesModule::Get().GetVideoRecordingSystem();
VideoRecordSystem->EnableRecording(true);
FVideoRecordingParameters param;
param.RecordingLengthSeconds = 6000;//设置的最大录制时间,不会录制超过的时间
//开始录制
VideoRecordSystem->NewRecording(TEXT("MyVideo"), param);
VideoRecordSystem->StartRecording();
//结束录制
IVideoRecordingSystem* VideoRecordSystem = IPlatformFeaturesModule::Get().GetVideoRecordingSystem();
VideoRecordSystem->FinalizeRecording(true, FText::FromString("Hello"), FText::FromString("World"));
ISequenceRecorder
在Editor下使用,可以录制一段Sequence,保存在固定的文件夹下。
#include "ISequenceRecorder.h"
//开始录制
ISequenceRecorder& Recorder = FModuleManager::LoadModuleChecked<ISequenceRecorder>("SequenceRecorder");
Recorder.StartRecording(this, "/Game/Sequence", "RecordedSequence");
//停止录制
ISequenceRecorder& Recorder = FModuleManager::LoadModuleChecked<ISequenceRecorder>("SequenceRecorder");
Recorder.StopRecording();
创建蓝图节点
VideoRecordBlueprint.h
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "VideoRecordBlueprint.generated.h"
UCLASS(Blueprintable, BlueprintType, meta = (DisplayName = "Record a Video"))
class VIDEORECORD_API UVideoRecordBueprint : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
//开始录制
UFUNCTION(BlueprintCallable, Category = "VideoRecording")
static bool StartRecording(const FString& Name);
//停止录制
UFUNCTION(BlueprintCallable, Category = "VideoRecording")
static bool StopRecording();
};
VideoRecordBlueprint.cpp
#include "VideoRecordBlueprint.h"
#include "VideoRecordingSystem.h"
#include "PlatformFeatures.h"
bool UVideoRecordBueprint::StartRecording(const FString& Name)
{
IVideoRecordingSystem* VideoRecordSystem = IPlatformFeaturesModule::Get().GetVideoRecordingSystem();
VideoRecordSystem->EnableRecording(true);
FVideoRecordingParameters param;
param.RecordingLengthSeconds = 6000;
VideoRecordSystem->NewRecording(*Name, param);
VideoRecordSystem->StartRecording();
return true;
}
bool UVideoRecordBueprint::StopRecording()
{
IVideoRecordingSystem* VideoRecordSystem = IPlatformFeaturesModule::Get().GetVideoRecordingSystem();
VideoRecordSystem->FinalizeRecording(true, FText::FromString("Hello"), FText::FromString("World"));
return true;
}
在关卡中的调用:
V按下M键实现播放一段Sequence,结束后会在项目文件的Saved\VideoCaptures下生成对应MP4文件。

录制Sequence.png