Comments (10)
This is how I managed to have both Python 3.6 and FFmpeg in one image:
FROM jrottenberg/ffmpeg:4.0-scratch AS ffmpeg
FROM python:3.6
COPY --from=ffmpeg / /
from ffmpeg.
This is how I got it to work. Leaving it here since this is the only result I found when googling for multistage builds with ffmpeg.
Complete Dockerfile
Resulted Docker file will also work on arm arch, e.g. on Raspberry Pi or Apple Silicon, considering base image supports it.
FROM debian:buster-slim as base # replace with your actual base image, e.g. `python-slim`
FROM base as base-installer
RUN apt update
FROM base-installer as ffmpeg-installer
RUN apt install --no-install-recommends -y ffmpeg
FROM base as runtime
COPY --from=ffmpeg-installer /usr/bin/ffmpeg /usr/bin/ffmpeg
COPY --from=ffmpeg-installer /usr/lib/*-linux-gnu/* /usr/lib/
COPY --from=ffmpeg-installer /lib/*-linux-gnu/* /usr/lib/
How to get ffmpeg for any image
- Define stage where you have working ffmpeg (in this example I install it with apt, but you can use ffmpeg as base image):
FROM debian:buster-slim as base # replace with your actual base image, e.g. `python-slim` FROM base as base-installer RUN apt update FROM base-installer as ffmpeg-installer RUN apt install --no-install-recommends -y ffmpeg
- Verify that at this stage ffmpeg is indeed working:
docker build --target ffmpeg-installer . -t ffmpeg docker run -it ffmpeg ffmpeg
- Get path where ffmpeg is installed:
docker run -it ffmpeg which ffmpeg # /usr/bin/ffmpeg
- Add ffmpeg binary to your runtime stage:
FROM base as runtime COPY --from=ffmpeg-installer /usr/bin/ffmpeg /usr/bin/ffmpeg
- Run ffmpeg from your runtime target and observe the error (or success!):
docker build --target runtime -t runtime . docker run -it runtime ffmpeg # ffmpeg: error while loading shared libraries: libavdevice.so.58: cannot open shared object file: No such file or directory
- Find location of shared library in ffmpeg-installer target:
docker run -it ffmpeg find / -name libavdevice.so.58 # /usr/lib/aarch64-linux-gnu/libavdevice.so.58
- Copy the lib location to your runtime stage (note * instead of arch name, this will work with multiarch builds):
FROM base as runtime COPY --from=ffmpeg-installer /usr/bin/ffmpeg /usr/bin/ffmpeg COPY --from=builder-base /usr/lib/*-linux-gnu/* /usr/lib/
- Return to 5. untill you don't observe errors anymore (took 1 repeat for me).
from ffmpeg.
To add to this, we're using the following in our production Dockerfiles:
ENV LD_LIBRARY_PATH=/usr/local/lib
COPY --from=jrottenberg/ffmpeg /usr/local /usr/local/
Works well 👍
from ffmpeg.
it exists now : https://github.com/videotools/ffmpeg-build
from ffmpeg.
To add to this, we're using the following in our production Dockerfiles:
ENV LD_LIBRARY_PATH=/usr/local/lib COPY --from=jrottenberg/ffmpeg /usr/local /usr/local/
Works well 👍
With ubuntu20.04 and ffmpeg 20.04-ubuntu it is no longer working. I get the following error:
ffmpeg: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory
It is working with:
ENV LD_LIBRARY_PATH=/usr/local/lib
COPY --from=jrottenberg/ffmpeg / /
from ffmpeg.
Copying the entire image into your destination can sometimes cause problems, this also works:
ENV LD_LIBRARY_PATH=/usr/local/lib
COPY --from=ffmpeg /usr/local /usr/local
COPY --from=ffmpeg /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu
from ffmpeg.
I also experienced issues with this... I hoped it would work as expected
from ffmpeg.
I could have sworn I found a more straightforward method, but a while back I had some success with using LD_LIBRARY_PATH
to copy over all the files to the new container and link them back up. I'll try to dig up the references when I have some time, but maybe this pointer will be enough to get you started down the right path...
from ffmpeg.
I tested every available distrib for 4.0 and 3.4... but I didn't managed to get the binary working in the final image
-
using
ubuntu
based image I had the same OP error message -
using others based image (including
scratch
), my binary didn't want to execute at all (something likeffmpeg command was not found
) even afterchmod a+rx
the binary, etc.
I didn't try @vagari solution thought
what I did after losing a lot of time was simply installing ffmpeg in my final image 😞:
FROM node:8.11.2-stretch
RUN apt-get update && apt-get install -y libav-tools ffmpeg
from ffmpeg.
I think it'd be nice to have intermediate images for development, I shameless did (copy & change) an ffmpeg-devel image and I already posted to dockerhub.
With this image you can create, test, compile and run your ffmpeg programs:
clean:
@rm -rf ./build/*
make_hello: clean
docker run --rm -it -v `pwd`:/files leandromoreira/ffmpeg-devel \
gcc -L/opt/ffmpeg/lib -I/opt/ffmpeg/include/ /files/MYCODE.c \
-lavcodec -lavformat -lavfilter -lavdevice -lswresample -lswscale -lavutil \
-o /files/build/MYPROGRAM
run_hello: make_hello
docker run --rm -it -v `pwd`:/files leandromoreira/ffmpeg-devel /files/build/MYPROGRAM /files/small_bunny_1080p_60fps.mp4
from ffmpeg.
Related Issues (20)
- Question: Is there / can there be a build for linux with video toolbox included? HOT 2
- "latest" is which variant? HOT 1
- ERROR: cuda requested, but not all dependencies are satisfied: ffnvcodec HOT 2
- ERROR: libvmaf >= 2.0.0 not found using pkg-config HOT 1
- Unknown encoder 'h264_qsv' when using -vcodec h264_qsv HOT 3
- ffmpeg with libxml2 HOT 1
- Missing image 6.0-nvidia HOT 1
- Add user to conatiner, so that ffmpeg does not run as root
- Support for Cuda v12
- amr wb support HOT 1
- FFmpeg Release 6.1 "Heaviside" Support HOT 1
- ffmpeg:4.4-nvidia2204,ffmpeg:5.1.2-nvidia2004,ffmpeg:6.1.1-nvidia2204 - install imagemagick error HOT 2
- FFmpeg 7.0 "Dijkstra" Support HOT 1
- amr-wb support ?
- enable libplacebo
- 7.0.1-nvidia2204: no such filter scale_cuda HOT 3
- CUDA_ERROR_COMPAT_NOT_SUPPORTED_ON_DEVICE HOT 1
- av1_nvenc missing HOT 1
- incorrect version HOT 3
- Was fine, now Errors: opening decoder and opening output files HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ffmpeg.