RTMP Ingest Setup and Usage
This article provides an overview of how to set up and use Phenix's RTMP ingest.
Since an RTMP stream is sent from an encoder to Phenix via RTMP, the encoder must be set up to send its output to Phenix. This means that, while the Phenix Customer Portal can be used to obtain information such as the stream key, the Portal's publishing tab cannot be used to publish RTMP to the Phenix platform.
Encoder Configuration for RTMP Ingest
Your encoder's configuration must be set up to ensure that it is not introducing unnecessary latency. The number one issue that causes high latency is not using the correct low-latency settings on the local encoder.
For details on setting up your source, please refer to RTMP Encoder Settings.
Measure Latency
To characterize the latency of the encoder, try measuring the lag using ffplay with the "nobuffer" setting. Using ffplay is always recommended to determine the baseline latency when evaluating encoder settings. The argument will be similar to:
ffplay -fflags nobuffer "<url>"
If the latency is not extremely low, that indicates that the encoder is not configured correctly for low latency.
Encoding Settings
Check that encoder settings are set to the lowest possible values that will provide acceptable results, such as baseline profile, CBR, 5 Mbps, 1-second GOP size.
Phenix supports H.264-encoded video as ingest, and recommends using Constrained Baseline Profile up to Level 5.2 with a maximum frame size of 36864 macro-blocks for best performance. Be sure to verify that features such as scene change detection are not enabled to keep the encoding consistent. Some video feeds using may appear to work initially, but will fail when certain unsupported features are used (e.g., when the encoding is optimized for a high motion scene).
The source bitrate must be less than 8Mbps, with no spikes in the bitrate exceeding that value. There must be zerolatency interleaving, and no grouping of audio or video packets. The audio and video packets should be in strict increasing order based on the timestamp in the signal.
The audio must be 48kHz AAC, either mono or stereo, MPEG-2 ADTS, not MPEG-4 LOAS/LATM.
Single-Bitrate Output
When using single-bitrate output (i.e., when the multi-bitrate capability is not set), the video quality/resolution is not changed; that is, the same video quality input is the quality that is output.
For example, if FHD video is provided to Phenix via RTMP, and the output quality is set to SD, the output will be FHD.
AWS Elemental Live Encoder
Various parameters may need to be modified to optimize for smooth playback. For Elemental Live version="2.22.4.1632837480838", use the following:
-
Protocol="RTMP"
-
Key points for smooth playback:
-
Scene Change Detection="off"
-
Use Baseline Profile of H.264
-
GOP Size(keyframe interval)="1 Sec"
-
Repeat PPS=True #Places a PPS header on each encoded picture, even if repeated.
-
Slices="1"
-
Adaptive Quantization="Auto"
-
Use AAC-LC Stereo 128kbps Sample Rate "48kHz"
-
vMix
To ensure minimal latency, use the following recommended settings for vMix:
-
Video Bit Rates: 2500, Encode Size 1280x720, Audio Bit Rate 128
-
Video
-
Profile: Baseline
-
Level: 2/1
-
Preset: ultrafast
-
-
Audio
- Format: AAC
-
Keyframe Frequency: 1 second
-
Network Buffer: the lowest setting allowed
-
Check both boxes for Strict CBR and Keyframe Aligned
LiveU
To ensure minimal latency, use the following recommended settings for LiveU encoders. All settings can be accessed from the LiveU Central website.
Unit Configuration
Set the unit configuration options as follows:
-
Adaptive Resolution: "Off"
-
Video Complexity: "Standard"
-
Audio Channels: "2 Channels"
-
Audio Bit Rate: "96kbps/AAC-LC"
Streaming Destination
For the Streaming Destination, use the following settings:
-
Stream Type: "RTMP"
-
Destination Name: A unique name for this destination.
-
Provider: "General (No Auth)"
-
Primary URL: "rtmp://ingest.phenixrts.com:80/ingest/"
-
Stream ID: the stream key of the destination Phenix channel (96 characters), followed by any capabilities that you want to add to the stream, separated by a pipe ( | ) character. Example:
96characterStreamKey|capabilities=hd,multi-bitrate
, where96characterStreamKey
is the stream key to be used when publishing, which can be found in the Customer Portal under the Properties tab for a Channel or Room. -
Video Profile: Custom, or select the preset value that corresponds to your highest desired output resolution
-
Resolution (not available if using a preset video profile): your desired resolution, e.g., 1280x720
-
Bit Rate (not available if using a preset video profile): a value higher than the bitrate shown for your resolution in the Phenix Qualities table, e.g., 3.6 Mbps for hd quality
-
Max Frame Rate (not available if using a preset video profile): “Keep source frame rate”
FFMPEG
When using ffmpeg, be sure to use the zerolatency option to get real-time output. This is not set automatically. Without the zerolatency setting the encoder will introduce 0.5 seconds of end-to-end latency out of the gate. Please refer to the ffmpeg documentation for details.
An example ffmpeg command to create test content is:
ffmpeg -re -f lavfi -i testsrc=size=1280x720:rate=30 -f lavfi -i aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) | 0.1*sin(2*PI*(360+2.5/2)*t)" -pix_fmt yuv420p -vcodec libx264 -profile:v baseline -deblock 1:0 -bitrate 500k -tune zerolatency -x264opts keyint=30 -acodec aac -ar 48000 -ac 2 -b:a 128k -f flv "rtmp://ingest.phenixrts.com:80/ingest/96characterStreamKey;capabilities=hd,multi-bitrate,mpegts-unicast-ingest;tags=my-awesome-stream-id"
Where 96characterStreamKey
is the stream key to be used when publishing, which can be found in the Customer Portal under the Properties tab for a Channel or Room.
On MacOS and Linux, you may need to add quotation marks around the second argument in order to not lose information after the semicolon:
"rtmp://ingest.phenixrts.com:80/ingest/96characterStreamKey;capabilities=hd,multi-bitrate,mpegts-unicast-ingest;tags=my-awesome-stream-id"
To measure latency, add a timestamp overlay:
ffmpeg -re -f lavfi -i testsrc=size=1280x720:rate=30 -f lavfi -i aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) | 0.1*sin(2*PI*(360+2.5/2)*t)" -pix_fmt yuv420p
-vf "drawtext=text='timestamp: %{pts \: hms}': x=20: y=20: fontsize=72:fontcolor=white@0.9: box=1: boxcolor=black@0.6"
-vcodec libx264 -profile:v baseline -deblock 1:0 -bitrate 500k -tune zerolatency -x264opts keyint=30 -acodec aac -ar 48000 -ac 2 -b:a 128k -f flv "rtmp://ingest.phenixrts.com:80/ingest/96characterStreamKey;capabilities=hd,multi-bitrate,mpegts-unicast-ingest;tags=my-awesome-stream-id"
Where 96characterStreamKey
is the stream key to be used when publishing, which can be found in the Customer Portal under the Properties tab for a Channel or Room.
An example of the resulting video stream in the Portal's Details page is shown below.
API Usage
For details on API usage, please refer to the RTMP REST API.
Example
An example RTMP URL is:
rtmp://ingest.phenixrts.com:80/ingest/96characterStreamKey;capabilities=hd,multi-bitrate,tags=my-awesome-stream-id
Where 96characterStreamKey
is the stream key to be used when publishing, which can be found in the Customer Portal under the Properties tab for a Channel or Room.
When using the URL, especially in command-line arguments, be sure to enclose it in quotation marks to avoid truncation of the capabilities.