RTMP Server
RTMP/RTMPS server for Unreal Engine: receive OBS and FFmpeg streams, serve viewers with view keys, Blueprint nodes and C++ usage.
The RTMP server accepts publishers (OBS, FFmpeg, another Unreal) and makes their audio and video available to an RTMP Receiver. It can also let RTMP clients (VLC, ffplay, OBS) watch those streams. See the RTMP overview for complete flows.
Unreal Engine 5.8 and DirectX 12 only
RTMP is supported only on Unreal Engine 5.8, Win64, with the DirectX 12 RHI. Set Project Settings > Platforms > Windows > Default RHI to DirectX 12. On DirectX 11 or Vulkan the GPU encoder refuses to start, and publishing fails with an error.
References
How to use
Blueprint: search by GetInternetProtocolSubsystem and call CreateRTMPServer function
C++: Use the code bellow
#include "rtmp/rtmpserver.h"
URTMPServer* Server = NewObject<URTMPServer>(this);
FServerBindOptions Bind;
Bind.Address = TEXT("0.0.0.0");
Bind.Port = 1935;
Server->Open(Bind);Variables
Backlog
- Set/Get the maximum number of pending connections the server will accept in queue.
Nodes
Is Open
- Return true if the server is listening.
Local Endpoint
- Get the local endpoint of the server. Use this function only after
Open.
Get Error Code
- Return a struct of the latest error code.
Open
- Opens the listening socket. The RTMP default port is
1935. - It returns false if the server is already open or if any error happens during the bind.
On Listeningis triggered on success. Addressmust be an IP literal,localhostor empty (any address). Host names are not resolved: they, and ports outside 0-65535, fail with anInvalid argumenterror.- Publishers connect to
rtmp://<this machine>:<port>/<app>/<stream key>.
Close
- Close the server and every publisher and viewer connection. 'on_close' event will be triggered.
Set Allowed Stream Keys
- Restricts which stream keys may publish. An empty array accepts any key.
- A publisher using a key that is not allowed is refused with
NetStream.Publish.Unauthorized. - A second publisher using a key that is already live is refused (
NetStream.Publish.BadName). - Keys are kept in memory only (never a saved property), so they never end up in versioned config.
Set Tls Options
- Enables RTMPS (RTMP over TLS) for the next
Open. Publishers and viewers then usertmps://. - Requires a certificate and a private key. See Security Context Options.
Clear Tls Options
- Disables RTMPS for the next
Open.
Playback
Playback lets RTMP clients (VLC, ffplay, an OBS Media Source, another Unreal) watch the streams published to this server. It is off by default. Viewers never get the publishing key: each stream is reached through a separate view key, at rtmp://<this machine>:<port>/<app>/<view key>.
- Each viewer costs the full stream bitrate in upload bandwidth.
- Each viewer has a bounded send queue: under congestion P-frames are dropped and the stream resumes at the next keyframe.
- Viewers stay connected while the publisher reconnects.
Set Playback Enabled
- Allows RTMP clients to watch published streams. Applies immediately.
Max Viewers Per Stream:0means unlimited.
Is Playback Enabled
- Return true if playback is enabled.
Set Playback Key
- Lets viewers watch
App/Stream Keyby openingrtmp://host:port/App/View Key. - Returns false if
View Keyis empty or equal toStream Key(that would reveal the publishing key). - Several view keys may point to the same stream.
Remove Playback Key
- Removes one view key of
App.
Clear Playback Keys
- Removes every view key.
Get Viewer Count
- Number of clients currently watching streams of
App. An emptyAppcounts every app.
Events
Stream keys are secrets
Stream Name in the publish events is the stream key sent by the publisher. Never show or log it. The plugin never logs keys, and playback events never report them.
On Listening
- This event will be triggered when the server starts listening.
On Publish Started
- A publisher started sending a stream.
On Publish Ended
- A publisher stopped or disconnected. More streams may start later with the same key.
On Play Started
- A client started watching a stream of
App.
On Play Ended
- A client stopped watching a stream of
App.
On Close
- Event triggered when the server is closed.
On Error
- Event triggered if any error occur during async process.
RTMP Overview
Live audio and video over RTMP/RTMPS in Unreal Engine: receive OBS or FFmpeg streams, serve viewers, pull from servers and publish to Twitch or YouTube.
RTMP Receiver
Play live RTMP/RTMPS streams in Unreal Engine 5.8: video texture for materials and UMG, spatialized audio, low latency mode, pull from servers and Media Framework.