Expand description
Safe, runtime-affine Rust access to the libobs object model.
§Start here
crate::context::ObsContext is the root managed handle. Most applications create it through
crate::utils::StartupInfo, then use only the modules needed for their workflow.
| What you need | Module |
|---|---|
| Discover installed sources/encoders/outputs/services | crate::capabilities |
| Configure arbitrary plugins from runtime metadata | crate::settings |
| Sources and filters | crate::sources |
| Scenes, groups, native order and transform snapshots | crate::scenes |
| Audio/video encoders | crate::encoders |
| Streaming services | crate::services |
| Validated output graphs and lifecycle | crate::data::output |
| Preview/display surfaces | crate::display |
| OBS event subscriptions | crate::signals and per-object signals() methods |
| Raw FFI escape hatch | [crate::sys] |
If you only need a conventional recorder, RTMP stream, replay buffer, or common capture source,
the libobs-simple crate is normally a better starting point. It uses this wrapper internally
and can be mixed with wrapper calls on the same crate::context::ObsContext.
§Plugin-generic workflow
Do not assume every machine has the same OBS plugins. The preferred generic path is:
- call
crate::context::ObsContext::capabilities; - choose by codec/protocol/capability, or use
crate::capabilities::ObsCapabilities::best_output_plan; - use descriptor
settings_schema_for/settings_snapshot_formethods to configure plugin settings without hard-coded property models; - create managed objects from the descriptors;
- use
crate::data::output::ObsOutputPipelineBuilderfor complete output graphs.
§Scene composition
crate::scenes::ObsSceneRef owns managed scene items and exposes libobs’s actual native order.
crate::scenes::SceneItemTrait covers transform/state behavior, including crop, bounds, scale
filters, blending, and restorable snapshots. crate::scenes::ObsSceneGroupRef represents native
OBS groups rather than simulating groups in Rust.
One important libobs behavior is exposed explicitly: ungrouping creates replacement parent-scene
items. crate::scenes::ObsSceneGroupRef::ungroup therefore returns replacement managed handles
and marks the replaced child handles removed.
§Ownership and unsafe access
Managed objects retain native references through one OBS runtime. Clones share a lifetime lease,
and operations validate runtime affinity before combining objects. Prefer opaque object IDs for
identity. [crate::sys] is available when raw libobs functionality is genuinely needed, but raw
pointers carry the usual libobs thread-affinity and reference-count responsibilities.
The repository’s docs/api_orientation.md contains a longer task-to-module guide and examples.
Re-exports§
pub use libobs as sys;
Modules§
- capabilities
- Runtime capability discovery and compatibility planning for the loaded OBS installation.
- context
- OBS Context Management
- crash_
handler - Contains a default crash handler that is attached by default to the ObsContext.
By default this will handle crashes just by printing them out to console, if the
dialog-crash-handlerfeature is disabled. If you want to implement your own crash handler, make sure that you do the least amount of work possible and access as few global variables as you can, as it is quite unstable if libobs has crashed. - data
- This module contains every struct related to storing data in OBS. There are two important structs:
- display
- This module is used to create a
OBS displaywhich you can use to preview the output of your recording. - encoders
- This module contains video- and audio-encoders. In simple terms, you need a video and audio encoder, so a proper mp4 file can get written to disk (with video and audio). If you are unsure which encoder to use, you might as well take a look at the libobs-simple crate for a output that has all needed encoders attached already.
- enums
- Contains all important enums for this crate
- graphics
- Holds a Vec2 vector, mainly used for positioning the ObsDisplay or ObsSceneItems.
- logger
- This module is used to provide a logger trait, which can be used to implement custom logging for the libobs console output.
- runtime
- Runtime management for serialized OBS access.
- scenes
- Scenes, managed scene items, native OBS groups, ordering, and transform state.
- services
- Typed OBS streaming-service handles.
- settings
- Generic, plugin-agnostic settings schemas built from OBS property metadata.
- signals
- Per-object OBS signal subscriptions.
- sources
- This module holds everything related to sources. A source renders specific content to the scene, which is then processed by the ObsOutputRef and for example written to a file using encoders.
- utils
Macros§
- impl_
obs_ drop - Implement a non-panicking native cleanup guard.
- impl_
signal_ manager - Generate a signal manager whose subscription state is owned by that manager.
- run_
with_ obs - Execute work on the OBS actor while preserving the runtime’s structured error.
- run_
with_ obs_ impl