transitive-bullshit / ffmpeg-concat

Concats a list of videos together using ffmpeg with sexy OpenGL transitions.
865 stars 113 forks source link

Docker container fails to run `ffmpeg-concat` #77

Closed georgy95 closed 4 years ago

georgy95 commented 4 years ago

When I test locally - works fine, however fails to work inside a Docker container.

Dockerfile

FROM nikolaik/python-nodejs:python3.8-nodejs14

RUN apt-get -y update && \
    apt-get -y upgrade && \
    apt-get install -y ffmpeg && \
    npm install -g ffmpeg-concat --unsafe-perm 

The stack trace I get when running ffmpeg-concat file1.mp4 file2.mp4 -o out.mp4 is:

Failed to create OpenGL context. Please see https://github.com/stackgl/headless-gl#supported-platforms-and-nodejs-versions for compatibility.
ffmpeg-concat: 2807.206ms
concat error Error: failed to create OpenGL context
    at module.exports (/usr/lib/node_modules/ffmpeg-concat/lib/context.js:24:11)
    at module.exports (/usr/lib/node_modules/ffmpeg-concat/lib/render-frames.js:19:21)
    at module.exports (/usr/lib/node_modules/ffmpeg-concat/lib/index.js:57:32)
    at async module.exports (/usr/lib/node_modules/ffmpeg-concat/lib/cli.js:38:5)
(node:117) UnhandledPromiseRejectionWarning: Error: failed to create OpenGL context
    at module.exports (/usr/lib/node_modules/ffmpeg-concat/lib/context.js:24:11)
    at module.exports (/usr/lib/node_modules/ffmpeg-concat/lib/render-frames.js:19:21)
    at module.exports (/usr/lib/node_modules/ffmpeg-concat/lib/index.js:57:32)
    at async module.exports (/usr/lib/node_modules/ffmpeg-concat/lib/cli.js:38:5)
(node:117) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:117) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
transitive-bullshit commented 4 years ago

Follow the link that the error gives.

This question has been asked several times on here before; you need to use xvfb to create an OpenGL context in environments where you don't have GPU access.

DanisHack commented 4 years ago

@skiler07 Follow this link: https://github.com/stackgl/headless-gl#supported-platforms-and-nodejs-versions to understand the issue.

Essentially, add this to your dockerfile to achieve whats said in the link:

run apt-get install -y build-essential libxi-dev libglu1-mesa-dev libglew-dev pkg-config
RUN apt-get install -y dumb-init xvfb
RUN chmod 0777 /usr/bin/dumb-init

ENTRYPOINT ["/usr/bin/dumb-init", "--", "xvfb-run", "-s", "-ac -screen 0 1280x1024x24"]
CMD ["node"]
georgy95 commented 4 years ago

Thank you

sunjianan9900 commented 3 years ago

apt-get install -y dumb-init xvfb

Ubuntu 16.04.5 Unable to locate package dumb-init

DanisHack commented 3 years ago

Look here: https://github.com/Yelp/dumb-init

sunjianan9900 commented 3 years ago

Look here: https://github.com/Yelp/dumb-init

thanks~