75lb / handbrake-js

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

Cannot install HandbrakeCLI in a Docker container #75

Open pooshonbanerjee opened 1 year ago

pooshonbanerjee commented 1 year ago

Preface

Dockerfile

# Use an official Node.js runtime as a parent image
FROM ubuntu

# Install Handbrake-CLI

RUN apt-get update && \
    apt-get install -y software-properties-common && \
    add-apt-repository --yes ppa:stebbins/handbrake-releases && \
    apt-get install -y handbrake-cli

# Set the working directory to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app

# Install any needed packages specified in package.json
RUN npm install

# Make port 3000 available to the world outside this container
EXPOSE 3000

# Define environment variable
# ENV NODE_ENV=production

# Run the app when the container launches
CMD ["npm", "start"]

Errors

pooshonbanerjee commented 1 year ago

I tried another method to install Handbrake manually, installed fine but the NPM module cannot find HandbrakeCLI. I tried first by installing HandBrakeCLI only using RUN flatpak install /app/cli/HandBrakeCLI-1.6.1-x86_64.flatpak -y. You can see the commented line in Dockefile.

Then when that didn't work, I tried to install full HandBrake, got the same error.

Dockerfile

# Use an official Node.js runtime as a parent image
FROM ubuntu:latest

# Set the working directory to /app
WORKDIR /app

COPY cli /app/cli

RUN apt-get update && \
    apt-get install -y flatpak && \
    flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

# RUN flatpak install /app/cli/HandBrakeCLI-1.6.1-x86_64.flatpak -y
RUN flatpak install /app/cli/HandBrake-1.6.1-x86_64.flatpak -y

# RUN Handbrake --version
# Copy the current directory contents into the container at /app
COPY . /app

# Install node

RUN apt-get update && \
    apt-get install -y curl && \
    curl -sL https://deb.nodesource.com/setup_18.x | bash - && \
    apt-get install -y nodejs

# Install any needed packages specified in package.json
RUN npm install

# Make port 3000 available to the world outside this container
EXPOSE 3000

# Define environment variable
# ENV NODE_ENV=production

# Run the app when the container launches
CMD ["npm", "start"]

Error

2023-06-23 13:29:25 Server started on port 3000
2023-06-23 13:29:49 AI for business elevator pitch_Yumi Kim.mp4
2023-06-23 13:29:49 base64Name:  QUkgZm9yIGJ1c2luZXNzIGVsZXZhdG9yIHBpdGNoX1l1bWkgS2ltLm1wNA==
2023-06-23 13:29:49 {
2023-06-23 13:29:49   path: 'uploads/QUkgZm9yIGJ1c2luZXNzIGVsZXZhdG9yIHBpdGNoX1l1bWkgS2ltLm1wNA==/AI for business elevator pitch_Yumi Kim.mp4'
2023-06-23 13:29:49 }
2023-06-23 13:29:49 error:  HandbrakeCLINotFound: HandbrakeCLI application not found: HandBrakeCLI. Linux users must install HandbrakeCLI manually, please see https://handbrake.fr/downloads.php.
2023-06-23 13:29:49     at Handbrake._run (/app/node_modules/handbrake-js/dist/index.cjs:208:15)
2023-06-23 13:29:49     at /app/node_modules/handbrake-js/dist/index.cjs:599:17
2023-06-23 13:29:49     at process.processTicksAndRejections (node:internal/process/task_queues:77:11) {
2023-06-23 13:29:49   errno: -2,
2023-06-23 13:29:49   HandbrakeCLIPath: 'HandBrakeCLI',
2023-06-23 13:29:49   spawnmessage: 'spawn HandBrakeCLI ENOENT',
2023-06-23 13:29:49   output: '',
2023-06-23 13:29:49   options: {
2023-06-23 13:29:49     input: 'uploads/QUkgZm9yIGJ1c2luZXNzIGVsZXZhdG9yIHBpdGNoX1l1bWkgS2ltLm1wNA==/AI for business elevator pitch_Yumi Kim.mp4',
2023-06-23 13:29:49     output: 'uploads/QUkgZm9yIGJ1c2luZXNzIGVsZXZhdG9yIHBpdGNoX1l1bWkgS2ltLm1wNA==/AI for business elevator pitch_Yumi Kim_HB.mp4',
2023-06-23 13:29:49     preset: 'Very Fast 1080p30'
2023-06-23 13:29:49   }
2023-06-23 13:29:49 }
2023-06-23 13:29:49 encoding complete
2023-06-23 13:29:49 File deleted!
pooshonbanerjee commented 1 year ago

Then I went into my docker terminal, and tried to install manually.

Install log

# flatpak install /app/cli/HandBrakeCLI-1.6.1-x86_64.flatpak 
Required runtime for fr.handbrake.HandBrakeCLI/x86_64/stable (runtime/org.freedesktop.Platform/x86_64/21.08) found in remote flathub
Do you want to install it? [Y/n]: Y

fr.handbrake.HandBrakeCLI permissions:
    dri   file access [1]

    [1] host

        ID                                         Arch          Branch        Op        Remote                     Download
        ID                                         Arch          Branch        Op        Remote                     Download
 1. [?] org.freedesktop.Platform.GL.default        x86_64        21.08         i         flathub                    129.5?MB / 129.8?MB
 2. [?] org.freedesktop.Platform.Locale            x86_64        21.08         i         flathub                     47.0?MB / 326.7?MB
        ID                                         Arch          Branch        Op        Remote                     Download
 1. [?] org.freedesktop.Platform.GL.default        x86_64        21.08         i         flathub                    129.5?MB / 129.8?MB
 2. [?] org.freedesktop.Platform.Locale            x86_64        21.08         i         flathub                     47.0?MB / 326.7?MB
 3. [?] org.freedesktop.Platform.openh264          x86_64        2.0           i         flathub                      1.5?MB / 1.5?MB
 4. [?] org.freedesktop.Platform                   x86_64        21.08         i         flathub                    185.9?MB / 201.6?MB
 5. [?] fr.handbrake.HandBrakeCLI                  x86_64        stable        i         handbrakecli-origin        0 bytes

Warning: While trying to apply extra data: apply_extra script failed, exit status 256
Installation complete.

But same error

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

FlawaCLV commented 6 months ago

@pooshonbanerjee have you found a solution/workaround?

pooshonbanerjee commented 6 months ago

No I didn't. Wasted a lot of time first with Handbrake then with ffmpeg but couldn't install inside a docker container.

Regards

On Tue, 21 May, 2024, 6:53 pm Hugo Pozzoli, @.***> wrote:

@pooshonbanerjee https://github.com/pooshonbanerjee have you found a solution/workaround?

— Reply to this email directly, view it on GitHub https://github.com/75lb/handbrake-js/issues/75#issuecomment-2122629862, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJTJE6E45QP4HH6IT36VO5DZDNDFFAVCNFSM6AAAAAAZOQ6VBSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRSGYZDSOBWGI . You are receiving this because you were mentioned.Message ID: @.***>

FlawaCLV commented 6 months ago

@pooshonbanerjee I actually made it work using this DockerFile and Fluent ffmpeg-API for node.js

FROM node:18.12-alpine

RUN apk add ffmpeg

WORKDIR /usr/src/api

COPY package*.json ./
RUN npm install --legacy-peer-deps

COPY . .
RUN npm run build

ENV ENV production
ENV PORT 8080
ENV HOST 0.0.0.0

EXPOSE $PORT

CMD npm start
pooshonbanerjee commented 6 months ago

Cool, I'll check it out.

On Wed, 22 May, 2024, 6:09 pm Hugo Pozzoli, @.***> wrote:

@pooshonbanerjee https://github.com/pooshonbanerjee I actually made it work using this DockerFile and Fluent ffmpeg-API for node.js https://www.npmjs.com/package/fluent-ffmpeg

FROM node:18.12-alpine RUN apk add ffmpeg WORKDIR /usr/src/api COPY package*.json ./RUN npm install --legacy-peer-deps COPY . .RUN npm run build ENV ENV productionENV PORT 8080ENV HOST 0.0.0.0 EXPOSE $PORT CMD npm start

— Reply to this email directly, view it on GitHub https://github.com/75lb/handbrake-js/issues/75#issuecomment-2124691665, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJTJE6BB5LJDG6NV44SFNB3ZDSGX7AVCNFSM6AAAAAAZOQ6VBSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRUGY4TCNRWGU . You are receiving this because you were mentioned.Message ID: @.***>

75lb commented 4 months ago

Regarding the HandbrakeCLI not being found, you can set a custom path via the API or with an environment variable.