Error when call the LockTexture2D

Hi, I’m working on a plugins to capture the screen of gaming and encode into a stream using ffmpeg.

The following code is used to caputre the screen of gaming

void UFFmpegDirector::GetScreenVideoData()
{
FRHICommandListImmediate& list = GRHICommandList.GetImmediateCommandList();
uint8
TextureData = (uint8*)list.LockTexture2D(GameTexture->GetTexture2D(), 0, EResourceLockMode::RLM_ReadOnly, LolStride, false);
if(Runnable)
Runnable->InsertVideo(TextureData);
list.UnlockTexture2D(GameTexture, 0, false);
}

But when running , the code will cash ,and the reason is
the content of TextureData is error , which is “Invalid character in string” , and when reading the content of TextureData , the code crashed!

So, is there better method? or is there somthing wrong in my code?

Thanks a lot!*
chu

Hello, Have you solved it?