Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
libobs-wrapper
A safe, ergonomic Rust wrapper around the OBS (Open Broadcaster Software) Studio library. This crate provides a high-level interface for recording and streaming functionality using OBS's powerful capabilities, without having to deal with unsafe C/C++ code directly.
Features
- Thread Safety: Uses a dedicated thread to communicate with OBS, allowing safe cross-thread usage
- Async API: Full async support with optional blocking API (via
blocking
feature) - Resource Safety: RAII-based resource management for OBS objects
- Runtime Bootstrapping: Optional automatic download and setup of OBS binaries at runtime
- Scene Management: Create and manipulate scenes, sources, and outputs
- Video Recording: Configure and record video with various encoders
- Audio Support: Configure audio sources and encoders
- Display Management: Create and control OBS displays
Prerequisites
The library needs OBS binaries in your target directory. There are multiple ways to set this up:
Option 1: Using cargo-obs-build (Recommended for development)
Install the cargo-obs-build
tool:
Add the following to your Cargo.toml
:
[]
# The libobs version to use (can either be a specific version or "latest")
= "31.0.3"
# Optional: The directory to store the OBS build
# libobs-cache-dir = "../obs-build"
Install OBS in your target directory:
# For debug builds
# For release builds
# For testing
| )
Option 2: Using the OBS Bootstrapper (Recommended for distribution)
The library includes a bootstrapper that can download and install OBS binaries at runtime, which is useful for distributing applications without requiring users to install OBS separately.
-
Add a placeholder
obs.dll
file to your executable directory (eg.target/release/
). That file will be replaced by the bootstrap during runtime:- Download a dummy DLL from libobs-builds releases
- Use the version that matches your target OBS version
- Rename the downloaded file to
obs.dll
-
Enable the bootstrapper feature in your
Cargo.toml
:
[]
= { = "4.0.1", = ["bootstrapper"] }
= "0.1" # For implementing the bootstrap status handler
= "0.17" # Optional: For progress bars
- Create a bootstrap handler to track progress and initialize OBS:
use ;
use ;
use ;
;
async
With this approach, the bootstrapper will:
- Download OBS binaries if needed, showing progress in a nice progress bar
- Extract the files, continuing to show progress
- Return a restart signal if necessary
- Otherwise provide an initialized OBS context ready to use
If the bootstrapper returns ObsContextReturn::Restart
, your application should exit and will be automatically restarted with the updated binaries.
Basic Usage
Here's a simple example of recording a monitor screen (assuming the bootstrapper
feature is enabled):
use ;
use Duration;
async
Advanced Usage
For more advanced usage examples, check out:
- Monitor capture example with full configuration: examples/monitor_capture.rs
- Tauri integration example: examples/tauri-app
- Runtime bootstrapping example: examples/download-at-runtime
For even easier source creation and management, consider using the libobs-sources
crate which builds on top of this wrapper.
Features
blocking
- Provides a blocking API instead of async (useful for applications that don't need async)bootstrapper
- Enables the OBS bootstrapper for runtime download and installation
Common Issues
Missing DLLs or Crashes on Startup
If you're experiencing crashes or missing DLL errors:
- Make sure OBS binaries are correctly installed using either cargo-obs-build or the bootstrapper
- Check that you're using the correct OBS version compatible with this wrapper
- Verify that all required DLLs are in your executable directory
Memory Leaks
The library handles most memory management automatically, but you should avoid resetting the OBS context repeatedly as this can cause small memory leaks (due to an OBS limitation). Also notice that dropping Obs structs leads to a blocking call to the runtime.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- The OBS Project for the amazing OBS Studio software
- Contributors to the libobs-rs ecosystem