nexmo-se / video-api-effects

MIT License
4 stars 8 forks source link

`publisher.setVideoSource` not changing video source #15

Closed AriHrannar closed 2 years ago

AriHrannar commented 2 years ago

Hi,

When I initialise the publisher I am setting the videoSource as effectProcessor.outputStream.getVideoTracks()[0] as per the documentation.

Then we have another feature where you can change your camera from f.x. the internal laptop one to an external camera. Here we use OT.getDevices and get a list of devices, we then filter by kind for videoInput and then we have a list of video inputs. Then each video input has a deviceId, which we then send to publisher.setVideoSource to change the camera.

However, when I call publisher.setVideoSource with a device id, the video source is not changed.

Here you can see the code where I am logging the device id and then the result of getVideoSource before and after setVideoSource is called

image

Here you can see the result, the video source is unchanged. The deviceId is also null here, perhaps that is part of the problem, I would expect this to be the id of the video source device where the background is being changed :)

image

Im running "@opentok/client": "2.22.2" "@vonage/video-effects": "1.0.0-rc3",

I hope that is clear enough, let me know if something is unclear :)

brian17han commented 2 years ago

In their developer doc, it states setVideoSource will not work "If the publisher does not currently use a camera input, the promise will reject with an error with the name property set to 'OT_SET_VIDEO_SOURCE_FAILURE'." I agree this is definitely something we need so we can change videoSource once the publisher is started. My workaround is to use "backgroundEffectProcessor.setInputStream(mediaStream);" to change the stream to the other camera.

enricop89 commented 2 years ago

Yes, using the backgroundEffectProcessor.setInputStream(mediaStream); is the right approach