VR Screenshot

Hello,

I’ve started working with UE4 and C++ two weeks ago, because we’ve switched engines for our newest project at work. So, I need to take a screenshot of a VR application to then display it somewhere else.
So far I’ve encountered two issues:

  1. Whenever I take a screenshot, the game freezes momentarily, so much so that I’m sent back to that Steam aurora hub for a moment. This might be because I’m taking two screenshots, one after another. I do this because I need to place the same screenshot in two different folders.
  2. I can’t figure out how to take a regular 16:9 screenshot while in VR. If I could just crop the feed from one eye to make it 16:9 that would be enough.

Here’s the code I’m using to take the screenshots:

void AScreenShotTaker::BeginPlay()
{
	Super::BeginPlay();
	
	tryToTakeAnotherScreenshot = false;
	timeSinceLastScreenShot = 0.f;

	GetWorldTimerManager().SetTimer(screenShotTimerHandle, this, &AScreenShotTaker::TakeScreenShot, ShotFrequency, true);

}

// Called every frame
void AScreenShotTaker::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	if (tryToTakeAnotherScreenshot && !FScreenshotRequest::IsScreenshotRequested())
	{
		TakeSecondScreenShot();
	}
}

void AScreenShotTaker::TakeSecondScreenShot()
{
	FString fileName2 = ("C:/Users/Me/Downloads/UE4_Prints/ToCast/ReplaceMe.png");
	FScreenshotRequest::RequestScreenshot(fileName2, false, false);
	UE_LOG(LogTemp, Warning, TEXT("File Name 1 : %s"), *fileName2);
	tryToTakeAnotherScreenshot = false;
}

void AScreenShotTaker::TakeScreenShot()
{
	FString fileName("C:/Users/Me/Downloads/UE4_Prints/Archive/KeepMe.png");
	FScreenshotRequest::RequestScreenshot(fileName, false, true);
	tryToTakeAnotherScreenshot = true;
	UE_LOG(LogTemp, Warning, TEXT("File Name 0 : %s"), *fileName);
}

Thank you for your time.

Ok, so I figured that if I use: FString command = TEXT("HighResShot 1920x1080"); GEngine->Exec((), *command); then it solves one of my problems, as now I can get a nice 16:9 image to display on a tv screen.

Unfortunately, this now sends all my screenshots to a default folder, with default image names. I need to send the same picture to two different locations, with different names each.

This method does still cause the application to stutter, taking the user from the VR experience for half a second.
Any idea on how to fix this?

Thank you.

If you making console command in C++ that means you doing something wrong, because those commands just execute C++ code that you can call yourself and you can trace it down by searching UE4 github

command calls TakeHighResScreenShot in FViewport

Which you can get from GEnigne->GameViewport->GetGameViewport , this screen shot system has global config which you can access via this global function

And you can edit those varbales:

It will frezze as this command make super high quality screen shot so it takes longer to render, lowering quality should help it out.

Thank you so much for replying!
I have only just recently started C++ in Unreal. I managed to write a simple function only yesterday.
The documentation on how to use these functions is a bit confusing or lacking.
How would one go about using these?

I’m very late, but I’m finding myself in the same situation today. Taking a screenshot freezes the headset for so long it makes my mechanic unusable. Did you ever find a solution to this problem?