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

OBS ignores programmatic set output video resolution #3

Closed Envek closed 4 years ago

Envek commented 4 years ago

OBS seems to ignore programmatic changes to set output video resolution to 1920x1080 here:

https://github.com/Envek/obs-studio-node-example/blob/918b801c830aef210ffbc8e22c9278acb525dcea/obsRecorder.js#L86-L89

Workaround: You can manually edit OBS configuration in osn-data subfolder and set OutputCX and OutputCY parameters under Video section to your display resolution (e.g. 1920 and 1080 respectively).

Originally posted by @hrueger in https://github.com/Envek/obs-studio-node-example/issues/2#issuecomment-612997973

I also noticed that only about 2/3 of my screen were recorded and in the logs (attached) it says this:

video settings reset:
   base resolution:   1536x960
   output resolution: 1228x768

My screen, however, is 1920x1200. I don't know much about OBS, but I don't think this problem belongs to the RecEncoder settings, does it?

2020-04-13 06-51-24.txt

After having a closer look at the code, I found that this already returns 1536x960. So no problem with your code, sorry! Probably a Windows scaling issue (my scaling is at 125% because I'm using a convertible). 1920 / 1.25 = 1536

  const { screen } = require('electron');
  const primaryDisplay = screen.getPrimaryDisplay();

Edit: After inspecting the whole code I saw that the scaleFactor is multiplied with the display size values retrieved from the electron screen module and the realDisplayWith and realDisplayHeight variables do have the correct value.

Envek commented 4 years ago

I have no time to tackle with it right now, but hope that it is something wrong with setSetting method (which was copied verbatim from obs-studio-node tests) and it just changes resolution in some wrong settings subcategory may be).

Envek commented 4 years ago

It turned out that settings from API are slightly differs in format from what is stored in OBS Studio's basic.ini.

How to set resolution to 1920x1080:

setSetting('Video', 'Base', '1920x1080');
setSetting('Video', 'Output', '1920x1080');

And how it will appear in osn-data/basic.ini:

[Video]
BaseCX=1920
BaseCY=1080
OutputCX=1920
OutputCY=1080