Closed alokmahor closed 3 years ago
Hi @alokmahor,
What issue do you have with electron-builder
? I use it in AGView and it works fine.
I tried to generate installer by adding electron-build
related entries in package.json
.
{
"name": "obs-studio-node-example",
"version": "1.0.0",
"description": "Electron and OBS together. As simple as possible.",
"main": "index.js",
"scripts": {
"start": "electron .",
"test": "echo \"Error: no test specified\" && exit 1",
"pack": "electron-builder --dir",
"dist": "electron-builder",
"postinstall": "electron-builder install-app-deps"
},
"keywords": [
"streaming"
],
"author": "",
"license": "GPL-2.0",
"dependencies": {
"obs-studio-node": "https://obsstudionodes3.streamlabs.com/osn-0.10.10-release-win64.tar.gz",
"rxjs": "^6.6.3",
"uuid": "^8.3.0"
},
"devDependencies": {
"electron": "^10.2.0",
"electron-builder": "^22.10.5"
},
"build": {
"appId": "com.something.app"
}
}
I run yarn dist
to generate installer.
I am able to see installer in dist
directory. I am able to run it but it get closed automatically. When I run this installer it install at C:\Users\alokm\AppData\Local\Programs\obs-studio-node-example\obs-studio-node-example.exe
When I try to run C:\Users\alokm\AppData\Local\Programs\obs-studio-node-example\obs-studio-node-example.exe
this open for about one second then it get closed automatically.
I am on master
branch of code.
What I am missing to make it working?
If you start a terminal / command prompt, navigate to C:\Users\alokm\AppData\Local\Programs\obs-studio-node-example\
and run the exe, what is the output?
I dont see any error message. GUI opens for only about one second then closes itself. I see only only log line
PS C:\Users\alokm\tmp\streamlabs\obs-studio-node-example> cd C:\Users\alokm\AppData\Local\Programs\obs-studio-node-example
PS C:\Users\alokm\AppData\Local\Programs\obs-studio-node-example> .\obs-studio-node-example.exe
PS C:\Users\alokm\AppData\Local\Programs\obs-studio-node-example>
Initializing OBS...
PS C:\Users\alokm\AppData\Local\Programs\obs-studio-node-example>
I guess execution is getting stuck in
function initOBS() {
console.debug('Initializing OBS...');
osn.NodeObs.IPC.host(`obs-studio-node-example-${uuid()}`);
osn.NodeObs.SetWorkingDirectory(path.join(__dirname, 'node_modules', 'obs-studio-node'));
const obsDataPath = path.join(__dirname, 'osn-data'); // OBS Studio configs and logs
// Arguments: locale, path to directory where configuration and logs will be stored, your application version
const initResult = osn.NodeObs.OBS_API_initAPI('en-US', obsDataPath, '1.0.0');
if (initResult !== 0) {
const errorReasons = {
'-2': 'DirectX could not be found on your system. Please install the latest version of DirectX for your machine here <https://www.microsoft.com/en-us/download/details.aspx?id=35?> and try again.',
'-5': 'Failed to initialize OBS. Your video drivers may be out of date, or Streamlabs OBS may not be supported on your system.',
}
const errorMessage = errorReasons[initResult.toString()] || `An unknown error #${initResult} was encountered while initializing OBS.`;
console.error('OBS init failure', errorMessage);
shutdown();
throw Error(errorMessage);
}
Code is running fine but distribution is not running. What can be the reason?
I found the problem. In the path generated by path.join
we have to replace app.asar
by app.asar.unpacked
. I remember that I had to do this in AGView, too: https://github.com/hrueger/AGView/blob/0de69a75ad308959f152480a53099cd72706d1f5/src/worker/obs.ts#L61-L62
@Envek Should I create a PR? It doesn't break anything when run in dev mode as in that case there is no app.asar
in the path, so nothing will be replaced.
Edit: They even do this in streamlabs-obs
: https://github.com/stream-labs/streamlabs-obs/blob/93a61df3d3b9419749150931c9ba1887e6e30db4/app/app.ts#L287-L293 😅
Should I create a PR?
@hrueger oh, yes, please! :pray:
Thank you for the investigation!
Thank you @hrueger and @Envek :)
replacing app.asar
by app.asar.unpacked
sovled my problem 🙏
@Envek The videos
folder does not exist when packaged. Should we use the default videos folder? https://www.electronjs.org/docs/api/app#appgetpathname
Since this is a different problem, would you mind creating a separate issue for that? I am sorry. I have created new issue
Since this is a different problem, would you mind creating a separate issue for that?
How to package this electron app for distribution? I tried to package using electron-builder but that does not work.