Envek / obs-studio-node-example

Learn how to use OBS Studio from your Electron app for screen video recording
GNU General Public License v2.0
104 stars 19 forks source link

Creating 'window_capture' & 'game_capture' inputs #12

Closed lulzsun closed 4 years ago

lulzsun commented 4 years ago

Hey! The example works great, however it doesn't provide any examples other than Display, Audio Device, and Video Device capture.

The examples provide clear and intuitive usage on those inputs, but others are not as easy to use, due to lack of documentation.

For example, I have tried to create a game capture source like so: const gameSource = osn.InputFactory.create('game_capture', 'game-source');

However, I wasn't able to understand how to define a window/source for the game capture. The gameSource.settings also do not show a way to add a source:

{ allow_transparency: false, anti_cheat_hook: true, auto_capture_rules_path: '', auto_placeholder_image: '', auto_placeholder_message: 'Looking for a game to caputure', capture_cursor: true, capture_mode: 'auto', capture_overlays: false, force_scaling: false, hook_rate: 1, limit_framerate: true, priority: 2, scale_res: '0x0', sli_compatibility: false }

If someone could provide an simple example on creating a 'game_capture' and 'window_capture', would greatly appreciate it!

lulzsun commented 4 years ago

Partially solved. Here's a quick and dirty example on how to create and pick a window for window_capture:

const videoSource = osn.InputFactory.create('window_capture', 'window-source');
let settings = videoSource.settings;
let windows = videoSource.properties.get('window').details.items;
settings['window'] = windows[0].value; //first detected 'window' in the array of windows
videoSource.update(settings);
videoSource.save();

I'm assuming 'game-capture' works the same way. Closing this.

Envek commented 4 years ago

Thank you for sharing code examples!

chfeizy commented 4 years ago

@lulzsun let windows = videoSource.properties.get('window').details.items; when the windows[0].value has chinese, and use encodeURI(windows[0].value) Preview is still black

aza547 commented 2 years ago

Thanks for this answer. It's helpful.

Window capture didn't work for me to capture the game, it seems to capture the region on my screen behind the game rather than the game itself.

I tried to make game_capture work in the same manner but had no luck. Is there a reference somewhere to these properties?

aza547 commented 2 years ago

Hm I found an example here: https://github.com/davidweatherall/replayslol-obs-recorder/blob/a1dac524eca22d95a7e940d3ab65a2eb6613fe30/src/NodeRecorder.ts

Might be an issue with my PC... recording appears to be working but the playback shows a black screen.