Can you copy video frames (screenshots)?

Hi Unrealers,

I’m trying to access individual frames of gameplay - I essentially need to grab 30 screenshots per second. I’ve been able to do this by calling ReadPixels from inside a UObject’s Tick function, and it works fine in the editor. Outside the editor, however, calling ReadPixels results in a null reference ("Access violation reading location 0x0000000000000020).

Has anyone found a way to copy a frame of gameplay outside the editor, a la ReadPixels or GetViewportScreenShot? Something like ReadPixels, which saves a Viewport’s output as a TArray, would be perfect as long as it doesn’t cause crashes. Also looking into alternative strategies.

Sidenote: I’ve seen somebody on AnswerHub who extended the Viewport class to do something like this, but

  1. that seems more complex than it needs to be, just to copy what’s on the screen, and
  2. their solution is locked behind a permission gate on some older forums.

Note that I’m not saving all these screenshots to the disc - I just need to get the color buffer in my code.

If you just need to get at the color buffer why not write a post process material to capture it?

There’s a tutorial on how to do this here: Post Process Materials in Unreal Engine | Unreal Engine Documentation

Is the color buffer really performance intensive? Could that be used in VR?