Skip to content

RTP

Node.js Browser (Client)

An input type that allows streaming video and audio to the Smelter server over RTP. It supports both streaming over UDP and TCP (smelter works as a TCP server).

Usage

rtpInputExample.tsx
import Smelter from "@swmansion/smelter-node";
async function run() {
const smelter = new Smelter();
await smelter.init();
await smelter.registerInput("example", {
type: "rtp_stream",
port: 8001,
transportProtocol: "tcp_server",
video: { decoder: "ffmpeg_h264" },
audio: { decoder: "opus" }
});
// At this point you can connect to 8001 TCP port
// and start sending RTP traffic
}
void run();

Reference

Type definitions

type RegisterRtpInput = {
type: "rtp_stream";
port: string | number;
transportProtocol?: "udp" | "tcp_server";
video?: VideoOptions;
audio?: AudioOptions;
required?: bool;
offsetMs?: number;
}

Parameters for registering an RTP stream as an input.

Properties

port

A port number or a port range in format START:END. If range is specified, a port from that range will be returned from Smelter.registerInput.

  • Type: string | number

transportProtocol

Transport protocol.

  • Type: "udp" | "tcp_server"
  • 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.


audio

Parameters of an audio source included in the RTP stream.


required

Determines if the input stream is essential for output frame production. If set to true and the stream is delayed, Smelter will postpone output frames until the stream is received.

  • Type: boolean
  • Default value: false

offsetMs

Offset in milliseconds relative to the pipeline start (start request). If unspecified, the stream synchronizes based on the delivery time of the initial frames.

  • Type: number

VideoOptions

Type definitions

type VideoOptions = {
decoder: "ffmpeg_h264" | "vulkan_h264" | "ffmpeg_vp8" | "ffmpeg_vp9";
}

Parameters of a video source included in the RTP stream.

Properties

decoder

Video decoder.

  • Type: "ffmpeg_h264" | "vulkan_h264" | "ffmpeg_vp8" | "ffmpeg_vp9"
  • Supported values:
    • "ffmpeg_h264" - Use the software H264 decoder based on ffmpeg.
    • "vulkan_h264" (Required feature: vk-video ) - Hardware decoder. Requires GPU that supports Vulkan Video decoding.
    • "ffmpeg_vp8" - Use the software VP8 decoder based on ffmpeg.
    • "ffmpeg_vp9" - Use the software VP9 decoder based on ffmpeg.

AudioOptions

Type definitions

type AudioOptions =
| {
decoder: "opus";
}
| {
decoder: "aac";
audioSpecificConfig: string;
rtpMode?: "low_bitrate" | "high_bitrate";
}

Parameters of an audio source included in the RTP stream.

Properties (decoder: “opus”)

Properties (decoder: “aac”)

audioSpecificConfig

Configuration encoded in the format described in RFC 3640.

  • Type: string

For detailed instructions on obtaining this value, refer to the information provided in the table below:

Format/ProtocolLocation of AAC Specific Config (ASC)Notes
FFmpeg StreamingSDP fileUse the -sdp_file FILENAME option when streaming to a smelter to generate an SDP file containing the ASC.
MP4 FilesInside the esds boxThe ASC is embedded as part of the esds box, not the entire box. Applies to regular MP4 and fragmented MP4s (used in HLS playlists with MP4 files).
FLV Files / RTMPInside the AACAUDIODATA tagThe ASC is contained within the AACAUDIODATA tag.

rtpMode

Specifies the RFC 3640 mode that should be used when depacketizing this stream. For more information, visit RFC specification

  • Type: "low_bitrate" | "high_bitrate"
  • Default value: "high_bitrate"