#obs #libobs #screen-recording #recording #encoding

libobs-sources

A helper crate to create sources for OBS

2 releases

new 0.1.1 Sep 18, 2024
0.1.0 Aug 5, 2024

#384 in Video

Download history 86/week @ 2024-07-31 23/week @ 2024-08-07

83 downloads per month

GPL-3.0 license

530KB
2.5K SLoC

libOBS Sources

This crate makes it really easy to create new sources for OBS Studio using the libobs crate.

Example

// Set up the obs context and output here (see libobs-new crate for more info)

let (mut context, output) = initialize_obs(rec_file);
let output = context.get_output(&output).unwrap();

let windows =
    WindowCaptureSourceBuilder::get_windows(WindowSearchMode::ExcludeMinimized).unwrap();
let window = windows.into_iter().find(|w| {
    w.class
        .as_ref()
        .is_some_and(|e| e.to_lowercase().contains("notepad"))
})
.unwrap();

WindowCaptureSourceBuilder::new("test_capture")
    .set_window(&window)
    .add_to_output(output, 0)
    .unwrap();
// And the window capture source is added and captures the notepad window!

lib.rs:

A library for creating OBS sources without having to figure out what properties are used by sources. Example usage (for window capture only on windows):

use libobs_window_helper::WindowSearchMode;
use libobs_wrapper::{context::ObsContext, sources::ObsSourceBuilder, utils::{OutputInfo, StartupInfo}};
use libobs_sources::windows::WindowCaptureSourceBuilder;


let output = context.output(output_info).unwrap();

// Do other initialization for video encoders, audio encoders, etc.

let windows = WindowCaptureSourceBuilder::get_windows(WindowSearchMode::IncludeMinimized).unwrap();
let example_window = windows.get(0).unwrap();

WindowCaptureSourceBuilder::new("Test Window Capture")
.set_window(example_window)
// Obs Output is created from `ObsContext`
.add_to_output(output, 0)
.unwrap();

Dependencies

~2–32MB
~494K SLoC