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
105 stars 19 forks source link

How to get window capture ? #14

Open GaeDLLD opened 4 years ago

GaeDLLD commented 4 years ago

Hello there, I'm trying to get all opened windows list and display them one by one with a selector (in the renderer). But, here's my question, how to choose window capture instead of obsCamera (in the obsRecorder.js) ? Thanks

hrueger commented 4 years ago

I believe that

  const videoSource = osn.InputFactory.create('monitor_capture', 'desktop-video');

has to be replaced with

  const videoSource = osn.InputFactory.create('window_capture', 'desktop-video', {
    window: xyz,
  });

and that we have to specify the window to be captured in the third parameter. But I couldn't get it to work. Neither with the NativeWindowHandle nor with ids...

Envek commented 4 years ago

@GaeTheDev take a look at https://github.com/Envek/obs-studio-node-example/issues/12#issuecomment-636672631

Does it solve your problem?

GaeDLLD commented 4 years ago

Hey, thank you @hrueger for your answer, but it's not working for me too... I replaced the window value "xyz" by the window name (found in OBS-Studio) but no result... Do you have any other idea ?

GaeDLLD commented 4 years ago

Sorry @Envek I didn't see your comment ! I tried it and it's working to get a list of all opened windows but not to get displayable result. I get only mouse capture with black screen and screen size instead of window size (I think I need to crop it with window width & height)

image

ChaosTong commented 4 years ago

Sorry @Envek I didn't see your comment ! I tried it and it's working to get a list of all opened windows but not to get displayable result. I get only mouse capture with black screen and screen size instead of window size (I think I need to crop it with window width & height)

image

i think you should add this input to a scene, then can display it, i work it out QQ截图20200707174604