
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
greenscreenstream
Advanced tools
Genereate new MediaStreams or Canvas elements based on MediaStreams (webcam) with any background image/video. Greenscreen your webcam and enable virtual backgrounds in your web applications.
GreenScreenStream provides a wide range of options for manipulating Mediastreams.
Generate a new MediaStream for <canvas> & <video> elements based on provided MediaStreamTrack and a background image/video just using JavaScript.
After processed and "green screened" you can capture the stream and use it in your WebRTC calls for instance.
All rendering is done in realtime using a WebGL2 pixel shader (glsl) and optionally machine-learning.
npm install greenscreenstream
Below you find a few different examples of greenscreenstream.
https://coloquium.github.io/greenscreenstream/example/mlWebGL
https://coloquium.github.io/greenscreenstream/example/WebGL#snow.mp4
https://coloquium.github.io/greenscreenstream/example/hologram
https://coloquium.github.io/greenscreenstream/example/procedual
https://coloquium.github.io/greenscreenstream/example/WebGL
See
/example/folder in repo for implementation.
Creates an instance of GreenScreenStream
constructor(greenScreenMethod: GreenScreenMethod, canvas?: HTMLCanvasElement, width?: number, height?: number)
Initlializes the GreenScreenStream with the provided background (image or video) and settings.
initialize(backgroundUrl?: string, config?: GreenScreenConfig): Promise<boolean>
Adds a MediaStreamTrack (i.e webcam)
addVideoTrack(track: MediaStreamTrack): Promise<void | any>;
Starts rendering the greenscreen. You can optionally set a fps maximum here
start(maxFps?: number): void
Stops the rendering process.
Optionally stop the media streams.
Stopping the streams works only if there are no references to them
outside of greenscreenstream.
stop(stopMediaStreams?:boolean): void
Capture the rendered result to a MediaStream that you apply to your <video> element.
captureStream(fps?: number): MediaStream;
Gets the most dominant color and a list (palette) of the colors most common in the provided MediaStreamTrack.
getColorsFromStream(): { palette: [number, number,number][], dominant: [number, number,number] } {
Pass a mask (rgb), color to the shader , to use as a mask. Should be the dominant color, or on of the palette colors detected. See getColorsFromStream
setChromaKey(r: number, g: number, b: number, threshold?: number): void;
Range is used to decide the amount of color to be used from either foreground or background.Playing with this variable will decide how much the foreground and background blend together.
setMaskRange(x:number,y:number): void
Get the most dominant color based on imageData and number of pixels
dominant(imageData: ImageData, pixelCount: number): [number, number,number] {
Get an Array of the most significant colors in the MediaTrack
pallette(imageData: ImageData, pixelCount: number): [number, number,number][] | null {
Sets the virtual background to a new image or video. Can be done while GreenScreenStream is running.
setBackground(src: string): Promise<HTMLImageElement | HTMLVideoElement | Error>
Swaps out the currently used BodyPixModel used in ml mode (GreenScreenMethod.VirtualBackground) (See GreenScreenMethod down below)
setBodyPixModel(config: IGreenScreenConfig): Promise<void>
Describes the method GreenScreenStream should use for applying a virtual background.
GreenScreenMethod.VirtualBackground uses a machine learning model (Tensorflow BodyPix)
GreenScreenMethod.VirtualBackgroundUsingGreenScreen works without a machine learning model and thus consumes much less performance,
but requires the user to have a green screen.
enum GreenScreenMethod {
Mask = 0, // get the mask
VirtualBackground = 1, // get mask and apply the provided background using MachineLearning
VirtualBackgroundUsingGreenScreen = 2 // user has a green screen, use shader only.
}
Provides detailed configuration options for GreenScreenStream.
maskSettings can be uses to fine tune the virtual background appearance. (
bodyPixMode can be used to apply premade BodyPix configurations (see GreenScreenStreamBodyPixMode for more details),
while bodyPixConfig allows you to configure BodyPix as you see fit. If both are provided, bodyPixMode will be ignored.
IGreenScreenConfig {
maskSettings?: IMaskSettings,
bodyPixMode?: GreenScreenStreamBodyPixMode,
bodyPixConfig?: IBodyPixConfig
}
Determines which BodyPix Preset GreenStream should use.
Presets Standard or Precise are recommended for most use cases.
Fast is meant for really weak clients, is unprecise and causes flickering.
Maximum uses a more complex ML Model and thus causes much more network traffic & gpu + cpu load.\
enum GreenScreenStreamBodyPixMode {
Fast = 0,
Standard = 1,
Precise = 2,
Maximum = 3
}
architecture: 'MobileNetV1',
outputStride: 16,
multiplier: 0.5,
quantBytes: 1
architecture: 'MobileNetV1',
outputStride: 16,
multiplier: 0.75,
quantBytes: 2
architecture: 'MobileNetV1',
outputStride: 16,
multiplier: 1,
quantBytes: 2
architecture: 'ResNet50',
outputStride: 32,
quantBytes: 2
Description TBA
interface IMaskSettings {
opacity?: number
flipHorizontal?: boolean
maskBlurAmount?: number
foregroundColor?: RGBA
backgroundColor?: RGBA
segmentPerson?: {
flipHorizontal?: boolean
internalResolution?: string
segmentationThreshold?: number
maxDetections?: number
quantBytes?: number
}
};
export interface RGBA {
r: number, g: number, b: number, a: number
}
FAQs
Genereate new MediaStreams or Canvas elements based on MediaStreams (webcam) with any background image/video. Greenscreen your webcam and enable virtual backgrounds in your web applications.
We found that greenscreenstream 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.