LiveKit JS Client SDK - v2.11.1

    Interface TrackPublishOptions

    Options when publishing tracks

    interface TrackPublishOptions {
        audioPreset?: AudioPreset;
        backupCodec?: boolean | { codec: "vp8" | "h264"; encoding?: VideoEncoding };
        backupCodecPolicy?: BackupCodecPolicy;
        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 Summary, Expand)

    Index

    Properties

    audioPreset?: AudioPreset

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

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

    Advanced codecs (VP9/AV1/H265) 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

    backupCodecPolicy?: BackupCodecPolicy

    When backup codec is enabled, there are two options to decide whether to send the primary codec at the same time:

    • codec regression: publisher stops sending primary codec and all subscribers will receive backup codec even if the primary codec is supported on their browser. It is the default behavior and provides maximum compatibility. It also reduces CPU and bandwidth consumption for publisher.
    • multi-codec simulcast: publisher encodes and sends both codecs at same time, subscribers will get most efficient codec. It will provide most bandwidth efficiency, especially in the large 1:N room but requires more device performance and bandwidth consumption for publisher.
    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, ], }

    MMNEPVFCICPMFPCPTTAAATR