Integration for backscrub project into OBS Studio
APACHE-2.0 License
Integration for backscrub project into OBS Studio
It's a video filter plugin for OBS Studio (currently limited to video capture devices that produce YUY2 format streams), which uses the backscrub
library to remove the background of a video source (replacing it with green), allowing subsequent chroma keying of alternate backgrounds.
build-essentials
, libobs-dev
, libopencv-dev
% mkdir build; cmake -B build; cmake --build build -j
This will pull the submodules (backscrub and Tensorflow), configure them (mostly Tensorflow fetching several more dependencies) then compile everything. Expect to wait 10+ minutes for a full build, and lose ~2GB of disk space.
NB: This is fiddly, fragile and poorly tested
C:\Users\phlash\Download\opencv
libobs
folder eg: C:\Users\phlash\Downloads\libobs
libobs
folder and unpack in place to get a CMake config scriptlibobs
folder into folder above, then rename as inc
, eg: C:\Users\phlash\Downloads\libobs\inc
bin
folder next to inc
eg: C:\Users\phlash\Downloads\libobs\bin
OBS.DLL
library out of your installed OBS Studio eg: C:\Program Files\obs-studio\bin\64bit\OBS.DLL
into bin
folder.VS2019 Developer Command Prompt
, generate an import library from the DLL, instructions modified from: https://stackoverflow.com/questions/9946322/how-to-generate-an-import-library-lib-file-from-a-dll
C> cd <libobs\bin folder>
C> echo LIBRARY OBS > obs.def
C> echo EXPORTS >> obs.def
C> for /f "skip=19 tokens=4" %A in ('dumpbin /exports OBS.DLL') do echo %A >> obs.def
C> lib /def:obs.def /out:OBS.LIB /machine:x64
windows-build
branch.VS2019 Developer Command Prompt
Do the CMake dance, informing it where OpenCV and libobs are:C> mkdir build
C> cmake -B build -D CMAKE_PREFIX_PATH="<OpenCV path>\build;<libobs folder>"
C> cmake --build build -j
tensorflow\tensorflow\core\lib\random\random_distributions_utils.h
and replace M_PI
symbol with 3.1415928
.C> cmake --build build -j
I choose to create sym-links for the built object and the data directory out of the obs-studio installation, this avoids install-to-test issues:
% cd /lib/x86_64-linux-gnu/obs-plugins
% sudo ln -s /home/phlash/obs-backscrub/build/obs-backscrub.so .
% cd /usr/share/obs/obs-plugins
% sudo ln -s /home/phlash/obs-backscrub/data obs-backscrub
Not quite the same as Linux as Windows cannot do file symlinks, only folders, so we copy the built object and dependencies:
C> cd \Program Files\obs-studio\obs-plugin\64bit
C> copy \Users\phlash\obs-backscrub\build\obs-backscrub.dll
C> copy <OpenCV path>\build\x64\opencv-world3414d.dll
C> cd ..\..\data\obs-plugin
C> mklink /D obs-backscrub \Users\phlash\obs-backscrub\data
Fire up OBS Studio - check the logs to ensure obs-backscrub.dll
loads successfully.
Add a video capture source, go to filters, and add an audio/video filter 'Background scrubber'. That's it.