RTMP input

RTMP input service overview

RTMP input is a service designed to bridge the gap between RTMP (Real-Time Messaging Protocol) and WebRTC (Web Real-Time Communication). It enables users to stream content using an RTMP client, such as OBS (Open Broadcaster Software), and have that content published to participants in a Call. The service will transcode the received media to ensure compatibility with WebRTC. It will also publish multiple qualities of it with Simulcast.

Please note that this page is about publishing video/audio using RTMP, NOT watching livestreams using RTMP.

About RTMP

RTMP is a real-time streaming protocol created by Adobe, as media container format it uses Flash Video FLV also developed by Adobe.

There’s also an enhanced RTMP protocol, created to support a wider range of newer video codecs like AV1, HEVC and VP8. OBS for example supports AV1 and HEVC. RTMP input service doesn’t support them.

RTMP publishing

This is how you can acquire the necessary information for publishing RTMP using a third-party software.

const resp = await call.get();

// userId of existing user
const userId = 'jane';
await client.upsertUsers([{ id: userId }]);
const token = client.generateUserToken({ user_id: userId });
const rtmpURL = resp.call.ingress.rtmp.address;
const streamKey = token;

console.log(rtmpURL, streamKey);

The user(s) streaming from the third-party software will show up as regular users in the call.

You can see an example in the Quickstart.

Streaming into a call with OBS

  1. Open OBS and go to Settings (CMD +, on macOS).
  2. Set the Stream Type to Custom.
  3. Set the URL to the rtmp_url you got from the API.
  4. Set the Stream Key to the stream_key you got from the API.

Rtmp Obs Settings

Optimal OBS Video Encoding Settings

To ensure optimal quality and performance when transcoding media from RTMP, follow these recommended H.264 encoding settings:

Go to Settings:

Video:

  • Base Resolution: 1920x1080
  • Output Resolution: 1920x1080 (Same as input resolution)

Output:

  • Encoder: x264
  • Rate Control: CBR (Constant Bit Rate)
  • Bitrate: 3,000-6,000 kbps (adjust based on your network and type of media being streamed, higher movement will require higher bitrate)
  • Keyframe Interval: 2 seconds
  • CPU Usage Preset: veryfast (balance between quality and encoding speed)
  • Tune: zerolatency

Rtmp In Obs Output Settings

The example is for OBS, but any other RTMP client should support adding the same settings

Streaming into a call with restream.io

  1. Go to restream.io and create an account.
  2. For streaming to a custom RTMP server, you need to have a paid account.
  3. Add a new channel and select Custom RTMP.
  4. Set the Server to the rtmp_url you got from the API.
  5. Set the Stream Key to the stream_key you got from the API.

Rtmp Restream Settings

Streaming a file into a call with FFmpeg

With your call’s RTMP url $CALL_RTMP_URL and your token streamKey $STREAM_KEY from publishing. Run:

ffmpeg -re -stream_loop 400 -i YourVideoFile1080p30fps.mp4 \
  -c:v libx264 -preset veryfast -tune zerolatency \
  -pix_fmt yuv420p -g 50 -c:a aac -b:a 160k \
  -ac 2 -f flv "$CALL_RTMP_URL/$STREAM_KEY"

FAQ

What is the typical latency introduced by RTMP?

RTMP input typically introduces a latency of 2-5 seconds. This can vary based on the network conditions, encoder settings (as the stream will be transcoded), and the performance of the RTMP server. Optimizing encoding settings and ensuring a stable network connection can help minimize this latency.

What are the best practices for setting up OBS for RTMP streaming?

Refer to Optimal OBS Video Encoding Settings.

Do we support both RTMP and RTMPS?

RTMP input service supports exclusively RTMPS. RTMPS is the recommended for secure streaming as it uses SSL/TLS to encrypt the data, providing an additional layer of security over RTMP.

  • Upload Speed: At least double the target bitrate of your stream. For example, if streaming at 5,000 kbps, ensure an upload speed of at least 10 Mbps.
  • Connection Type: Wired Ethernet connection is preferred over Wi-Fi for stability.
  • Network Quality: Ensure low packet loss (<1%) and low jitter (<30ms).
© Getstream.io, Inc. All Rights Reserved.