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.
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
callJsMethodfrom 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.
BackgroundTexture.set(path)- set image as a background, the path can be relative or absolute.
BackgroundTexture.clear()- disable the feature and reset the background.
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.