75lb / handbrake-js

Video encoding / transcoding / converting for node.js
Other
550 stars 69 forks source link

Handbrake-js on Heroku doesn't work. #60

Closed alexakuna closed 3 years ago

alexakuna commented 3 years ago

Problem description:

Good afternoon. There is a problem. Using the npm install handbrake-js --save command, I installed handbrake-js as a library, and after some tweaking, handbrake-js started to do the job perfectly. And here's the problem. On the local computer everything works well, videos are decoded, etc. BUT (!) When I upload my application to Heroku, handbrake-js stops working.

HandBrake version:

5.0.2

Operating system and version:

macOS 10.15 Catalina

My application uses node js

Error message text:

Here is what information Heroku gives when deploy an application on Heroku:

Linux users handbrake-cli must be installed separately as the root user.

Ubuntu users can do this using the following commands: add-apt-repository --yes ppa: stebbins / handbrake-releases apt-get update -qq apt-get install -qq handbrake-cli

HandBrake Activity Log:

Here's what happens when you try to decode:


2020-12-02T18:34:14.124945+00:00 app[web.1]: Error: Command failed: "HandBrakeCLI" --input "public/images/02122020-123404_338-test.mov" --output "public/images/02122020-123404_338-test.mp4" --preset "Gmail Medium 5 Minutes 480p30"
2020-12-02T18:34:14.124948+00:00 app[web.1]: /bin/sh: 1: HandBrakeCLI: not found
2020-12-02T18:34:14.124948+00:00 app[web.1]: 
2020-12-02T18:34:14.124949+00:00 app[web.1]: at ChildProcess.exithandler (child_process.js:308:12)
2020-12-02T18:34:14.124950+00:00 app[web.1]: at ChildProcess.emit (events.js:314:20)
2020-12-02T18:34:14.124950+00:00 app[web.1]: at maybeClose (internal/child_process.js:1022:16)
2020-12-02T18:34:14.124951+00:00 app[web.1]: at Socket.<anonymous> (internal/child_process.js:444:11)
2020-12-02T18:34:14.124951+00:00 app[web.1]: at Socket.emit (events.js:314:20)
2020-12-02T18:34:14.124951+00:00 app[web.1]: at Pipe.<anonymous> (net.js:675:12) {
2020-12-02T18:34:14.124952+00:00 app[web.1]: killed: false,
2020-12-02T18:34:14.124952+00:00 app[web.1]: code: 127,
2020-12-02T18:34:14.124953+00:00 app[web.1]: signal: null,
2020-12-02T18:34:14.124954+00:00 app[web.1]: cmd: '"HandBrakeCLI" --input "public/images/02122020-123404_338-test.mov" --output "public/images/02122020-123404_338-test.mp4" --preset "Gmail Medium 5 Minutes 480p30"'
2020-12-02T18:34:14.124954+00:00 app[web.1]: }

Here is the code used to set up and start decoding:

const options = {
        input: req.files.video ? req.files.video[0].path : '',
        output: newPathVideo,
        preset: 'Gmail Medium 5 Minutes 480p30',
    }
    async function startEncoding () {
        console.log('Start decoding video')
        const result = await hbjs.run(options)
        console.log(`${result.stdout}End decoding video`)
    }
    await startEncoding()

I ask for help. How to solve this problem?

75lb commented 3 years ago

Handbrake-js is a javascript library which depends on HandbrakeCli being installed on the system. This error message is telling you that, on a Linux OS, HandbrakeCli must be installed manually as the root user using the follow commands.

add-apt-repository --yes ppa: stebbins / handbrake-releases
apt-get update -qq
apt-get install -qq handbrake-cli

You must run these commands as root yourself, npm install is not able to install linux packages as the root user.

alexakuna commented 3 years ago

Can I install handbrake-cli remotely?

75lb commented 3 years ago

I don't know - you need to ask Heroku.. i found this:

https://help.heroku.com/IYRYW6VB/how-do-i-install-additional-software-packages-that-my-application-requires