Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
virtual-bg
Advanced tools
Easily add virtual background effects to your video/camera input inside any web browser
Install from npm using:
npm install virtual-bg
or include directly in HTML:
<script src="https://cdn.jsdelivr.net/npm/virtual-bg@latest/virtual-bg.min.js"></script>
<div>
<video autoplay="true" id="inputVideoElement"></video>
<canvas id="output_canvas"></canvas>
</div>
import { segmentBackground, applyBlur, applyImageBackground } from'virtual-bg';
const inputVideoElement = document.querySelector('#inputVideoElement');
const outputCanvasElement = document.querySelector('#output_canvas');
let myStream = await navigator.mediaDevices.getUserMedia({
video: true
});
inputVideoElement.srcObject = myStream;
// segments foreground & background
segmentBackground(inputVideoElement, outputCanvasElement);
// applies a blur intensity of 7px to the background
applyBlur(7);
// applies an image background
const image = new Image();
image.src = 'https://imageurl.jpg'
applyImageBackground(image);
segmentBackground(inputVideoElement, outputCanvasElement, modelSelection <optional>);
Parameters:
inputVideoElement
: <HTMLVideoElement> Source of video which is to be used for applying segmentation.outputCanvasElement
: <HTMLCanvasElement> Canvas Element where output is to be displayed.modelSelection
: Numerical value to select type of model to be used for segmentation. applyBlur(blurIntensity <optional>);
Parameters:
blurIntensity
: Numerical value in pixels to apply a blur filter to the background. This uses the same filter as used in CSS blur filterapplyImageBackground(imageElement);
Parameters:
imageElement
: <HTMLImageElement> Image element to be set as background. You can create a new element dynamically using the Image() constructor.applyVideoBackground(videoElement);
Parameters:
videoElement
: <HTMLVideoElement> Video element to be set as background.applyScreenBackground(screenCaptureStream);
Parameters:
screenCaptureStream
: <MediaStream> Stream obtained from the Screen Capture APIAn example use case for this can be when user has set screen capture as the background and want to present something.
changeForegroundType(foregroundType, offset<optional>);
Parameters:
foregroundType
: normal | presenter
Type of foreground. Presenter mode shrinks the foreground and displays it in the bottom right corner.offset
: Numerical value in pixels for setting custom offset when presenter mode is selected.Note: I'm using mediapipe's selfie segmentation model and library as a base.
For any doubts/feedback/suggestions, please start an issue/discussion at https://github.com/akhil-rana/virtual-bg or contact me at contact@akhilrana.com
FAQs
Easily add virtual background effects to your video/camera input inside any web browser
The npm package virtual-bg receives a total of 87 weekly downloads. As such, virtual-bg popularity was classified as not popular.
We found that virtual-bg demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.