DEV Community

Cover image for Using a newer version of FFmpeg with Docker.
Ethan
Ethan

Posted on

Using a newer version of FFmpeg with Docker.

Introduction

Hello, I needed to use FFmpeg in a node application, however the problem was the default FFmpeg that can be installed with the node image was too old and didn't support what I was trying to do.

There were two ways to handle this either compile FFmpeg from source, which would take a while and I really didn't want to have a long Dockerfile, not to mention the cleanup afterwards.

So I decided to copy the FFmpeg bin from the "jrottenberg/ffmpeg:4.4-alpine" into the Nodejs image. Reason being it's simpler.


Using FFmpeg 4.4 with the node image

To use the FFmpeg bin with the node image I changed the head of my Dockerfile like so:

FROM jrottenberg/ffmpeg:4.4-alpine AS FFmpeg
FROM node:16-alpine

COPY --from=FFmpeg / /
Enter fullscreen mode Exit fullscreen mode

With this I was able to use FFmpeg 4.4 with the Node 16 image.
I also learned something new about Docker.

Hopefully this will help me in future projects, and hopefully be of use to you.

Top comments (2)

Collapse
 
unmanner profile image
Alexey Kryazhev

seems like copying just /usr/local should be enough:
github.com/jrottenberg/ffmpeg/blob...

Collapse
 
ethand91 profile image
Ethan

I see. Thanks for sharing :)