LiveKit Server SDK: "preset" property not found in "IngressVideoOptions"

140 Views Asked by At

I'm working with the LiveKit Server SDK and trying to set the video encoding preset for an Ingress. However, I'm encountering the error:

Object literal may only specify known properties, and 'preset' does not exist in type 'IngressVideoOptions'.

Here's the relevant code snippet:

import {
  IngressVideoEncodingPreset,
  // ... other imports
} from "livekit-server-sdk";

// ...

options.video = {
  source: TrackSource.CAMERA,
  preset: IngressVideoEncodingPreset.H264_1080P_30FPS_3_LAYERS,
};

I've verified that the livekit-server-sdk package is up-to-date and the IngressVideoEncodingPreset import seems correct. I have also tried to update my typescript and upated npm install livekit-server-sdk, still the issue persists. Any suggestions on how to fix this error?

Update: It is working with the old version but the new version has these error: on

`if (ingressType === IngressInput.WHIP_INPUT) {
    options.bypassTranscoding = true;
  } else {
    options.video = {
      source: TrackSource.CAMERA,
      encodingOptions: {
        value: IngressVideoEncodingPreset.H264_1080P_30FPS_3_LAYERS,
        case: "preset",
      },
    }
  }`

error: Type

'{ source: TrackSource; encodingOptions: { value: IngressVideoEncodingPreset.H264_1080P_30FPS_3_LAYERS; case: "preset"; }; }'

is missing the following properties from type 'IngressVideoOptions': name, equals, clone, fromBinary, and 7 more.

I have tried to add name and it does work, but the other properties seem to be non existing in dependency.

Documentation: https://docs.livekit.io/server-sdk-js/classes/IngressVideoOptions.html

2

There are 2 best solutions below

0
On

I have found an answer to my question.

Here's what worked for me:

I downgraded my dependencies for "livekit-client": "^1.15.4", & "livekit-server-sdk": "^1.2.7",. Additionally, I imported livekit-server-sdk/dist after the downgrade.

This approach has effectively resolved the error. I will now attempt to update to the latest versions to see if that resolves the issue permanently. Please give me a few minutes to try this out.

2
On

The docs showed an outdated version for livekit-server-sdk 1.x.

The latest major version is 2.x and constructing those options has changed a bit:

const ingress: CreateIngressOptions = {
  name: 'my-ingress',
  roomName: 'my-room',
  participantIdentity: 'my-participant',
  participantName: 'My Participant',
  video: new IngressVideoOptions({
    source: TrackSource.SCREEN_SHARE,
    encodingOptions: {
      case: 'preset',
      value: IngressVideoEncodingPreset.H264_1080P_30FPS_3_LAYERS,
    },
  }),

  audio: new IngressAudioOptions({
    source: TrackSource.MICROPHONE,
    encodingOptions: {
      case: 'preset',
      value: IngressAudioEncodingPreset.OPUS_STEREO_96KBPS
    }
  })
};