Skip to main content

How to use the Background Replacement

nn_api Face Filter contains the background replacement functionality. You can change the background with any image or video file while using the API in your app.

Download Face Filter

Background replacement#

Both image and video keep their original aspect ratio ("aspect fill").

There are several ways you can consume the effect API:

  • Via effect's config.js
  • In your application code use callJsMethod from Banuba SDK

Below you may find the code examples for different API use cases and languages.

When using the effect API directly in the effect config.js you can write your own function and initiate the desired parameters. Or you can use testAll function, which is already provided with code examples.

Mind to call your function (or uncomment testAll function) in the end of config.js file.

Image replacement#

  • BackgroundTexture.set(path) - set image as a background, the path can be relative or absolute.
  • BackgroundTexture.clear() - disable the feature and reset the background.
BackgroundTexture.set("images/default_tex1.png");
// BackgroundTexture.clear();

Preview

Drag

Video replacement#

  • BackgroundVideo.set(path) - set video as a background, the path can be relative or absolute.
  • BackgroundVideo.clear() - disable the feature and reset the background.
  • BackgroundVideo.isLooped(true) - set this parameter to loop the video.
BackgroundVideo.set("videos/video2.mp4");
// BackgroundVideo.clear();

Preview

Drag
Last updated on