A native Node.js addon for Electron that enables real-time video sharing via Spout2 on Windows. Send frames from your Electron application to any Spout-compatible receiver (OBS, Resolume, TouchDesigner, etc.).
- Send video frames to Spout receivers from Electron
- Two output modes:
- CPU mode: Send raw pixel buffers (BGRA format)
- GPU mode: Send DirectX shared texture handles for zero-copy performance
- Built with N-API for ABI stability across Node.js versions
- Targets Electron 38.x
Windows only - Spout is a Windows-specific technology that relies on DirectX shared textures.
- Windows 10/11
- Visual Studio 2019 or later with C++ build tools
- vcpkg package manager
- Node.js 18+
- CMake 3.25+
# Clone vcpkg if you haven't already
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.bat
# Set environment variable
set VCPKG_ROOT=C:\path\to\vcpkgpnpm install
pnpm run buildOr with npm:
npm install
npx cmake-js compileimport { SpoutOutput } from 'electron-spout';
// Create a Spout sender with a name
const spout = new SpoutOutput('My Electron App');
// Send a frame using raw pixel data (CPU mode)
const width = 1920;
const height = 1080;
const pixels = new Uint8Array(width * height * 4); // BGRA format
// Fill pixels with your frame data...
spout.updateFrame(pixels, { width, height });
// Or send using a shared texture handle (GPU mode - more efficient)
spout.updateTexture({
widgetType: 'offscreen',
pixelFormat: 'BGRA8',
sharedTextureHandle: textureHandle
});
// Change the sender name
spout.name = 'New Sender Name';import { BrowserWindow } from 'electron';
import { SpoutOutput } from 'electron-spout';
const win = new BrowserWindow({
webPreferences: {
offscreen: true
}
});
const spout = new SpoutOutput('Electron Browser');
win.webContents.on('paint', (event, dirty, image) => {
const size = image.getSize();
const buffer = image.getBitmap();
spout.updateFrame(new Uint8Array(buffer), {
width: size.width,
height: size.height
});
});
win.webContents.setFrameRate(60);new SpoutOutput(name: string)Creates a new Spout sender with the specified name. The name will be visible to Spout receivers.
name: string- Get or set the Spout sender name
Sends a frame using raw pixel data.
buffer: Uint8Array- Pixel data in BGRA formatsize: { width: number, height: number }- Frame dimensions
Sends a frame using a DirectX shared texture handle (zero-copy).
options.widgetType: string- Widget type identifieroptions.pixelFormat: string- Pixel format (e.g., 'BGRA8')options.sharedTextureHandle: string- DirectX shared texture handle
# Debug build
npx cmake-js compile --debug
# Release build
npx cmake-js compile --release
# Rebuild
npx cmake-js rebuildThe compiled .node file will be in build/Release/ or build/Debug/.
Your Spout output can be received in:
- OBS Studio - Use the Spout2 Plugin for OBS
- Resolume Arena/Avenue - Native Spout support
- TouchDesigner - Native Spout support
- Unity - Spout4Unity
- Any Spout-compatible application
reito - Original author (2023)
MIT