Output game frames to file

This applies to Unreal Engine 4.9

Each frame, I’d like to save it to file (overwriting the existing one).

For a simple D3D11 demo that I have made, I’ve been able to do this with:

void Engine::CaptureFrame(D3DX11_IMAGE_FILE_FORMAT format, const LPCTSTR fileName){

	backbuffer->GetResource(&resource);
	ID3D11Texture2D* texture;
	HRESULT hResult = resource->QueryInterface(__uuidof(ID3D11Texture2D), reinterpret_cast<LPVOID*>(&texture));
	D3DX11SaveTextureToFile(deviceContext, texture, format, fileName);

	//Clean up
	texture->Release();
	resource->Release();
}

I have done this with OpenGL, too, using a library called “FreeImage”.

I don’t want to modify UE4 source and am looking for a way to “hook” into UE4 and “capture” the frame.

I’ve managed to do this with Open Broadcasting Software, but I’d like to do this natively, within UE4, either via c++ or blueprints.

How can I go about this? Is it even possible?