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

osn.InputFactory.create('window_capture', 'window-source') Black screen with Chinese #21

Closed chfeizy closed 4 years ago

chfeizy commented 4 years ago
  const videoSource = osn.InputFactory.create('window_capture', 'window-source',{ device_id: 'does_not_exist' });
  let windows = videoSource.properties.get('window').details.items;
  const { physicalWidth, physicalHeight, aspectRatio } = displayInfo();
  let value=windows[0].value;
  let settings = videoSource.settings;
  settings['window'] = encodeURI(value);
  settings['width'] = physicalWidth;
  settings['height'] = physicalHeight;
  videoSource.update(settings);
  videoSource.save();
┏ Electron -------------------

  [{"name":"[electron.exe]: 直播客户端","enabled":true,"value":"直播客户端:Chrom
e_WidgetWin_1:electron.exe"},{"name":"[cmd.exe]: npm","enabled":true,"value":"np
m:ConsoleWindowClass:cmd.exe"},{"name":"[chrome.exe]: 百度一下,你就知道 - Googl
e Chrome","enabled":true,"value":"百度一下,你就知道 - Google Chrome:Chrome_Widg
etWin_1:chrome.exe"}]
  window value
  %E7%99%BE%E5%BA%A6%E4%B8%80%E4%B8%8B%EF%BC%8C%E4%BD%A0%E5%B0%B1%E7%9F%A5%E9%81
%93%20-%20Google%20Chrome:Chrome_WidgetWin_1:chrome.exe

┗ ----------------------------

When there is Chinese in the value, the screen will be black

Envek commented 4 years ago

Why do you do encodeURI(value)? I wonder whether there is some string re-encoding is required (e.g. Windows uses UTF-16 almost everywhere internally, AFAIK).


I think you'd better to open this issue in obs-studion-node library repository instead at https://github.com/stream-labs/obs-studio-node/issues – we're just users of it that reverse-engineer how to use it.

chfeizy commented 4 years ago

@Envek ok