Skip to main content

VideoEffect()

This class is used to apply a video effect to the video stream. It's compatible with Ant Media Server JavaScript SDK v2.5.2+

Kind: global function

videoEffect.init(webRTCAdaptor, streamId, virtualBackgroundImage, rawLocalVideo)

This method is used to initialize the video effect.

Kind: instance method of VideoEffect

ParamTypeDescription
webRTCAdaptorWebRTCAdaptorAnt Media Server JavaScript SDK instance
streamIdstringStream ID
virtualBackgroundImageHTMLElementElement of virtual background image. You should set the image source before calling this method.
rawLocalVideoHTMLElementElement of raw local video. It's used to keep the raw video stream.

videoEffect.createEffectCanvas()

This method is used to create the canvas element which is used to apply the video effect.

Kind: instance method of VideoEffect

videoEffect.initializeSelfieSegmentation()

This method is used to initialize the selfie segmentation.

Kind: instance method of VideoEffect

videoEffect.enableVirtualBackground()

This method is used to activate the virtual background effect to the video stream.

Kind: instance method of VideoEffect

videoEffect.enableBlur()

This method is used to activate the blur effect to the video stream.

Kind: instance method of VideoEffect

videoEffect.removeEffect()

This method is used to disable the virtual background and blur effects.

Kind: instance method of VideoEffect

videoEffect.setCanvasStreamAsCustomVideoSource()

This method is used to prepare canvas stream and set the custom video source on Ant Media Server SDK.

Kind: instance method of VideoEffect

videoEffect.loadSelfieSegmentation()

This method is used to prepare the raw video stream.

Kind: instance method of VideoEffect

videoEffect.playing() ⇒ Promise.<void>

This method is used to send raw video stream to mediapipe.

Kind: instance method of VideoEffect

videoEffect.drawSegmentationMask(segmentation)

This method is used to draw the segmentation mask.

Kind: instance method of VideoEffect

ParamTypeDescription
segmentationUint8ArraySegmentation mask

videoEffect.onResults(results)

This method is called by mediapipe when the segmentation mask is ready.

Kind: instance method of VideoEffect

Param
results

videoEffect.drawImageDirectly(image)

This method is used to draw the raw frame directly to the canvas.

Kind: instance method of VideoEffect

Param
image

videoEffect.drawVirtualBackground(image, segmentation, virtualBackgroundImage)

This method is used to draw the frame with virtual background effect to the canvas.

Kind: instance method of VideoEffect

Param
image
segmentation
virtualBackgroundImage

videoEffect.drawBlurBackground(image, segmentation, blurAmount)

This method is used to draw frame with background blur effect to the canvas.

Kind: instance method of VideoEffect

Param
image
segmentation
blurAmount