hello, I have been battling with unreal engine all day. I’m trying to grab the texture data off of a render target using the RHI functions. I eventually want to stream the texture data using LibVLC.
Capture is SceneCapture2D component, VideoTexture is of type UTexture. VideoBuffer is of type TArray .
When I place that actor in the level and I play the game, unreal editor freezes and and I have to kill UE with the task manager.
All I want to do is grab the texture data off of the render target of a SceneCapture2D so that I can then stream the data over a network. The solutions that I’ve seen here already don’t work.
Thank you. I’m on mobile so please excuse my punctuation.
Figured it out. Just use that GameThread_RenderTargetResource function in the TextureRenderTarget2D and then use the ReadPixels function to get the pixel data.
Hi, I’m not sure if this approach still works because I did this back in 4.7.6. Even if it does still work, I wouldn’t recommend using this approach because at most I was able to stream out at 8 FPS, which is horrible.
I actually found a much better way of doing this using OBS (https://obsproject.com/) and using a nginx as an RTMP server. Then I could connect to the nginx server with VLC and display the stream on my custom app.
The problem with this approach is that there is a lot of latency. The picture I was getting was about 2-3 seconds behind the actual gameplay.
If you really need the picture to be real-time, your best bet is to make an OBS plugin that interfaces directly with VLC.
As far as I can see this is not a viable solution, at least not in 4.16.2.
The comments for GameThreadRender_GetRenderTargetResource state:
Returns a pointer to the (game thread managed) render target resource. Note that you’re not allowed to deferenced [sic] this pointer on the game thread, you can only pass the pointer around and check for NULLness