Skip to content

Commit

Permalink
[PBE-5141] Enhance RTMP public docs (#690)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbarbugli authored Jul 29, 2024
2 parents 701853c + 7f950de commit c93dc74
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 3 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 72 additions & 3 deletions docusaurus/video/docusaurus/docs/api/streaming/rtmp.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,21 @@ title: RTMP input

import RTMP from '../_common_/rtmp.mdx';

## RTMP input support overview
## RTMP input service overview

Almost all livestream software and hardware supports RTMP. Our API supports using third-party software for streaming using RTMP.
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](../basics/calls.mdx).
The service will transcode the received media to ensure compatibility with WebRTC. It will also publish multiple qualities of it with [Simulcast](https://getstream.io/resources/projects/webrtc/architectures/simulcast/).

_Please not that this page is about publishing video/audio using RTMP, **NOT** watching livestreams using RTMP._
_Please note that this page is about publishing video/audio using RTMP, **NOT** watching livestreams using RTMP._

### About RTMP

[RTMP](https://rtmp.veriskope.com/docs/spec/) is a real-time streaming protocol created by Adobe, as media container format it uses Flash Video [FLV](https://rtmp.veriskope.com/pdf/video_file_format_spec_v10.pdf)
also developed by Adobe.

There's also an enhanced RTMP protocol, created to support a [wider range of newer video codecs](https://veovera.org/docs/enhanced/enhanced-rtmp-v2)
like AV1, HEVC and VP8. OBS for example supports AV1 and HEVC. **RTMP input service doesn’t support them**.

## RTMP publishing

Expand All @@ -35,6 +45,31 @@ You can see an example in the [Quickstart](../../streaming/overview/#test-sendin
style={{ width: '100%' }}
/>

#### 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`

<img
src={require('../assets/rtmp_in_obs_output_settings.png').default}
style={{ width: '50%' }}
/>

_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](https://restream.io/) and create an account.
Expand All @@ -47,3 +82,37 @@ You can see an example in the [Quickstart](../../streaming/overview/#test-sendin
src={require('../assets/rtmp_restream_settings.png').default}
style={{ width: '50%' }}
/>


### 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](#rtmp-publishing).
Run:

```bash
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](#optimal-obs-video-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](#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.

#### What are the recommended internet connection settings for optimal streaming performance?

- **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).

0 comments on commit c93dc74

Please sign in to comment.