Skip to content


Switch branches/tags


Failed to load latest commit information.
Latest commit message
Commit time

OBS Plugin: Background Removal


Check out the latest releases for downloads and install instructions.


This plugin is meant to make it easy to replace the background in portrait images and video. It is using a neural network to predict the mask of the portrait and remove the background pixels. It's easily composable with other OBS plugins to replace the background with e.g. an image or a transparent color.

The models used for background detection are SINet: and MODNet: The pre-trained model weights were taken from:

Some more information about how I built it:


The plugin was built and tested on Mac OSX, Windows and Ubuntu Linux. Help is appreciated in building on other OSs and formalizing the one-click installers.

Prerequisites for building


Install dependencies

You may use homebrew:

$ brew install opencv onnxruntime

Or - you may also build a (very minimal) version of OpenCV and ONNX Runtime for static-linking, instead of the homebrew ones:

<root>/build/ $ ../scripts/
<root>/build/ $ ../scripts/

Static linking should be more robust across versions of OSX, as well as building for 10.13.

Finding libobs

If you install the desktop OBS app ( you already have the binaries for libobs (e.g. /Applications/ But you don't have the headers - so clone the main obs repo e.g. git clone --single-branch -b 27.2.4 (match the version number to your OBS install. Right now on OSX it's 27.2.4)


$ mkdir -p build && cd build
$ cmake .. -DobsLibPath=/Applications/ -DobsIncludePath=~/Downloads/obs-studio/libobs
$ cmake --build . --target dist
$ cpack


Unpack the package to the plugins directory of the system's Library folder (which is Apple's preferred way but requires admin privileges)

sudo mkdir -p "/Library/Application Support/obs-studio/plugins/obs-backgroundremoval"
sudo unzip -j "Plugins/" -d "/Library/Application Support/obs-studio/plugins/obs-backgroundremoval/bin"
sudo unzip -j "Resources/data/obs-plugins/obs-backgroundremoval/*" -d "/Library/Application Support/obs-studio/plugins/obs-backgroundremoval/data"

or directly to your OBS install directory, e.g.

$ unzip -o -d /Applications/

The first is recommended as it preserves the plugins over the parallel installation of OBS versions (i.e. running the latest productive version and a release candidate), or operations like brew upgrade obs, whereas the latter will also remove the plugin if you decide to delete the OBS application.



$ sudo apt install -y libobs-dev libopencv-dev language-pack-en wget git build-essential cmake libsimde-dev
$ wget
$ sudo tar xzvf onnxruntime-linux-x64-1.7.0.tgz --strip-components=1 -C /usr/local/ --wildcards "*/include/*" "*/lib*/"

Clone this repo into a directory of your choice, then build and install, e.g.:

$ cd obs-backgroundremoval
$ mkdir build && cd build
$ cmake .. && cmake --build . && sudo cmake --install .

To build with CUDA support, you will need the CUDA libraries installed as well as the GPU version of the ONNX Runtime library.

Use the instructions at to set up the NVIDIA Cuda repository, then:

These instructions use the 1.9.0 version of onnxruntime. If you wish to use a different version, change the export line to the version number you require.

$ export ONNX_VERSION=1.9.0
$ sudo apt install cuda libcudnn8
$ wget${ONNX_VERSION}/onnxruntime-linux-x64-gpu-${ONNX_VERSION}.tgz
$ sudo tar xzvf onnxruntime-linux-x64-gpu-${ONNX_VERSION}.tgz --strip-components=1 -C /usr/local/ --wildcards "*/include/*" "*/lib*/"

Then build and install:

$ sudo ldconfig  # required if you have previously had a different version of onnxruntime installed
$ mkdir build && cd build
$ cmake -DWITH_CUDA=ON .. && cmake --build . && sudo cmake --install .

If after installing, the plugin fails to load and cannot be found in the interface, there are additional steps to carry out.

$ mkdir -p ~/.config/obs-studio/plugins/obs-backgroundremoval/bin/64bit
$ ln -s /usr/local/lib/obs-plugins/ ~/.config/obs-studio/plugins/obs-backgroundremoval/bin/64bit/
$ ln -s /usr/local/share/obs/obs-plugins/obs-backgroundremoval ~/.config/obs-studio/plugins/obs-backgroundremoval/data

If you wish to install this system-wide, change obs-studio path from ~/.config/obs-studio/plugins to /usr/share/obs/obs-plugins.


A PKGBUILD file is provided for making the plugin package

$ cd scripts
$ makepkg -s

Building for Arch in Docker (host OS e.g. MacOSX):

$ docker pull archlinux:latest
$ docker run -it -v $(pwd):/src archlinux:latest /bin/bash
# pacman -Sy --needed --noconfirm sudo fakeroot binutils gcc make
# useradd builduser -m
# passwd -d builduser
# printf 'builduser ALL=(ALL) ALL\n' | tee -a /etc/sudoers
# sudo -u builduser bash -c 'cd /src/scripts && makepkg -s'


We will use static linking (as much as possible) to aviod having to lug around .DLLs with the plugin.

Install Prerequisites

Install OpenCV via vcpkg:

$ mkdir build
$ cd build
$ git clone
$ cd vcpkg
$ .\bootstrap-vcpkg.bat
$ .\vcpkg.exe install opencv[core]:x64-windows-static

Install Onnxruntime with NuGet:

$ cd build
$ mkdir nuget
$ Invoke-WebRequest -UseBasicParsing -OutFile nuget.exe
$ .\nuget.exe install Microsoft.ML.OnnxRuntime.DirectML -Version 1.11.0
$ .\nuget.exe install Microsoft.ML.OnnxRuntime.Gpu -Version 1.11.0
Build OBS Studio from source

Clone the OBS repo, $HOME\Downloads\ $ git clone --recursive, to e.g. Downloads. Use OBS scripts to build: $HOME\Downloads\obs-studio $ .\CI\build-windows.ps1

Find the complete instructions here:

Build and install the plugin

$ cmake .. -Dlibobs_DIR="$HOME\Downloads\obs-studio\build64\libobs"
$ cmake --build . --config Release
$ cpack
$ Expand-Archive .\ -DestinationPath 'C:\Program Files\obs-studio\' -Force

To build with CUDA support, tell cmake to use the CUDA version of OnnxRuntime

$ cmake .. -Dlibobs_DIR="$HOME\Downloads\obs-studio\build64\libobs" -DWITH_CUDA=ON

The rest of the build process is similar, but the result archive will be