Construct a VirtualBackgroundProcessor. Default values will be used for any missing optional properties in [[VirtualBackgroundProcessorOptions]], and invalid properties will be ignored.
The HTMLImageElement representing the current background image.
Set an HTMLImageElement as the new background image. An error will be raised if the image hasn't been fully loaded yet. Additionally, the image must follow security guidelines when loading the image from a different origin. Failing to do so will result to an empty output frame.
Whether the pipeline is calculating the person mask without waiting for the current input frame to be downscaled (Chrome only).
Toggle whether the pipeline should calculate the person mask without waiting for the current input frame to be downscaled (Chrome only).
The current blur radius when smoothing out the edges of the person's mask.
Set a new blur radius to be used when smoothing out the edges of the person's mask.
Apply a transform to the background of an input video frame and leaving the foreground (person(s)) untouched. Any exception detected will result in the frame being dropped.
The source of the input frame to process.
OffscreenCanvas - Good for canvas-related processing
that can be rendered off screen.
HTMLCanvasElement - This is recommended on browsers
that doesn't support OffscreenCanvas
, or if you need to render the frame on the screen.
HTMLVideoElement
VideoFrame - Recommended on browsers that support the
Insertable Streams API.
The output frame buffer to use to draw the processed frame.
Generated using TypeDoc
The VirtualBackgroundProcessor, when added to a VideoTrack, replaces the background in each video frame with a given image, and leaves the foreground (person(s)) untouched. Each instance of VirtualBackgroundProcessor should be added to only one VideoTrack at a time to prevent overlapping of image data from multiple VideoTracks.
Example