Mup - How to make Handbreak-js works?

I need handbrake-js to convert video files into mp4 format.
I have tested this script on Ubuntu 20 and it works fine !

const hbjs = require('handbrake-js')

hbjs.spawn({ input: 'test.mkv', output: 'test.mp4' })
  .on('error', err => {
    // invalid user input, no video found etc
  })
  .on('progress', progress => {
    console.log(
      'Percent complete: %s, ETA: %s',
      progress.percentComplete,
      progress.eta
    )
  })

However, It throw errors when running in a docker .

[server]2020-06-12T07:23:59.567397648Z   encodeError: HandbrakeCLINotFound: HandbrakeCLI application not found: HandBrakeCLI. Linux users must install HandbrakeCLI manually, please see https://handbrake.fr/downloads.php.
[server]2020-06-12T07:23:59.567514784Z       at Handbrake._run (/built_app/programs/server/npm/node_modules/handbrake-js/lib/Handbrake.js:64:15)
[server]2020-06-12T07:23:59.567609765Z       at /built_app/programs/server/npm/node_modules/handbrake-js/index.js:40:17
[server]2020-06-12T07:23:59.567671237Z       at processTicksAndRejections (internal/process/task_queues.js:75:11) {
[server]2020-06-12T07:23:59.567707791Z     errno: 'ENOENT',
[server]2020-06-12T07:23:59.567766749Z     HandbrakeCLIPath: 'HandBrakeCLI',
[server]2020-06-12T07:23:59.567788619Z     name: 'HandbrakeCLINotFound',
[server]2020-06-12T07:23:59.567807380Z     message: 'HandbrakeCLI application not found: HandBrakeCLI. Linux users must install HandbrakeCLI manually, please see https://handbrake.fr/downloads.php.',
[server]2020-06-12T07:23:59.567878284Z     spawnmessage: 'spawn HandBrakeCLI ENOENT',
[server]2020-06-12T07:23:59.567899599Z     output: '',
[server]2020-06-12T07:23:59.567918797Z     options: {
[server]2020-06-12T07:23:59.567989688Z       input: '/files/tmp_download/test.mkv',
[server]2020-06-12T07:23:59.568011208Z       output: '/files/tmp_download/test.mp4',
[server]2020-06-12T07:23:59.568079151Z       subtitle: '1',
[server]2020-06-12T07:23:59.568102587Z       'subtitle-burned': 1,
[server]2020-06-12T07:23:59.568161007Z       preset: 'Fast 720p30'
[server]2020-06-12T07:23:59.569792390Z     }
[server]2020-06-12T07:23:59.570486160Z   }

I know this is more related to Docker but please tell me what to do if you know it

encodeError: HandbrakeCLINotFound: HandbrakeCLI application not found: HandBrakeCLI. Linux users must install HandbrakeCLI manually, please see https://handbrake.fr/downloads.php

Looks like you need to install the handbrake CLI which is a bit more complicated with MUP, since it will need to be installed in the container with the app.

Looking at the handbrake download page, it looks like it’s available through apt so you can tell mup/docker to add it to the container by adding a config in mup.js:

module.exports = {
  app: {
    name: 'app',
    path: '../',
    servers: { one: {} },
    docker: {
      buildInstructions: [
        'RUN apt-get update && apt-get install -y handbrake-cli'
      ]
    }
  }
};

http://meteor-up.com/docs.html#customize-docker-image

3 Likes

Thank you so much but this isn’t working greatly.
Idk if some libraries’ missing?
As the quality of videos drops so much compare to when it’s converted outside of the Docker,
Also the options not working, like the subtitles not get embedded while Direct Node.js script works perfectly

Can you please tell me how to get this Image merged with the base Mup Image: abernix/meteord:node-12.14.0-base
https://hub.docker.com/r/jlesage/handbrake/
I don’t have a Docker account also it looks so hard to build a customized image.

It could be a version difference, the docs for handbrake-js say to add a custom APT source repository for handbrake before installing, so I would try that first.

  buildInstructions: [
    'RUN add-apt-repository --yes ppa:stebbins/handbrake-releases',
    'RUN apt-get update -qq',
    'RUN apt-get install -qq handbrake-cli'
  ]

Otherwise I don’t know why the quality would be different, you might just need to test passing different encoding options to hbjs.spawn


It’s very unlikely that this would happen, as very few mup users need handbrake, and there’s already an easy way to customise the final image

Thank you again !

This is the build options : `

  buildInstructions: [
            // 'RUN apt-get update',
            // 'RUN apt-get install software-properties-common -y',
            // 'RUN apt-get update && \
            // apt-get install -y software-properties-common && \
            // rm -rf /var/lib/apt/lists/*',
            // 'RUN apt-get update',
            // 'RUN add-apt-repository -y ppa:stebbins/handbrake-releases',
            'RUN apt-get update -qq',
            'RUN apt-get install -y handbrake-cli',
            // 'RUN apt-get update && apt-get install -y handbrake-cli'
        ]`

The above is part of my now configuration of mup,And this shows bad quality and no subtitle which is opposite to the direct node.js script run.

I wanted this line which i have it installed fine on the Ubuntu system but it throws errors in Docker’s build for not founding repository RUN add-apt-repository -y ppa:stebbins/handbrake-releases