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();
TextureData = (uint8*)list.LockTexture2D(GameTexture->GetTexture2D(), 0, EResourceLockMode::RLM_ReadOnly, LolStride, false);
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!*

Hello, Have you solved it?