Last active
May 31, 2022 17:49
-
-
Save hhsprings/e491ba4983cf6bfafb9dd7650302b893 to your computer and use it in GitHub Desktop.
This is a Dockerfile configured to build FFMPEG on its own, independent of apt-get. (This is an original version of https://github.com/hhsprings/docker-ffmpeg-yours)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
ARG _BUILDPACKDEPS_TAG=22.04 | |
FROM hhsprings/buildpack-deps-plus:latest-from-${_BUILDPACKDEPS_TAG} | |
ARG _FFMPEG_VERSION=4.4.2 | |
ARG _OPENCV_VERSION=3.4.15 | |
ARG _PREFIX=/usr/local | |
ARG _FFMPEG_EXTRA_VERSION_SUFFIX=hhsprings0.1 | |
ARG __APT_Y="-yq --no-install-recommends" | |
# | |
WORKDIR /tmp/build | |
# ---------------------------------------------------------- | |
# | |
# ffmpeg and opencv are interdependent with each other. | |
# Therefore, install the small ffmpeg in advance. | |
# | |
# ---------------------------------------------------------- | |
# download specific released version, not current snapshot via git. | |
ADD https://ffmpeg.org/releases/ffmpeg-${_FFMPEG_VERSION}.tar.xz . | |
RUN tar Jxvf ffmpeg-${_FFMPEG_VERSION}.tar.xz | |
ENV FFMPEG_SRCDIR=/tmp/build/ffmpeg-${_FFMPEG_VERSION} | |
WORKDIR ${FFMPEG_SRCDIR} | |
# | |
ENV LD_LIBRARY_PATH=${_PREFIX}/lib64:${_PREFIX}/lib:${LD_LIBRARY_PATH:-/usr/lib64:/usr/lib} | |
ENV PKG_CONFIG_PATH=${_PREFIX}/lib64/pkgconfig:${_PREFIX}/lib/pkgconfig:${PKG_CONFIG_PATH:-/usr/lib64/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig} | |
# | |
RUN sh configure \ | |
--extra-version=${_FFMPEG_EXTRA_VERSION_SUFFIX}-min \ | |
--disable-static \ | |
--enable-shared \ | |
--enable-pthreads \ | |
\ | |
--disable-ffplay \ | |
--disable-doc \ | |
--disable-htmlpages \ | |
--disable-manpages \ | |
--disable-podpages \ | |
--disable-txtpages | |
RUN make -j $(grep "^core id" /proc/cpuinfo | wc -l) | |
RUN make install | |
# ---------------------------------------------------------- | |
# | |
# build opencv from source, because libopencv-dev of apt | |
# is broken or at least CRAZY in my humble opinion. | |
# | |
# ---------------------------------------------------------- | |
# opencv from source | |
RUN apt-get install ${__APT_Y} libgtk2.0-dev | |
WORKDIR /tmp/build | |
# download specific released version, not current snapshot via git. | |
ADD https://github.com/opencv/opencv/archive/refs/tags/${_OPENCV_VERSION}.tar.gz . | |
RUN tar zxvf ${_OPENCV_VERSION}.tar.gz | |
ENV OPENCV_SRCDIR=/tmp/build/opencv-${_OPENCV_VERSION} | |
WORKDIR ${OPENCV_SRCDIR} | |
RUN mkdir build | |
WORKDIR ${OPENCV_SRCDIR}/build | |
# "-D OPENCV_GENERATE_PKGCONFIG=ON" has no effect if opencv 3.x, this is only for opencv 4+. | |
RUN cmake -D CMAKE_BUILD_TYPE=RELEASE -D OPENCV_GENERATE_PKGCONFIG=ON -D CMAKE_INSTALL_PREFIX=${_PREFIX} .. | |
RUN make -j $(grep "^core id" /proc/cpuinfo | wc -l) | |
RUN make install | |
# ---------------------------------------------------------- | |
# | |
# prepare dependancies which we can get with apt-get | |
# for full-build of ffmpeg | |
# | |
# ---------------------------------------------------------- | |
# | |
RUN apt-get install ${__APT_Y} libssh-dev | |
RUN apt-get install ${__APT_Y} libgnutls28-dev | |
RUN apt-get install ${__APT_Y} nvidia-opencl-dev | |
# | |
RUN apt-get install ${__APT_Y} libsrt-gnutls-dev | |
RUN apt-get install ${__APT_Y} libass-dev | |
RUN apt-get install ${__APT_Y} libfribidi-dev | |
RUN apt-get install ${__APT_Y} libfontconfig-dev | |
RUN apt-get install ${__APT_Y} libfreetype-dev | |
# | |
RUN apt-get install ${__APT_Y} libx264-dev | |
RUN apt-get install ${__APT_Y} libx265-dev | |
RUN apt-get install ${__APT_Y} libvpx-dev | |
RUN apt-get install ${__APT_Y} libaom-dev | |
RUN apt-get install ${__APT_Y} libmp3lame-dev | |
RUN apt-get install ${__APT_Y} libtwolame-dev | |
RUN apt-get install ${__APT_Y} libopus-dev | |
RUN apt-get install ${__APT_Y} libvorbis-dev | |
# | |
RUN apt-get install ${__APT_Y} libbs2b-dev | |
RUN apt-get install ${__APT_Y} frei0r-plugins-dev | |
RUN apt-get install ${__APT_Y} libtesseract-dev libleptonica-dev tesseract-ocr-eng | |
RUN apt-get install ${__APT_Y} flite1-dev | |
RUN apt-get install ${__APT_Y} libchromaprint-dev | |
RUN apt-get install ${__APT_Y} librubberband-dev | |
RUN apt-get install ${__APT_Y} libzmq5-dev | |
RUN apt-get install ${__APT_Y} libzimg-dev | |
RUN apt-get install ${__APT_Y} libsoxr-dev | |
RUN apt-get install ${__APT_Y} libtheora-dev | |
RUN apt-get install ${__APT_Y} libmysofa-dev | |
RUN apt-get install ${__APT_Y} libshine-dev | |
RUN apt-get install ${__APT_Y} ladspa-sdk | |
RUN apt-get install ${__APT_Y} libspeex-dev | |
RUN apt-get install ${__APT_Y} libgme-dev | |
RUN apt-get install ${__APT_Y} libgsm1-dev | |
RUN apt-get install ${__APT_Y} libopenmpt-dev | |
RUN apt-get install ${__APT_Y} libmodplug-dev | |
RUN apt-get install ${__APT_Y} libopencore-amrwb-dev | |
RUN apt-get install ${__APT_Y} libopencore-amrnb-dev | |
RUN apt-get install ${__APT_Y} libvo-amrwbenc-dev | |
RUN apt-get install ${__APT_Y} libvulkan-dev | |
RUN apt-get install ${__APT_Y} glslang-dev | |
RUN apt-get install ${__APT_Y} libmfx-dev | |
RUN apt-get install ${__APT_Y} libvidstab-dev | |
RUN apt-get install ${__APT_Y} libxvidcore-dev | |
RUN apt-get install ${__APT_Y} libsvtav1enc-dev | |
RUN apt-get install ${__APT_Y} libzvbi-dev | |
RUN apt-get install ${__APT_Y} libdav1d-dev | |
RUN apt-get install ${__APT_Y} libcaca-dev | |
RUN apt-get install ${__APT_Y} libbluray-dev | |
RUN apt-get install ${__APT_Y} libsnappy-dev | |
RUN apt-get install ${__APT_Y} libgmp-dev | |
RUN apt-get install ${__APT_Y} libpulse-dev | |
RUN apt-get install ${__APT_Y} libpocketsphinx-dev | |
RUN apt-get install ${__APT_Y} pocketsphinx-en-us | |
RUN apt-get install ${__APT_Y} libdrm-dev | |
RUN apt-get install ${__APT_Y} librtmp-dev | |
RUN apt-get install ${__APT_Y} libxavs2-dev | |
RUN apt-get install ${__APT_Y} liblilv-dev | |
# ---------------------------------------------------------- | |
# | |
# finally, full-build of ffmpeg. | |
# | |
# ---------------------------------------------------------- | |
WORKDIR ${FFMPEG_SRCDIR} | |
RUN sh `head -1 ffbuild/config.log | sed 's@^# @@' | \ | |
sed "s@--extra-version=${_FFMPEG_EXTRA_VERSION_SUFFIX}-min@--extra-version=${_FFMPEG_EXTRA_VERSION_SUFFIX}@"` \ | |
--enable-gpl \ | |
--enable-version3 \ | |
\ | |
--enable-lzma --enable-zlib --enable-iconv \ | |
\ | |
--enable-libsrt \ | |
--enable-libass \ | |
--enable-libfribidi \ | |
--enable-libfontconfig \ | |
--enable-libfreetype \ | |
--enable-libxml2 \ | |
\ | |
--enable-libssh \ | |
--enable-gnutls \ | |
\ | |
--enable-libx264 \ | |
--enable-libx265 \ | |
--enable-libvpx \ | |
--enable-libwebp \ | |
--enable-libaom \ | |
--enable-libmp3lame \ | |
--enable-libtwolame \ | |
--enable-libopus \ | |
--enable-libvorbis \ | |
\ | |
--enable-libbs2b \ | |
--enable-frei0r \ | |
--enable-libflite \ | |
--enable-libtesseract \ | |
--enable-librubberband \ | |
--enable-chromaprint \ | |
--enable-libzmq \ | |
--enable-libzimg \ | |
--enable-libsoxr \ | |
--enable-libtheora \ | |
--enable-libmysofa \ | |
--enable-libshine \ | |
--enable-ladspa \ | |
--enable-libspeex \ | |
--enable-libopenjpeg \ | |
--enable-libgme \ | |
--enable-libgsm \ | |
--enable-libopenmpt \ | |
--enable-libmodplug \ | |
--enable-libopencore-amrwb \ | |
--enable-libopencore-amrnb \ | |
--enable-libvo-amrwbenc \ | |
--enable-vulkan \ | |
--enable-libglslang \ | |
--enable-libmfx \ | |
--enable-libvidstab \ | |
--enable-libxvid \ | |
--enable-libsvtav1 \ | |
--enable-libzvbi \ | |
--enable-libdav1d \ | |
--enable-libcaca \ | |
--enable-libbluray \ | |
--enable-libsnappy \ | |
--enable-gmp \ | |
--enable-libpulse \ | |
--enable-pocketsphinx \ | |
--enable-libdrm \ | |
--enable-librtmp \ | |
--enable-libxavs2 \ | |
--enable-lv2 \ | |
\ | |
--enable-opencl \ | |
--enable-libopencv | |
RUN make -j $(grep "^core id" /proc/cpuinfo | wc -l) | |
RUN make install | |
# ------------------------------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment