Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Electron build path issue #54

Open
birchb opened this issue Apr 16, 2020 · 6 comments
Open

Electron build path issue #54

birchb opened this issue Apr 16, 2020 · 6 comments

Comments

@birchb
Copy link

birchb commented Apr 16, 2020

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!

@birchb
Copy link
Author

birchb commented Apr 16, 2020

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?

@75lb
Copy link
Owner

75lb commented Apr 17, 2020

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?

@birchb
Copy link
Author

birchb commented Apr 17, 2020

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.

@birchb
Copy link
Author

birchb commented Apr 19, 2020

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.

@jpangelle
Copy link

Hey, just seeing this. Were you able to get it going? @birchb

@birchb
Copy link
Author

birchb commented Apr 21, 2020

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
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants