Skip to main content

RTP

An output type that allows streaming video and audio from the compositor 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/register
Content-Type: application/json
{
"type": "rtp_stream",
"transport_protocol": "tcp_server",
"port": 9003,
"video": {
"resolution": { "width": 1280, "height": 720 },
"encoder": {
"type": "ffmpeg_h264",
"preset": "ultrafast",
},
"initial": {
"root": {
"type": "view",
"background_color_rgba": "#4d4d4dff"
}
}
},
"audio": {
"encoder": {
"type": "opus",
"channels": "mono",
},
"initial": {
"inputs": [{ "input_id": "input_1" }]
}
}
}

See HTTP Routes documentation to learn more about managing outputs. You can also check out our guide to learn how to receive streams after registering them.

RtpOutputStream

type RtpOutputStream = {
port: string | u16;
ip?: string;
transport_protocol?: "udp" | "tcp_server";
video?: OutputVideoOptions;
audio?: OutputRtpAudioOptions;
}

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 LiveCompositor will listen for incoming connections.
  • ip - Only valid if transport_protocol="udp". IP address where RTP packets should be sent to.
  • transport_protocol - (default="udp") Transport layer protocol that will be used to send RTP packets.
    • "udp" - UDP protocol.
    • "tcp_server" - TCP protocol where LiveCompositor is the server side of the connection.
  • video - Video stream configuration.
  • audio - Audio stream configuration.

OutputVideoOptions

type OutputVideoOptions = {
resolution: {
width: u32;
height: u32;
};
send_eos_when?: OutputEndCondition;
encoder: VideoEncoderOptions;
initial: { root: Component; };
}

Properties

  • resolution - Output resolution in pixels.
  • send_eos_when - Defines when output stream should end if some of the input streams are finished. If output includes both audio and video streams, then EOS needs to be sent on both.
  • encoder - Video encoder options.
  • initial - Root of a component tree/scene that should be rendered for the output. Use update_output request to update this value after registration. Learn more.

OutputRtpAudioOptions

type OutputRtpAudioOptions = {
mixing_strategy?: "sum_clip" | "sum_scale";
send_eos_when?: OutputEndCondition;
encoder: RtpAudioEncoderOptions;
initial: { inputs: InputAudio[]; };
}

Properties

  • mixing_strategy - (default="sum_clip") Specifies how audio should be mixed.
    • "sum_clip" - Firstly, input samples are summed. If the result is outside the i16 PCM range, it gets clipped.
    • "sum_scale" - Firstly, input samples are summed. If the result is outside the i16 PCM range, nearby summed samples are scaled down by factor, such that the summed wave is in the i16 PCM range.
  • send_eos_when - Condition for termination of output stream based on the input streams states.
  • encoder - Audio encoder options.
  • initial - Initial audio mixer configuration for output.

OutputEndCondition

type OutputEndCondition = {
any_of?: string[];
all_of?: string[];
any_input?: bool;
all_inputs?: bool;
}

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

Properties

  • any_of - Terminate output stream if any of the input streams from the list are finished.
  • all_of - Terminate output stream if all the input streams from the list are finished.
  • any_input - Terminate output stream if any of the input streams ends. This includes streams added after the output was registered. In particular, output stream will not be terminated if no inputs were ever connected.
  • all_inputs - Terminate output stream if all the input streams finish. In particular, output stream will be terminated if no inputs were ever connected.

VideoEncoderOptions

type VideoEncoderOptions = 
| {
type: "ffmpeg_h264";
preset?:
| "ultrafast"
| "superfast"
| "veryfast"
| "faster"
| "fast"
| "medium"
| "slow"
| "slower"
| "veryslow"
| "placebo";
ffmpeg_options?: Map<string, string>;
}

Properties (type: "ffmpeg_h264")

  • preset - (default="fast") Preset for an encoder. See FFmpeg docs to learn more.
  • ffmpeg_options - Raw FFmpeg encoder options. See docs for more.

RtpAudioEncoderOptions

type RtpAudioEncoderOptions = 
| {
type: "opus";
channels: "mono" | "stereo";
preset?: "quality" | "voip" | "lowest_latency";
}

Properties

  • channels - Specifies channels configuration.
    • "mono" - Mono audio (single channel).
    • "stereo" - Stereo audio (two channels).
  • preset - (default="voip") Specifies preset for audio output encoder.
    • "quality" - Best for broadcast/high-fidelity application where the decoded audio should be as close as possible to the input.
    • "voip" - Best for most VoIP/videoconference applications where listening quality and intelligibility matter most.
    • "lowest_latency" - Only use when lowest-achievable latency is what matters most.

InputAudio

type InputAudio = {
input_id: string;
volume?: f32;
}

Properties

  • volume - (default=1.0) float in [0, 1] range representing input volume