libobs via node bindings
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.
yarn install git submodule update --init --recursive mkdir build cd build cmake .. -G"Visual Studio 16 2019" -A x64 cmake --build . cpack -G ZIP
This 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.
Custom OBS Build
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_SCRIPTINGmust be set to
ENABLE_UImust be set to
QTDIRshould not be specified.
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 console:
cd build cmake --build . --target CPPCHECK
Also 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
LLVM have to be installed in system. Warning: depot_tool have broken ninja.
To make build open
mkdir build_clang cd build_clang "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat" set CCC_CC=clang-cl set CCC_CXX=clang-cl set CC=ccc-analyzer.bat set CXX=c++-analyzer.bat #set CCC_ANALYZER_VERBOSE=1 #make ninja project cmake -G "Ninja" -DCLANG_ANALYZE_CONFIG=1 -DCMAKE_INSTALL_PREFIX:PATH="" -DCMAKE_LINKER=lld-link -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_SYSTEM_NAME="Generic" -DCMAKE_MAKE_PROGRAM=ninja.exe .. #try to build and "fix" errors ninja.exe #clean build to scan ninja.exe clean scan-build --keep-empty -internal-stats -stats -v -v -v -o check ninja.exe
"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.
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:
git submodule update --init --recursive --force
cmake -Bbuild -H. -G"Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX="path_of_your_choosing"
cmake --build build --target install
Terminal using package.json scripts
In obs-studio-node root folder:
- Optional: To clean build folder to repeat the steps 2 to 3 again do
- Create a build folder in obs-studio-node root
- Open CMake GUI
- Put obs-studio-node project path in
Where is the source code:box
- Put path to build folder in
Where to build the binaries:box
- Change CMAKE_INSTALL_PREFIX to a folder path of your choosing
Open Projectto open Visual Studio and build the project there
Some 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.
- To run all the tests do
yarn run test
- To run only run one test do
yarn run test --grep describe_name_valuewhere
describe_name_valueis the name of the test passed to the describe call in each test file. Example:
yarn run test --grep nodeobs_api