I was able to get the UMovieSceneCapture
working on my end, so I believe I should be able to help you figure out what’s going wrong on your end.
With just the information that you provided that UMovieSceneCapture::Initialize
is causing the project to crash, I would guess that the problem is that scene_vieport
is null and you’re passing that into Initialize
.
Here is a function I am calling in an actor component class I created that gets created in my player controller class. I’m calling InitializeSceneCapture
in UMyActorComponent::BeginPlay
.
void UMyActorComponent::InitializeSceneCapture()
{
const UWorld* World = this->GetWorld();
if (!World)
{
UE_LOG(LogMyActorComponent, Error, TEXT("InitializeSceneCapture: World was invalid"));
return;
}
UGameViewportClient* GameViewportClient = World->GetGameViewport();
if (!GameViewportClient)
{
UE_LOG(LogMyActorComponent, Error, TEXT("InitializeSceneCapture: Unable to get GameViewport"));
return;
}
TSharedPtr<SViewport> GameViewportWidget = GameViewportClient->GetGameViewportWidget();
if (!GameViewportWidget)
{
UE_LOG(LogMyActorComponent, Error, TEXT("InitializeSceneCapture: Unable to get GameViewport widget"));
return;
}
TSharedPtr<FSceneViewport> SceneViewportPtr = MakeShareable(new FSceneViewport(GameViewportClient, GameViewportWidget));
if (!SceneViewportPtr)
{
UE_LOG(LogMyActorComponent, Error, TEXT("InitializeSceneCapture: Unable to create pointer to TSharedPtr<FSceneViewport>"));
return;
}
if (!this->MovieSceneCapture)
{
UE_LOG(LogMyActorComponent, Error, TEXT("InitializeSceneCapture: MovieSceneCapture was invalid"));
return;
}
this->InitializeSceneCaptureSettings();
this->MovieSceneCapture->Initialize(SceneViewportPtr, 0);
this->MovieSceneCapture->StartWarmup();
this->MovieSceneCapture->StartCapture();
}
This is working for me, so I think
scene_viewport
here is most likely null and that’s causing UMovieSceneCapture::Initialize
to crash.