Class tsvb

Constructors

Properties

Accessors

Methods

addComponent cache clear clearBackground clearBlur clearCustomResolution clearModelCache clearOutputResolution config createComponent createEffectInstance destroy disableBeautification disableChromaKey disableColorCorrector disableColorFilter disableFrameSkipping disableLowLightEffect disableMirroring disablePortraitLighting disableSharpnessEffect disableSmartZoom emulateError enableBeautification enableChromaKey enableColorCorrector enableColorFilter enableFrameSkipping enableLowLightEffect enableMirroring enablePortraitLighting enableSharpnessEffect enableSmartZoom freeze getComponentConstructor getCustomerId getDetectedFaces getEffectInstance getLatestErrors getMetrics getSegmentationPreset getSnapshot getStream hideFps initFrameProcessor isSupported loadEffect onBackgroundSuccess onChangeInputResolution onColorFilterSuccess onError onLowLightSuccess preload processFrame run setBackground setBackgroundColor setBackgroundFitMode setBeautificationLevel setBlur setBoundaryLevel setBoundaryMode setChromaKeySettings setColorCorrectorPeriod setColorCorrectorPower setColorFilterConfig setCustomLayout setCustomResolution setFaceArea setFaceDetectorAccuracy setFilterPart setFpsLimit setLayout setLayoutMode setLowLightEffectConfig setLowLightEffectPower setOutputFrameFormat setOutputResolution setPortraitLightingOptions setSegmentationPreset setSharpnessEffectConfig setSmartZoomPerod setSmartZoomSensitivity setSmartZoomSmoothing showFps stop switchDrawFaceSquare switchDrawPreFaceSquare toCanvas unfreeze useStream

Constructors

  • Initiation of main SDK instance.

    Parameters

    • customer_id: string

      the unique customer identifier provided by SDK vendor.

    • inference: any = null

    Returns tsvb

Properties

components: any = ...
customer_id: string

Unique customer identifier provided by SDK vendor.

recorder: IRecorder
sdkOptions: Options

Accessors

  • set onFrame(f): void
  • Parameters

    • f: undefined | Function

    Returns void

  • set onReady(f): void
  • A callback is fired when the SDK is ready for frame processing. Effects configuration should only be applied after this callback has been triggered.

    Parameters

    • f: Function

    Returns void

Methods

  • Type Parameters

    • K extends "lowerthird_3" | "overlay_screen" | "watermark" | "lowerthird_1" | "lowerthird_2" | "lowerthird_4" | "lowerthird_5" | "stickers"

    Parameters

    • c: ClassType<K>
    • id: string

    Returns void

  • Parameters

    • clear: boolean = false

      pass true to delete cached models

    Returns Promise<void>

    Deprecated

    moved cache_models configuration to config + add seperate function to clear cache Set the cache_models configuration to true. This can also be configured using sdk.config({ cache_models: true | false }). The model will be cached during the first load to local storage. This will speed up all subsequent initializations of effects using ML models.

  • Clear output stream.

    Returns boolean

  • Disable background effect. As a background will be shown original video.

    Returns boolean

  • Disable blur of the background.

    Returns boolean

  • Returns void

  • Returns Promise<void>

  • Returns void

    Deprecated

    renamed to clearCustomResolution

  • Ability to configure sdk execution environment

    Parameters

    • config: any

      configuration object

    Returns void

    Example

    General configuration options

    config = {
    api_url: 'url', // Enable custom URL configuration for SDK authentication, suitable for on-premises solutions.
    model_url: 'url', // Custom URL for the segmentation model; in most cases, this parameter does not require configuration.
    sdk_url: 'url', // This parameter specifies the URL to the SDK folder for cases where you host the model files yourself.
    effects: ['virtual_background', 'smart_zoom', 'low_light', 'color_correction'], // List of effects which should be loaded at initializatin
    preset: 'balanced', // You can set the default segmentation preset to one of the following options: quality, balanced, speed, or lightning.
    proxy: true/false, // The configuration specifies whether segmentation should operate in a separate worker thread (not in the main UI thread), with the default value set to true.
    provider: wasm/webgpu/auto, // Allow users to select where to execute the segmentation. In auto mode, the SDK will verify the availability of a GPU. If a GPU is not available, it will automatically fall back to using WASM
    stats: true/false, // To enable or disable the sending of statistics.
    cache_models: true/false, // To cache models locally, this will speed up the load time. By default is true
    test_inference: true/false, // False by default. If set to true, the SDK will test inference consistency on the WebGPU backend.
    models: {
    'colorcorrector': 'url', // The feature allows for the provision of a custom model name; if left empty, the feature will be disabled.
    'facedetector': 'url', // The feature allows for the provision of a custom model name; if left empty, the feature will be disabled.
    'lowlighter': 'url', // The feature allows for the provision of a custom model name; if left empty, the feature will be disabled.
    },
    wasmPaths: { // Currently, WASM files are loaded from the same directory where the SDK is placed, but custom URLs are also supported (for example, you can load them from CDNs).
    'ort-wasm.wasm': 'url',
    'ort-wasm-simd.wasm': 'url',
    'ort-wasm-threaded.wasm': 'url',
    'ort-wasm-simd-threaded.wasm': 'url'
    }
    }

    Example

    Example of how to change default segmentation preset

    config = {
    preset: 'lightning'
    }

    Example

    Example of how to disable colorcorrection and facedetection

    config = {
    effects: ['virtual_background']
    }

    Example

    Example of how to hot models on custom domain

    config = {
    sdk_url: 'https://domain.com/sdk/' // in this derectory should be subfolder models with all required models
    }
  • Type Parameters

    • K extends "lowerthird_3" | "overlay_screen" | "watermark" | "lowerthird_1" | "lowerthird_2" | "lowerthird_4" | "lowerthird_5" | "stickers"

    Parameters

    • arg: K extends keyof OptionsMap
          ? ComponentArguments<K<K>>
          : Omit<ComponentArguments<K>, "options">

    Returns ClassType<K>

  • Parameters

    • key: EffectsEnum

    Returns AbstractEffect

  • Destroy SDK instance and cleanup all resources including WebGL contexts. This method should be called when you're done with the SDK instance to prevent memory leaks. After calling destroy(), you should create a new SDK instance if you need to use it again.

    Parameters

    • withInference: boolean = false

    Returns Promise<boolean>

  • Disable beautification effect.

    Returns boolean

  • Disable the classic chroma key algorithm.

    Returns boolean

  • Disable color-corrector effect.

    Returns boolean

  • Disable color-filter effect.

    Returns boolean

  • Disable Frame Skipping - segmentation will be running on every video frame. FrameSkipping disabled by default.

    Returns boolean

  • Disable LowLight effect.

    Returns boolean

  • Disable Mirroring Effect.

    Returns boolean

  • Disable portrait lighting effect.

    Returns boolean

  • Disable Sharpness effect.

    Returns boolean

  • Disable smart-zoom effect.

    Returns boolean

  • Parameters

    • code: ErrorCode

    Returns void

  • Enable beautification effect.

    Returns boolean

  • Enable the classic chroma key algorithm.

    Returns boolean

  • Enable color-correction effect.

    Returns boolean

  • Enable color-filter effect.

    Returns boolean

  • Enable Frame Skipping - segmentation will be running on every second frame, this will increase FPS but brings some motion trail

    Returns boolean

  • Enable LowLight effect.

    Returns boolean

  • Enable Mirroring Effect.

    Returns boolean

  • Enable portrait lighting effect. This will brighten the subject and create a professional portrait look with smooth edges.

    Returns boolean

  • Enable Sharpness effect.

    Returns boolean

  • Enable smart-zoom effect.

    Returns boolean

  • Freeze the stream

    Returns boolean

  • Type Parameters

    • K extends "lowerthird_3" | "overlay_screen" | "watermark" | "lowerthird_1" | "lowerthird_2" | "lowerthird_4" | "lowerthird_5" | "stickers"

    Parameters

    • key: K

    Returns {
        lowerthird_1: typeof LtLeftTextbox;
        lowerthird_2: typeof LtHorizontalMirror;
        lowerthird_3: typeof LtSlideBold;
        lowerthird_4: typeof LtDoubleSlideRect;
        lowerthird_5: typeof LtTwoSlideRects;
        overlay_screen: typeof OverlayScreen;
        stickers: typeof Stickers;
        watermark: typeof Watermark;
    }[K]

  • Get Customer ID provided by vendor.

    Returns string

  • Get the detected faces squares. Works only if SmartZoom is enabled. To get detected faces without applying SmartZoom effects, just use setFaceArea with the minimal parameter.

    Returns FaceCombiner[]

  • Parameters

    • key: EffectsEnum

    Returns null | AbstractEffect

  • Returns ErrorObject[]

  • Return Metrics for processing fps - the current actual FPS (limited by source fps) segmentationInferenceTime - inference time for segmentation fullFrameDrawTime - time for applying all effects (including ML processing) and drawing the final frame

    Returns Metrics

  • Return current active segmentation mode.

    Returns PresetType

  • Returns Promise<ImageBitmap>

  • Get the output MediaStream object for further processing.

    Returns undefined | null | MediaStream

  • Hide fps and other stats on the stream.

    Returns boolean

  • Initialize the frame processor for processing individual video frames. This method sets up the rendering pipeline and effect processor without requiring a MediaStream. It creates the necessary components (Renderer, EffectProcessor) and loads all configured effects. If the frame processor is already initialized, this method returns immediately.

    Use this method when you want to process individual VideoFrame objects directly via processFrame(), rather than processing an entire MediaStream via useStream().

    IMPORTANT - Mode Isolation:

    • This method is mutually exclusive with useStream()
    • Calling initFrameProcessor() will automatically destroy any active stream processor
    • You cannot use processFrame() and useStream() simultaneously
    • Choose one mode: either frame-by-frame processing OR stream processing

    Returns Promise<void>

    A promise that resolves when initialization is complete and all effects are loaded.

  • Check the minimal requirements for SDK

    Returns boolean

  • Dynamically loading effects and adding them to the effects pipeline

    Parameters

    • type: AvailableEffects

      is the type of effect should be added: 'virtual_background' | 'color_correction' | 'low_light' | 'smart_zoom'

    Returns Promise<void>

  • Parameters

    • Optional f: (() => void)
        • (): void
        • Returns void

    Returns void

  • Parameters

    • Optional f: (() => void)
        • (): void
        • Returns void

    Returns void

  • Parameters

    • Optional f: ((id) => void)
        • (id): void
        • Parameters

          • id: string

          Returns void

    Returns void

  • pass onError callback to ErrorBus

    Parameters

    • handler: ((e) => void)

      callback function that takes ErrorObject as its first argument.

        • (e): void
        • Parameters

          • e: ErrorObject

          Returns void

    Returns void

  • Parameters

    • Optional f: (() => void)
        • (): void
        • Returns void

    Returns void

  • Initialize all ML resources (models and inference objects). The initial configurations are obtained from sdk.config().

    Returns Promise<void>

  • Process a single VideoFrame through the effects pipeline. This method allows for frame-by-frame processing without requiring a MediaStream. The frame processor must be initialized via initFrameProcessor() before calling this method.

    All enabled effects (virtual background, color correction, smart zoom, etc.) will be applied to the input frame, and a new processed VideoFrame will be returned.

    IMPORTANT - Mode Isolation:

    • This method cannot be used simultaneously with useStream()
    • You must choose one mode: either processFrame() for frame-by-frame processing OR useStream() for MediaStream processing
    • Calling useStream() will destroy the frame processor and disable this method

    Important: The input VideoFrame is consumed by this method. You should not use it after passing it to processFrame(). The SDK automatically closes the input frame even if processing fails.

    Backpressure Control: The SDK can handle up to 2 frames in-flight simultaneously:

    • One frame actively being rendered/processed
    • One frame in preparation/queued

    It's recommended to track in-flight frames and drop incoming frames when the limit is reached to prevent memory buildup and maintain smooth performance.

    Parameters

    • videoFrame: VideoFrame

      The input VideoFrame to process. This frame will be consumed by the processing pipeline.

    Returns Promise<VideoFrame>

    A promise that resolves to the processed VideoFrame with all effects applied.

    Throws

    Throws an error if the Frame Processor is not initialized. Call initFrameProcessor() first.

    Example

    Basic usage:

    await sdk.initFrameProcessor();
    const processedFrame = await sdk.processFrame(inputFrame);

    Example

    Recommended pattern with backpressure control:

    let stats = { inFlight: 0, droppedFrames: 0 };

    // In your frame callback:
    // Drop frames if too many in-flight (backpressure control)
    if (stats.inFlight >= 2) {
    stats.droppedFrames++;
    inputFrame.close();
    continue;
    }

    stats.inFlight++;

    sdk.processFrame(inputFrame)
    .then(outputFrame => {
    // Draw output frame to canvas
    ctx.drawImage(outputFrame, 0, 0);

    // Close the output frame
    outputFrame.close();
    })
    .catch(err => {
    console.error('Frame processing failed:', err);
    // Note: inputFrame is already closed by SDK even on error
    })
    .finally(() => {
    // Decrement in-flight counter (inputFrame already closed by SDK)
    stats.inFlight--;
    });
  • Run the processing of frames.

    Returns boolean

  • Set media source of the background. Video sources will be played automatically from the beginning.

    Parameters

    • url: BackgroundSource

      the link to image/video of the server or one of the following objects: MediaStream, MediaStreamTrack, HTMLVideoElement, ImageBitmap, Canvas.

    Returns boolean

  • Set the background color for background 'color' mode.

    Parameters

    • color: number

      in hexadecimal format.

    Returns void

  • Control background fit/fill mode. Default value is fill mode.

    Parameters

    • mode: string

      the background fit mode, can be fit of fill

    Returns boolean

  • Control face beautification level.

    Parameters

    • level: number

      could be from 0 to 1. Higher number -> more visible effect of beautification.

    Returns boolean

  • Enable blur of the background and set the power of blur.

    Parameters

    • power: number

      of the blur, can be a number from 0 to 1. Higher number -> better blur. This value could affect the performance (CPU/GPU, FPS)

    Returns boolean

  • Parameters

    • level: number

    Returns boolean

    Deprecated

    Due to the update of segmentation models, there is no need for such a function. It will be removed in future versions.

  • Parameters

    • mode: string

      the boundary mode, can be smooth or strong

    Returns boolean

    Deprecated

    with updated models don't need anymore Control boundary mode smooth or strong. Default value is strong mode.

  • Set chroma key parameters.

    Parameters

    Returns boolean

    True if the settings were applied successfully.

  • Set period in ms for cc-model working.

    Parameters

    • value: number

      can be a number from 0 to 5000 (default 1000)

    Returns boolean

  • Set power of color correction.

    Parameters

    • value: number

      can be a number from 0 to 1 (default 1)

    Returns boolean

  • set color-filter config.

    Parameters

    • config: Partial<ColorFilterConfig>

    Returns boolean

  • Set the layout with custom params

    Parameters

    • persent: {
          size?: number;
          xOffset?: number;
          yOffset?: number;
      }

      objects with the custom params

      • Optional size?: number
      • Optional xOffset?: number
      • Optional yOffset?: number

    Returns boolean

    Example

    persent = {
    xOffset?: number, // horizontal offset relative to center, value can be a number from -1 to 1
    yOffset?: number, // vertical offset relative to center, value can be a number from -1 to 1
    size?: number, mask size percentage// value can be a number from 0 to 1 *
    }
  • Parameters

    • size: ResizeSettings

    Returns void

  • Set the face-area proportion. Used by the smart-zoom effect to calculate frame scale value

    Parameters

    • value: number

      can be a number from 0.01 to 1 (default = 0.1)

    Returns boolean

  • Set the face detector accuracy.

    Parameters

    • value: number

      can be a number from 0.2 to 1 (default 0.75)

    Returns boolean

  • Set filter part for the color correction (dev feature).

    Parameters

    • value: number

      can be a number from 0 to 1 (default 1)

    Returns boolean

  • Show fps on the stream.

    Parameters

    • limit: number

    Returns boolean

  • Set the layout. Useful for presentations.

    Parameters

    • mode: string

      could be the one of the following: center, left-bottom, right-bottom

    Returns boolean

  • Set the layout mode. You can disable segmentation and show full camera frame or hide camera frame.

    Parameters

    • mode: LayoutMode

      could be the one of the following: 'segmentation' | 'full' | 'hide' | 'transparent' Segmentation - Process the segmentation and display the selected background. Full - Show the full original frame without segmentation. Hide - Hide the original frame completely (only the background will be visible). Transparent - Process the segmentation and return the segmented person with a transparent background.

    Returns boolean

  • Set LowLight effect config.

    Parameters

    • config: Partial<LowLightConfig>

      LowLight effect config.

    Returns boolean

  • Set LowLight effect power.

    Parameters

    • value: number

      number from 0 to 1 (default 1)

    Returns boolean

  • The default frame format is RGBA. Using this method, you can change the frame format to I420.

    Parameters

    • format: FrameFormat

    Returns void

  • Parameters

    • size: ResizeSettings

    Returns void

    Deprecated

    renamed to setCustomResolution

  • Set portrait lighting options.

    Parameters

    Returns boolean

  • Set the segmentation mode. Segmentation mode allow to choose combination of quality and speed of segmentation. Balanced mode is enabled by default.

    Parameters

    • preset: PresetType

      in string format. The values could be quality, balanced, speed, lightning.

    Returns Promise<boolean>

  • Set Sharpness effect config.

    Parameters

    • config: Partial<SharpnessConfig>

      Sharpness effect config.

    Returns boolean

  • Set period in ms for face detector reaction.

    Parameters

    • value: number

      can be a number from 0 to 1000 (default 100)

    Returns boolean

  • Set sensitivity for the smart-zoom rection. The set value means the difference between the new and old face-params for the smartzoom reaction

    Parameters

    • value: number

      can be a number from 0 to 1 (default 0.05)

    Returns boolean

  • Set count of the smart-zoom smoothing. The more steps, the higher the smoothing

    Parameters

    • steps: number

      can be a number from 0.01 to 1 (default 0.2)

    Returns boolean

  • Show fps on the stream.

    Returns boolean

  • Stop applying all effects. The original frames will be bypassed to the output stream.

    Returns boolean

  • Switch face-square-drawing mode.

    Parameters

    • isOn: boolean

      is a boolean argument (default false)

    Returns boolean

  • Switch preface-square-drawing mode. Draw face square before processing

    Parameters

    • isOn: boolean

      is a boolean argument (default false)

    Returns boolean

  • Set the canvas where will be rendered the processed frames.

    Parameters

    • canvas: null | HTMLCanvasElement

      the HTMLCanvasElement object.

    Returns void

  • Unfreeze the stream

    Returns boolean

  • Set the MediaStream object which will be the source of the video frames for processing.

    IMPORTANT - Mode Isolation:

    • This method is mutually exclusive with processFrame()
    • Calling useStream() will automatically destroy any active frame processor
    • You cannot use useStream() and processFrame() simultaneously
    • Choose one mode: either MediaStream processing OR frame-by-frame processing

    Parameters

    • stream: MediaStream

      the source MediaStream object.

    • Optional resize: ResizeSettings

      optional resize settings to apply custom output dimensions.

    Returns void