mybatis-dynamic-sql
mybatis-dynamic-sql copied to clipboard
Electron build path issue
This code, which works in a dev build, throws a path error in a production build:
const options = { input: file.path, output: '../video_crunched.mp4', width: 1280, height: 720 }
hbjs.spawn(options)
.on('error', err => {
console.log('Error: ', err)
})
.on('progress', progress => {
console.log(
'Percent complete: %s, ETA: %s',
progress.percentComplete,
progress.eta
)
})
This is the error:
Error: HandbrakeCLINotFound: HandbrakeCLI application not found: /Users/birchbrowning/Development/video_test/dist/electron/Video Cruncher-darwin-x64/Video Cruncher.app/Contents/Resources/bin/HandbrakeCLI. Linux users must install HandbrakeCLI manually, please see https://handbrake.fr/downloads.php.
at i._run (file:///Users/birchbrowning/Development/video_test/dist/electron/Video%20Cruncher-darwin-x64/Video%20Cruncher.app/Contents/Resources/app.asar/js/vendor.js:11:53007)
at file:///Users/birchbrowning/Development/video_test/dist/electron/Video%20Cruncher-darwin-x64/Video%20Cruncher.app/Contents/Resources/app.asar/js/vendor.js:6:97230
at processTicksAndRejections (internal/process/task_queues.js:75:11)
process.platform = darwin process.arch = x64
I tried some of the edits referenced in an early issue, but they also resulted in various errors. I can try again and document those, if it would help.
Note: I'm using Quasar, and found the suggestion asar: false
in one of the forums. When I did that, I ended up with a app folder the did include HandbrakeCLI, but the path was still incorrect. Again, I can go back and recreate that if it will help.
I will happily pay a beer bounty if you can help me figure this out!
Out of curiosity, I implemented the changes jpangelle suggested on Dec 6, 2018, and I get this error:
Error: InvalidInput: Invalid input, not a video file [error code: 2]
at ChildProcess.eval (webpack-internal:///./node_modules/handbrake-js/lib/Handbrake.js:130:15)
at ChildProcess.emit (events.js:210:5)
at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
Perhaps I can just change my arguments and it will work. If so, could you suggest the correct way?
I have never used Electron before, I don't know where to begin debugging this.. Maybe it's time I learned Electron..
One known issue is that Electron has a different process.argv
structure which causes issues with command-line arguments.. Is that relevant?
Sorry, I hadn't put in the code snippets so the first lines didn't show. That's resolved so you can see the complete code and error statements.
I was able to make it work by altering the path in config.js for electron build:
HandbrakeCLIPath = path.join(__dirname, '..', 'app', 'node_modules', 'handbrake-js', 'bin', 'HandbrakeCLI')
I also had to set asar: false
in the build config. It's a hack but it works.
Hey, just seeing this. Were you able to get it going? @birchb
Addemdum:
Editing lib/config.js
enables handbrake-js to work under a PROD build of electron without interfering with other applications. I'm an amateur, so YMMV.
switch (process.platform) {
case 'darwin':
if (process.env.PROD && process.env.MODE === 'electron') {
HandbrakeCLIPath = path.join(__dirname, '..', 'app', 'node_modules', 'handbrake-js', 'bin', 'HandbrakeCLI')
} else {
HandbrakeCLIPath = path.join(__dirname, '..', 'bin', 'HandbrakeCLI')
}
break
case 'win32':
HandbrakeCLIPath = path.join(__dirname, '..', 'bin', 'HandbrakeCLI.exe')
break
case 'linux':
HandbrakeCLIPath = 'HandBrakeCLI'
break
}