Skip to content

WHIP

An output type that allows streaming video and audio from the Smelter over WHIP.

Usage

To use WHIP 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": "whip",
"endpoint_url": "", // The endpoint URL you want to stream to via WHIP.
"bearer_token": "", // Your WHIP bearer token
"video": {
"resolution": {
"width": 1280,
"height": 720,
},
"encoder": {
"type": "ffmpeg_h264",
"preset": "medium"
},
"initial": {
"root": {
"id": "input_1",
"type": "input_stream",
"input_id": "input_1",
}
}
},
"audio": {
"encoder": {
"type": "opus",
"channels": "stereo",
},
"initial": {
"inputs": [
{"input_id": "input_1"}
]
}
}
}

WhipOutput

Parameters for an WHIP output stream from the Smelter.

Type definitions

type WhipOutput = {
endpointUrl: string;
bearerToken?: string;
video?: OutputVideoOptions;
audio?: WhipAudioOptions;
};

Properties

endpointUrl

The destination URL for sending media streams using the WHIP.

  • Type: string

bearerToken

Token used for authentication when connecting to the WHIP endpoint.

  • Type: string

video

Parameters of a video included in the WHIP stream.


audio

Parameters of an audio included in the WHIP stream.

OutputVideoOptions

Parameters of a video source included in the WHIP stream.

Type definitions

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

Properties

resolution

Output resolution in pixels.

  • Type: { width: number; height: number;}

sendEosWhen

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.


encoder

Video encoder options.


initial

Root of a component tree/scene that should be rendered for the output.

VideoEncoderOptions

Configuration for the video encoder, based on the selected codec.

Type definitions

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

Properties (type: “ffmpeg_h264”)

preset

Video output encoder preset. Visit FFmpeg docs to learn more.

  • Type: "ultrafast" | "superfast" | "veryfast" | "faster" | "fast" | "medium" | "slow" | "slower" | "veryslow" | "placebo"
  • Default value: fast
  • Supported values:
    • ultrafast
    • superfast
    • veryfast
    • faster
    • fast
    • medium
    • slow
    • slower
    • veryslow
    • placebo

ffmpegOptions

Raw FFmpeg encoder options. Visit FFmpeg docs to learn more.

  • Type: Map<string, string>

WhipAudioOptions

Parameters of an audio source included in the WHIP stream.

Type definitions

type WhipAudioOptions = {
mixingStrategy?: "sum_clip" | "sum_scale";
sendEosWhen?: Outputs.OutputEndCondition;
encoder: Outputs.WhipAudioEncoderOptions;
}

Properties

mixingStrategy

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.

sendEosWhen

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.


encoder

Audio encoder options.


WhipAudioEncoderOptions

Configuration for the audio encoder, based on the selected codec.

Type definitions

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

Properties(type: “opus”)

channels

Channels configuration

  • Type: "mono" | "stereo"
  • Supported values:
    • mono - Mono audio (single channel).
    • stereo - Stereo audio (two channels).

preset

Audio output encoder preset.

  • Type: "quality" | "voip" | "lowest_latency"
  • Default value: voip
  • Supported values:
    • quality - Recommended for broadcast and high-fidelity applications requiring decoded audio to maintain maximum fidelity to the input signal.
    • voip - Recommended for VoIP and videoconferencing applications, prioritizing listening quality and speech intelligibility.
    • lowest_latency - Recommended only when achieving the lowest possible latency is the highest priority.

sampleRate

Sample rate for audio encoder.

  • Type: u32
  • Supported values: 8000, 16000, 24000, 48000.

OutputEndCondition

Defines when the output stream should end based on the state of the input streams. Only one of the nested fields can be set at a time.

By default, 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 =
| { anyOf: string[]; }
| { allOf: string[]; }
| { anyInput: boolean; }
| { allInputs: boolean; };

Properties

anyOf

List of the input streams. The output stream will terminate if any stream in the list finishes.

  • Type: string[]

allOf

List of the input streams. The output stream will terminate when all streams in the list finish.

  • Type: string[]

anyInput

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: boolean

allInputs

Terminate the output stream only when all input streams have finished. Notably, the output stream will terminate if no inputs were ever connected.

  • Type: boolean