RTP
An output type that allows streaming video and audio from Smelter over RTP.
Usage
To use RTP Output you must register it first. You can do it by sending a request like this:
Example request
POST: /api/output/:output_id/registerContent-Type: application/json
{ "type": "rtp_stream", "transport_protocol": "tcp_server", "port": 9003, "video": { "resolution": { "width": 1280, "height": 720 }, "encoder": { "type": "ffmpeg_h264" }, "initial": { "root": { "type": "view" } } }, "audio": { "encoder": { "type": "opus" }, "channels": "stereo", "initial": { "inputs": [{ "input_id": "input_1", "volume": 1 }] } }}See HTTP Routes documentation to learn more about managing outputs.
References
Type definitions
type RtpOutput = { type: "rtp_stream"; port: string | u16; ip?: string; transport_protocol?: "udp" | "tcp_server"; video?: VideoOptions; audio?: AudioOptions;}Properties
port
Depends on the value of the transport_protocol field:
-
udp- An UDP port number that RTP packets will be sent to. -
tcp_server- A local TCP port number or a port range that Smelter will listen for incoming connections.l TCP port number or a range of ports that Smelter will listen to for incoming connections. -
Type:
string | u16
ip
IP address to which RTP packets should be sent. This field is only valid if transport_protocol field is set to udp.
- Type:
string
transport_protocol
Transport layer protocol that will be used to send RTP packets.
- Type:
"udp" | "tcp_server" - Default value:
udp - Supported values:
udp- UDP protocol.tcp_server- TCP protocol where Smelter is the server side of the connection.
video
Parameters of a video included in the RTP stream.
- Type:
VideoOptions
audio
Parameters of an audio included in the RTP stream.
- Type:
AudioOptions
VideoOptions
Type definitions
type VideoOptions = { resolution: { width: u32; height: u32; }; send_eos_when?: OutputEndCondition; encoder: VideoEncoderOptions; initial: { root: Component; };}Properties
resolution
Output resolution in pixels.
- Type:
{ width: u32; height: u32; }
send_eos_when
Condition for termination of the output stream based on the input streams states. If output includes both audio and video streams, then EOS needs to be sent for every type.
- Type:
OutputEndCondition
encoder
Video encoder options.
- Type:
VideoEncoderOptions
initial
Root of a component tree/scene that should be rendered for the output. Use update_output request to update this value after registration.
- Type:
{ root: Component; }
VideoEncoderOptions
Type definitions
type VideoEncoderOptions = | ({ type: "ffmpeg_h264"; } & FfmpegH264EncoderOptions) | ({ type: "ffmpeg_vp8"; } & FfmpegVp8EncoderOptions) | ({ type: "ffmpeg_vp9"; } & FfmpegVp9EncoderOptions) | ({ type: "vulkan_h264"; } & VulkanH264EncoderOptions);Configuration for the video encoder, based on the selected codec. Visit encoder documentation to learn more.
AudioOptions
Type definitions
type AudioOptions = { mixing_strategy?: "sum_clip" | "sum_scale"; send_eos_when?: OutputEndCondition; encoder: AudioEncoderOptions; channels?: "mono" | "stereo"; initial: { inputs: InputAudio[]; };}Properties
mixing_strategy
Specifies how audio should be mixed.
- Type:
"sum_clip" | "sum_scale" - Default value:
"sum_clip" - Supported values:
sum_clip- First, the input samples are summed. If the result exceeds the i16 PCM range, it is clipped.sum_scale- First, the input samples are summed. If the result exceeds the i16 PCM range, the summed samples are scaled down by a factor to fit within the range.
send_eos_when
Condition for termination of the output stream based on the input streams states. If output includes both audio and video streams, then EOS needs to be sent for every type.
- Type:
OutputEndCondition
encoder
Audio encoder options.
- Type:
AudioEncoderOptions
channels
Channels configuration
- Type:
"mono" | "stereo" - Default value:
"stereo" - Supported values:
mono- Mono audio (single channel).stereo- Stereo audio (two channels).
initial
Initial audio mixer configuration for output.
- Type:
{ inputs: InputAudio[]; }
AudioEncoderOptions
Type definitions
type AudioEncoderOptions = | { type: "opus"; } & OpusEncoderOptions;Configuration for the audio encoder. Visit encoder documentation to learn more.
InputAudio
Type definitions
type InputAudio = { input_id: string; volume?: f32;}Properties
input_id
ID of an input. It identifies a stream registered using a register input method.
- Type:
string
volume
Input volume in range [0, 2]
- Type:
f32 - Default value:
1.0 - Supported values:
[0, 2]
OutputEndCondition
This type defines when end of an input stream should trigger end of the output stream. Only one of those fields can be set at the time. Unless specified otherwise the input stream is considered finished/ended when:
- TCP connection was dropped/closed.
- RTCP Goodbye packet (
BYE) was received. - Mp4 track has ended.
- Input was unregistered already (or never registered).
Type definitions
type OutputEndCondition = { any_of?: string[]; all_of?: string[]; any_input?: bool; all_inputs?: bool;}Properties
any_of
List of the input streams. The output stream will terminate if any stream in the list finishes.
- Type:
string[]
all_of
List of the input streams. The output stream will terminate when all streams in the list finish.
- Type:
string[]
any_input
Terminate the output stream if any of the input streams end, including streams added after the output was registered. Notably, the output stream will not terminate if no inputs were ever connected.
- Type:
bool
all_inputs
Terminate the output stream only when all input streams have finished. Notably, the output stream will terminate if no inputs were ever connected.
- Type:
bool