libOBS (OBS Studio) for Node.Js, Electron and similar tools
libOBS (OBS Studio) for Node.Js, Electron and similar tools
This library intends to provide bindings to obs-studio's internal library, named libobs accordingly, for the purpose of using it from a node runtime. Currently, only Windows and MacOS are supported.
You will need to have the following installed:
Building on windows requires additional software:
We use a flexible cmake script to be as broad and generic as possible in order to prevent the need to constantly manage the cmake script for custom uses, while also providing sane defaults. It follows a pretty standard cmake layout and you may execute it however you want.
Example:
yarn install
git submodule update --init --recursive
mkdir build
cd build
cmake .. -G"Visual Studio 17 2022" -A x64 -DCMAKE_PREFIX_PATH=%CD%/libobs-src/cmake/
cmake --build . --target install --config RelWithDebInfoThis will will download any required dependencies, build the module, and then place it in an archive compatible with npm or yarn that you may specify in a given package.json.
If you are testing a local libobs development package that was built before it bundled its public development dependencies, pass those dependency package prefixes with OSN_LIBOBS_DEPENDENCY_PREFIX_PATH. For example:
cmake .. -G"Visual Studio 17 2022" -A x64 -DCMAKE_PREFIX_PATH=%CD%/libobs-src/cmake/ -DOSN_LIBOBS_DEPENDENCY_PREFIX_PATH=D:/path/to/obs/.deps/obs-deps-2025-08-23sl2-x64Building on Mac requires Xcode.
Example (this assumes desktop repo is also installed in same parent folder and attempts to build a test developer app bundle so you can see browser sources, etc):
yarn install
git submodule update --init --recursive
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/Users//streamlabs/desktop/node_modules/obs-studio-node/OSN.app/distribute/obs-studio-node -DCMAKE_OSX_ARCHITECTURES=arm64 -G Xcode
cmake --build . --target install --config RelWithDebInfoNote, the only gotcha is that if you later run yarn package:mac-arm64 command in the desktop folder instead, then you should remove OSN.app from the CMAKE_INSTALL_PREFIX path. This is because the electron-builder scripts will throw an error this is not a fully formed app bundle during codesign.
By default, we download a pre-built version of libobs if none is specified. However, this pre-built version may not be what you want to use or maybe you're testing a new obs feature.
You may specify a custom archive of your own. However, some changes need to be made to obs-studio's default configuration before building:
ENABLE_SCRIPTING must be set to falseENABLE_UI must be set to falseQTDIR should not be specified as it is not used.If you don't know how to build obs-studio from source, you may find instructions here.
Install cppcheck from http://cppcheck.sourceforge.net/ and add cppcheck folder to PATH To run check from command line:
cd build
cmake --build . --target CPPCHECKAlso target can be built from Visula Studio. Report output format set as compatible and navigation to file:line posiible from build results panel.
Some warnings suppressed in files obs-studio-client/cppcheck_suppressions_list.txt and obs-studio-server/cppcheck_suppressions_list.txt.
Ninja and LLVM have to be installed in system. Warning: depot_tool have broken ninja.
To make build open cmd.exe.
…Step with "fixing" errors is important as code base and especially third-party code are not ready to be build with clang. And files which failed to compile will not be scanned for errors.
js/module.{js,d.ts})js/module.ts is the source of truth. js/module.js and js/module.d.ts (and the index.* / type_check.* siblings) are tsc outputs of js/tsconfig.json — the npm package ships them as-is, so they're committed. Regenerate with yarn build:javascript. yarn local:build already chains it. CI rejects stale outputs via .github/workflows/check-js-generated.yml (ci/check-js-generated.sh).
The tests for obs studio node are written in Typescript and use Mocha as test framework, with electron-mocha pacakage to make Mocha run in Electron, and Chai as assertion framework.
You need to build obs-studio-node in order to run the tests. You can build it any way you want, just be sure to use CMAKE_INSTALL_PREFIX to install obs-studio-node in a folder of your choosing. The tests use this variable to know where the obs-studio-node module is. Since we use our own fork of Electron, you also need to create an environment variable called ELECTRON_PATH pointing to where the Electron binary is in the node_modules folder after you run yarn install. Below are three different ways to build obs-studio-node:
In obs-studio-node root folder:
yarn installgit submodule update --init --recursive --forcemkdir buildcmake -Bbuild -H. -G"Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX="path_of_your_choosing"cmake --build build --target installIn obs-studio-node root folder:
mkdir buildyarn local:configyarn local:buildyarn local:cleanyarn installWhere is the source code: boxWhere to build the binaries: boxConfigureGenerateOpen Project to open Visual Studio and build the project thereSome tests interact with Twitch and we use a user pool service to get users but in case we are not able to fetch a user from it, we use the stream key provided by an environment variable. Create an environment variable called SLOBS_BE_STREAMKEY with the stream key of a Twitch account of your choosing.
yarn run test yarn run test --grep describe_name_value where describe_name_value is the name of the test passed to the describe call in each test file. Examples: yarn run test --grep nodeobs_api or yarn run test -g "Start streaming"If you wish to debug a specific test change the wildcard character to the name of your test (for ex, change *.ts into test_nodeobs_api.ts) in your launch.json:
…No open issues yet, or sync has not completed.