opentok / opentok-android-sdk-samples

Sample applications illustrating best practices using OpenTok Android SDK.
https://tokbox.com/developer/sdks/android/
MIT License
211 stars 169 forks source link

For BackgroundBlur feature with custom radius, application starts lagging #496

Closed WCRohit closed 8 months ago

WCRohit commented 8 months ago

Describe the bug Hi,

Found some issues, we get when trying the Segmentation feature of the OpenTok.

Additional context The main issue is with BackgroundBlur with custom radius, the application becomes very laggy. We tried setting it to 90 and 100. In both cases faces the lagging issue.

Thanks

goncalocostamendes commented 8 months ago

@WCRohit which version of OpenTok lib are you using? There have been some improvements on the latests versions

WCRohit commented 8 months ago

@goncalocostamendes We are using 2.27.0 version of OpenTok. Thanks

goncalocostamendes commented 8 months ago

@WCRohit with which device and which resolution did you experience lagging?

WCRohit commented 8 months ago

@goncalocostamendes We set the resolution to HIGH(CameraCaptureResolution.HIGH). Also below is the details on which we face the issue.

  1. Google Pixel 6 Android Version 13

  2. Motorola One Fusion+ (Model Number: XT2067-3) Android Version 11

Thanks

goncalocostamendes commented 8 months ago

@WCRohit please note that the blur algorithm complexity is O(R^2 W H) where:

Meaning increasing radius imply exponential more time processing.

As such, I recommend using a lower custom radius value or going with the High or Low pre-defined values where no lagging is visible.

I will be closing the ticket. Please re-open it if necessary.

goncalocostamendes commented 8 months ago

@WCRohit in regards to your request for a black blur, I raised the feature request with the Product Team, but there is no prediction when it will be done or even if it will be done.

The best solution for it is to use insertable streams and create your own transformer. More info here https://tokbox.com/developer/guides/vonage-media-processor/android/#:~:text=Creating%20a%20custom%20video%20transformer

WCRohit commented 8 months ago

@goncalocostamendes Thanks a lot for your fast response and clearing the doubts. One last question, Is it possible to create 2 Publisher instances simultaneously. So that we can use 1 Publisher with Background blur(Will show this to phone user) and other without Background Blur(Will show this to Subscriber).

Although, I have tried this but it is not working, in case if somehow it can work.

Thanks

goncalocostamendes commented 8 months ago

@WCRohit yes, you can create multiple publishers and configure blur as you want to each one. To create multiple publisher just create an ArrayList the same way we do it for subscribers

WCRohit commented 8 months ago

@goncalocostamendes Sorry, I didn't find any way in which multiple publishers can be created. On initialising 2nd publisher the application is getting crashed. Also, as you suggested we found that multiple subscribers are possible with multiple streams.

Can You please share any document reference or Github example related to this?

Thanks