Interface TrackPublishOptions

Options when publishing tracks

interface TrackPublishOptions {
    audioPreset?: AudioPreset;
    backupCodec?: boolean | {
        codec: "vp8" | "h264";
        encoding?: VideoEncoding;
    };
    degradationPreference?: RTCDegradationPreference;
    dtx?: boolean;
    forceStereo?: boolean;
    name?: string;
    red?: boolean;
    scalabilityMode?: ScalabilityMode;
    screenShareEncoding?: VideoEncoding;
    screenShareSimulcastLayers?: VideoPreset[];
    simulcast?: boolean;
    source?: Source;
    stopMicTrackOnMute?: boolean;
    stream?: string;
    videoCodec?:
        | "vp8"
        | "h264"
        | "vp9"
        | "av1";
    videoEncoding?: VideoEncoding;
    videoSimulcastLayers?: VideoPreset[];
}

Hierarchy (view full)

Properties

audioPreset?: AudioPreset

which audio preset should be used for publishing (audio) tracks defaults to [[AudioPresets.music]]

backupCodec?: boolean | {
    codec: "vp8" | "h264";
    encoding?: VideoEncoding;
}

Multi-codec Simulcast VP9 and AV1 are not supported by all browser clients. When backupCodec is set, when an incompatible client attempts to subscribe to the track, LiveKit will automatically publish a secondary track encoded with the backup codec.

You could customize specific encoding parameters of the backup track by explicitly setting codec and encoding fields.

Defaults to true

degradationPreference?: RTCDegradationPreference

degradation preference

dtx?: boolean

dtx (Discontinuous Transmission of audio), enabled by default for mono tracks.

forceStereo?: boolean

publish track in stereo mode (or set to false to disable). defaults determined by capture channel count.

name?: string

set a track name

red?: boolean

red (Redundant Audio Data), enabled by default for mono tracks.

scalabilityMode?: ScalabilityMode

scalability mode for svc codecs, defaults to 'L3T3_KEY'. for svc codecs, simulcast is disabled.

screenShareEncoding?: VideoEncoding

encoding parameters for screen share track

screenShareSimulcastLayers?: VideoPreset[]

custom video simulcast layers for screen tracks Note: the layers need to be ordered from lowest to highest quality

simulcast?: boolean

use simulcast, defaults to true. When using simulcast, LiveKit will publish up to three versions of the stream at various resolutions.

source?: Source

Source of track, camera, microphone, or screen

stopMicTrackOnMute?: boolean

For local tracks, stop the underlying MediaStreamTrack when the track is muted (or paused) on some platforms, this option is necessary to disable the microphone recording indicator. Note: when this is enabled, and BT devices are connected, they will transition between profiles (e.g. HFP to A2DP) and there will be an audible difference in playback.

defaults to false

stream?: string

Set stream name for the track. Audio and video tracks with the same stream name will be placed in the same MediaStream and offer better synchronization. By default, camera and microphone will be placed in a stream; as would screen_share and screen_share_audio

videoCodec?:
    | "vp8"
    | "h264"
    | "vp9"
    | "av1"

codec, defaults to vp8; for svc codecs, auto enable vp8 as backup. (TBD)

videoEncoding?: VideoEncoding

encoding parameters for camera track

videoSimulcastLayers?: VideoPreset[]

Up to two additional simulcast layers to publish in addition to the original Track. When left blank, it defaults to h180, h360. If a SVC codec is used (VP9 or AV1), this field has no effect.

To publish three total layers, you would specify: { videoEncoding: {...}, // encoding of the primary layer videoSimulcastLayers: [ VideoPresets.h540, VideoPresets.h216, ], }