The RTMP target is a generic RTMP Encoder that supports CPU-based encoding (X264) and GPU-based encoding (NVENC). For audio encoding, the RTMP Target supports the AAC encoder.
The component is based on the libraries from the FFmpeg application family and the NVENC library from NVidia.
Using the NVENC encoder (GPU) requires an NVENC-compatible GPU such as the RTXA4000, P2200, P4000, or the T40. Most NVidia GPU:s support NVENC, but the capabilities differ. This matrix can be helpful when determining your GPU features:
https://developer.nvidia.com/video-encode-and-decode-gpu-support-matrix-new
Using the NVENC option is an excellent way of offloading load from the CPU. NVENC does not affect the GPU either, as it is managed by a separate and dedicated chipset. When using multiple instances of the RTMP Target, you can mix between X264 (CPU) and NVENC (GPU).
Autostart when the application starts - Check this option to enable target at application launch. For autostart of targets, the Autostart target options also must be activated on the application level (See the chapter Runtime Performance)
Show advanced option - Toggle to show/hide advanced options.
Addresses:
RTMP server address - The RTMP(S) server address. The address is the first choice of ingesting URL used by the RTMP target.
It is possible to generate a random stream name by using a macro: @@RandomId() or @@HostName()
The generated URL will be displayed in the log, and the field “Current rtmp endpoint”
Example: rtmp://yourrtmpserveraddress/@@RandomId()
Example: rtmp://yourrtmpserveraddress/@@HostName()Backup RTMP server address - An optional backup RTMP server address. If a backup server is provided, Composer will alternate between the primary and the backup server when there is a connection issue and the Rtmp tries to reconnect.
Player URL - (Optional) Playout URL of your stream. Click the "Open Player" button to launch your player in a browser. (Purpose is to have quick access to monitor your playout stream)
Encoder configurations:
Video bitrate - Outgoing video bitrate.
Audio bitrate - outgoing audio bitrate.
H264 B frame distance - the number of b-frames used in a GOP
H264 Gop size - GOP (Group of pictures) length in frames. Typically this is 2x or 1x the framerate. The available options are:
H264 profile - H264 profile. The available options are:
If you are using Vindral CDN and your Vindral Transcoder is set to PASS-THROUGH, you must select the baseline profile to provide support for playback on iOS devices (Web SDK).Audio/Video synchronization - Select an action based on the PTS (Presentation Time Stamp) difference between video and audio. If the PTS differs too much, the audio and video will be out of sync. If the PTS difference exceeds the selected threshold, the RTMP encoder will restart.
CBR configuration
To create a CBR-stream (Constant Bitrate) suitable for live streaming and CDN providers that support adaptive bitrate (ABR), you typically want to create an RTMP output with a stable bitrate. Smaller fluctuation in the bitrate is often ok, but you typically don't want the bitrate to vary too much. This concept is called CBR. For example, depending on the content, a 2Mbit/s stream running a CBR configuration might vary between 1.5 and 2.0Mbit/s.Use CBR configuration - Activates the max and min video-rate multipliers and buffer size
Max video rate (multiplier) - Sets the max video bitrate. The value is a multiplier, typically between 1.0 and 3.0. The maximum video bitrate will be set to multiplier*video bitrate. Example: 1.1*2.4Mbit/s=2.64Mbit/s
Min video rate (multiplier) - Sets the min video bitrate. Same concept as for the Max video rate. The value is a multiplier, typically between 0.5 and 1.0.
Buffer size (multiplier) - Buffer length used by the encoder to maintain max- and min bitrates. Typically this multiplier is set to a value between 0.5 and 3.0. If a low value is specified, the encoder will frequently check for the output bit rate and constrain it to the specified video (average) bit rate. Hence, lowering the buffer lengths reduces the bitrate variation that the encoder can produce. Specifying too small a buffer size would cause the encoder to degrade the output image quality because it would have to (frequently) conform to the limitations and would not have enough free space to use some optimizations (for example, optimizations based on the frame repetitions and similar), because the buffer would not contain enough frames for the optimizations to be effective.
Quality speed control - (H264) controls the encoding speed (versus quality). For ultra low latency setups, very fast or superfast options are common. The alternatives are:
ultrafast, superfast, very fast, faster, fast, medium, slow, slower, very slow, placebo
Tune - (H264) Encoder tuning. Select zero latency for live streaming. The alternatives are:
film, animation, grain, still image, psnr, ssim, fast decode, zero latency
H264 threads - Number of CPU threads used for encoding. The ideal setting depends on your CPU and needs to be tested. The alternatives are:
Zero (auto), One, Two, Three, Four, Five, Six, Seven, Eight
Use NVENC as a video encoder - Option to use NVENC (GPU) for encoding. By using NVENC, the CPU is offloaded. Note: the following options are not applicable for NVENC: Quality Speed Control, Tune, and H264 Threads.
Note!
The number of NVENC-encoders you can run in parallel depends on your GPU model.Advanced options (json) - This configuration is rarely changed. However, there might be use cases where tweaking the low-level parameters of NVENC is needed.
The default value is {"no - scenecut": "1","zerolatency": "1","strict_gop": "1","gpu": "any","preset": "p4","rc": "cbr","delay": "0","rc-lookahead": "0","surfaces": "1"}
CBR with NVENC
In Composer there are two important configurations related to CBR. The first one is the CBR Configuration (see more info earlier in this chapter).
Activate CBR configuration to set max video rate multiplier, min video multiplier, and buffer size. In many cases, the value 1.0 is a good starting point. However, depending on the content, you might wanna adjust these parameters. Unfortunately, there is no single configuration that works for all use cases.
The second part is related to the NVENC configuration parameters. Activate NVENC and adjust the Advanced options:
The parameter that matters for CBR is the rate control parameter ("rc"). Set this to "cbr" (default from Composer version 1.5.x.)
Options:
Warn on low average bitrate (<10%) - if the average outgoing bitrate is less than 10% of the defined bitrate in “Video bitrate”, a warning will be logged.
Reconnect interval - If the RTMP connection terminates/fails, the RTMP Target will reconnect automatically. The reconnect interval determines how long the component will wait until it tries to reconnect.
Max output queue size (packets) - The number of AV-packets used for the outgoing RTMP-buffer. In most use-cases, you do not need to change the default value. However, in scenarios where there the RTMP ingest server is very distant, or if the network connection is jittering, you might set this to a higher value
Allow frame skipping - If the rtmp “output queue size” is high, Composer will skip frames to keep the “output queue size” buffer under the threshold for reconnecting the rtmp connection.
Debug* (debug) (Only visible if "Show debug properties" are enabled in Settings.)
Log bitrate to disk* - (debug) this option is used for analyzing encoded frame sizes. It´s a feature sometimes which can be helpful when studying encoding performance. If activated, Composer will create a .CSV file in the root of the application folder. The .CSV file will have a name based on the GUID of the RTMP Target + date/time. Example: 9da53b93-03ce-41cf-b552-7296c93b555a-2021-07-15T16.54.29.csv The .CSV files can be opened in Excel or similar spreadsheet applications. Content of the .CSV file:
Commands
Start sending - starts the encoder and the RTMP stream
Disconnect - stops the encoder and the RTMP stream
Reconnect - Reconnects the RTMP stream. If both a Primary and Backup RTMP server address is specified, it will alternate between the primary and the backup server address
Current connection status
Rtmp message - the latest message (info, warn, error)
Rtmp message time - Date and time for last Rtmp message
Performance and properties
Outgoing bitrate - current outgoing bitrate
Number of reconnects - the total number of RTMP reconnects since the start
Uptime since start - Time since the RTMP-target was started.
Current RTMP endpoint - The current RTMP server address used (Primary or Backup server address)
Error counter - The number of errors since the RTMP-target was started
Last Error DateTime - Date and time of last error
Warning counter - The number of warnings since the RTMP-target was started
Last Warning DateTime - Date and time of last warning
Rtmp message - “Warning, output queue size high”
This message usually indicates that Composer is having trouble pushing data to the ingest server. The most common reasons are:
No internet connection or insufficient bandwidth
High RTT (Round Trip Time) to the ingest server
Bitrate set too high
Logging
If Use extended logging (in the .prj file, UseExtendedLogging ) is enabled, statistics about the RTMP target are logged. This is by default enabled.
Example:
[2023-09-12 11:53:12.239 [Information] [2055] [SystemLabel] TargetStatistics {"GetStatistics": "", "Name": "RTMP Target", "ConnectionStatus": "Connected", "UpTimeSinceStartTimeSpan": "00:00:18.9664998", "CurrentRTMPEndPoint": "rtmp://myrtmpingesturl.com/live/mystream", "OutgoingBitRateMbitPerSecond": "1.118671", "NumAutoReconnectsperformed": "0", "AverageVideoEncoderTimeMs": "6.6467999999986205", "MaxVideoEncoderTimeMS": "19.94959999999992", "AverageNetworkWriteTimeMs": "0.09729999999763095", "OutputQueueSize": "0", "ErrorCount": "0", "LastErrorDateTime": "", "WarningCount": "0", "LastWarningDateTime": "", "VideoFramesWritten": "569", "AudioFramesWritten": "889"}
RTMP Server Authentication
To connect to an RTMP server that requires authentication, provide the username and password in the server address using the following format: rtmp(s)://username:password@serveradress. Example:
rtmps://myname:mypassword@rtmp.server.com/live/mystream
Ingesting RTMP(S) into CDN:s
Composer is compatible with any CDN that uses RTMP as an ingest.
Vindral Live CDN
Vindral Live CDN is for ultra-low latency playback and can be licensed separately. Find more information in the Vindral Live CDN documentation.
Documentation for Vindral Live CDN is out of scope for this section. However, there are a few things worth mentioning
h264 configuration: if your stream is set up to pass through on the highest bitrate (ask RealSprint for this information):
For playback support on iOS devices:
use h264 profile “baseline”
Do not use b-frames. The number of b-frames should be set to 0.
The ingested stream needs to contain both audio and video. Streams with video only will not be playable.
If you are using the transcoding service for all ABR-streams (qualities), including the highest quality, you can use h264-profiles such as Main or High, as well as B-frames, for your ingest stream.
More information on X264 and NVENC
For more information on LibAv, visit https://libav.org/
For more information on FFMPEG, visit https://www.ffmpeg.org/
For more information on NVENC, visit https://developer.nvidia.com/video-encode-and-decode-gpu-support-matrix-new