Unreal Engine 5 Example for receiving video streams over RTSP (using FSockets and FRunnables) and displaying their image data in a texture.
MIT License
Example code for receiving video streams over RTSP using Unreal Engine FSockets and displaying them in real time.
https://github.com/finger563/unreal-rtsp-display/assets/213467/64270d95-f223-43ef-885b-599e607d48b1
When running this example, you will need to configure the address, port, and path of your RTSP server on the actor:
Note: this example currently only supports MJPEG streams over RTSP, which are parsed with the RtpJpegPacket class into JpegFrames. This example uses Unreal Engine's built-in image decoding to decode the jpeg frames into uncompressed image data for use in a UTexture2D.
This example contains a few components:
RtspClientComponent
class: This component can be added to an actor andRtpPacket
, RtpJpegPacket
, JpegHeader
, and JpegFrame
classes whichMyRunnable
class: used by the RtspClientComponent when it connects to aM_Display
and M_Display_Inst
: these assets in the Content/MaterialsRtspDisplay
: This blueprint actor contains an RtspClientComponent and aW_RtspDisplay
: This user widget contains the UI (2D) for interacting with aRtspDisplayMap
's levelImage of the running example in the editor:
Disconnected (With text box to write URI and connect button): Connected: Playing:
Note the image has been set with angle 180 and X scale of -1 so that it matches the camera image that I'm currently sending. May need to be changed for other streams depending on camera orientation.
Its blueprint:
Follow the setup instructions here.
Note: you will likely have to modify the /Users/Shared/Epic\ Games/UE_5.2/Engine/Extras/Android/SetupAndroid.command
file - possibly to
point to the right JAVA_HOME
directory. In my case I had to modify the
JAVA_HOME export in the SetupAndroid.command
file to point to
/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
and had
to install jdk8 specifically.
You will need to set the environment variables (under Android SDK
)
appropriately, e.g.:
Android SDK
: /Users/bob/Library/Android/sdk
Android NDK
: /Users/bob/Library/Android/sdk/ndk/25.1.8937393
Location of JAVA
: /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
SDK API Level
: android-32
NDK API Level
: android-32
For that version of java (jdk 8) which is required to successfully build for android, you can (on macos) install it via:
brew install --cask adoptopenjdk8