From a7019ef748fd3680e844c752fd670e21297da2f0 Mon Sep 17 00:00:00 2001 From: Abhishek Thakur Date: Sun, 18 Aug 2019 16:22:07 +0530 Subject: [PATCH] Added OpenSSL & various protocol support to FFmpeg backend (#229) * Added OpenSSL & different protocol support to FFmpeg backend - Fixed Docker dependencies (both x86 & x86-64) - Fixes bug #204 * Additional Fixes - updates to OpenSSL build from scratch - removed specific protocol - Added neccessary dependency * Fixed ./Configure command * Updates for docker images: - Added perl build from scratch - Fixed wrong/redundant dependencies/paths - Fixed & updated openssl installation * Fixed Empty continuation lines bug & added comments * fix inconsitent spacing * Don't add perl 5.10 to PATH * fix syntax error * Fixed OpenSSL build fails in i686 Dockerfile due to buggy perl source * Fixing manylinux docker entrypoint for i686 in 32 bit images * ENTRYPOINT not needed, it only affects "docker run" invocations * manylinux1 provides better libcurl for cmake * manylinux1 provides the toolchain and git git install fails in i686, too * cleanup tar invocations * nasm is not installed in manylinux1 * detect i686 in openssl configure * move perl to a separate subtree as it's a private dependency * rm it after library build * comment unusual openssl build step * avoid redundant work in perl build * build each library in a separate dockerfile command for easier debugging * comment custom i686 step * update dockerfile README * opencv now bundles libjpeg-turbo and the separate's onre buid fails dueto expired certificate at https://kent.dl.sourceforge.net --- docker/Dockerfile_i686 | 86 ++++++++++++++++++++++++---------------- docker/Dockerfile_x86_64 | 83 +++++++++++++++++++++----------------- docker/README.md | 3 +- 3 files changed, 99 insertions(+), 73 deletions(-) diff --git a/docker/Dockerfile_i686 b/docker/Dockerfile_i686 index 62366543..98d70324 100644 --- a/docker/Dockerfile_i686 +++ b/docker/Dockerfile_i686 @@ -14,43 +14,74 @@ ENV QTDIR /opt/Qt4.8.7 ENV PATH "$QTDIR/bin:$PATH" RUN curl -O -L https://cmake.org/files/v3.9/cmake-3.9.0.tar.gz && \ - tar -zxf cmake-3.9.0.tar.gz && \ + tar -xf cmake-3.9.0.tar.gz && \ cd cmake-3.9.0 && \ - yum -y install curl-devel zlib-devel && \ + true '#manylinux1 provides curl-devel equivalent and libcurl statically linked \ + against the same newer OpenSSL as other source-built tools \ + (1.0.2s as of this writing)' && \ + yum -y install zlib-devel && \ ./configure --system-curl && \ - make && \ + make -j4 && \ make install && \ cd .. && \ rm -rf cmake-3.9.0* -RUN yum install autoconf automake bzip2 cmake freetype-devel gcc gcc-c++ libtool make mercurial pkgconfig zlib-devel -y && \ - yum remove nasm -y && \ - mkdir ~/ffmpeg_sources && \ - cd ~/ffmpeg_sources && \ +# https://trac.ffmpeg.org/wiki/CompilationGuide/Centos#GettheDependencies +# manylinux provides the toolchain and git; we provide cmake +RUN yum install freetype-devel bzip2-devel zlib-devel -y && \ + mkdir ~/ffmpeg_sources + +# Newer openssl configure requires newer perl +RUN curl -O -L https://www.cpan.org/src/5.0/perl-5.20.1.tar.gz && \ + tar -xf perl-5.20.1.tar.gz && \ + cd perl-5.20.1 && \ + ./Configure -des -Dprefix="$HOME/openssl_build" && \ + true '#perl build scripts do much redundant work \ + if running "make install" separately' && \ + make install -j4 && \ + cd .. && \ + rm -rf perl-5.20.1* + +RUN cd ~/ffmpeg_sources && \ + curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_1_1_1c.tar.gz && \ + tar -xf OpenSSL_1_1_1c.tar.gz && \ + cd openssl-OpenSSL_1_1_1c && \ + true '#in i686, ./config detects x64 in i686 without linux32 \ + when run from "docker build"' && \ + PERL="$HOME/openssl_build/bin/perl" linux32 ./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" shared zlib && \ + make -j4 && \ + true '#skip installing documentation' && \ + make install_sw && \ + rm -rf ~/openssl_build + +RUN cd ~/ffmpeg_sources && \ curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/2.13.02/nasm-2.13.02.tar.bz2 && \ - tar xjvf nasm-2.13.02.tar.bz2 && cd nasm-2.13.02 && ./autogen.sh && \ + tar -xf nasm-2.13.02.tar.bz2 && cd nasm-2.13.02 && ./autogen.sh && \ ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \ make -j4 && \ - make install && \ - cd ~/ffmpeg_sources && \ + make install + +RUN cd ~/ffmpeg_sources && \ curl -O -L http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz && \ - tar xzvf yasm-1.3.0.tar.gz && \ + tar -xf yasm-1.3.0.tar.gz && \ cd yasm-1.3.0 && \ ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \ make -j4 && \ - make install && \ - cd ~/ffmpeg_sources && \ + make install + +RUN cd ~/ffmpeg_sources && \ git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git && \ cd libvpx && \ ./configure --prefix="$HOME/ffmpeg_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm --enable-pic --enable-shared && \ make -j4 && \ - make install && \ - cd ~/ffmpeg_sources && \ + make install + +RUN cd ~/ffmpeg_sources && \ curl -O -L https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 && \ - tar xjvf ffmpeg-snapshot.tar.bz2 && \ + tar -xf ffmpeg-snapshot.tar.bz2 && \ cd ffmpeg && \ PATH=~/bin:$PATH && \ - PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" --enable-libvpx --enable-shared --enable-pic --bindir="$HOME/bin" && \ + PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" --enable-openssl --enable-libvpx --enable-shared --enable-pic --bindir="$HOME/bin" && \ make -j4 && \ make install && \ echo "/root/ffmpeg_build/lib/" >> /etc/ld.so.conf && \ @@ -60,30 +91,15 @@ RUN yum install autoconf automake bzip2 cmake freetype-devel gcc gcc-c++ libtool ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/root/ffmpeg_build/lib/pkgconfig ENV LDFLAGS -L/root/ffmpeg_build/lib -RUN mkdir libjpeg-turbo && \ - cd libjpeg-turbo && \ - export PATH=~/bin:$PATH && \ - curl -L https://kent.dl.sourceforge.net/project/libjpeg-turbo/1.5.3/libjpeg-turbo-1.5.3.tar.gz > libjpeg-turbo-1.5.3.tar.gz && \ - tar xzvf libjpeg-turbo-1.5.3.tar.gz && \ - cd libjpeg-turbo-1.5.3 && \ - export CFLAGS="-fPIC" && \ - export CXXFLAGS="-fPIC" && \ - autoreconf -fiv && \ - ./configure --host=i686-pc-linux-gnu && \ - make && \ - make install && \ - cd ../../ && \ - rm -rf libjpeg-turbo - -ENV JPEG_LIBRARY /opt/libjpeg-turbo/lib32/libjpeg.a -ENV JPEG_INCLUDE_DIR /opt/libjpeg-turbo/include - RUN curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/uapi/linux/videodev2.h && \ curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/uapi/linux/v4l2-common.h && \ curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/uapi/linux/v4l2-controls.h && \ curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/linux/compiler.h && \ mv videodev2.h v4l2-common.h v4l2-controls.h compiler.h /usr/include/linux +#in i686, yum metadata ends up with slightly wrong timestamps +#which inhibits its update +#https://github.com/skvark/opencv-python/issues/148 RUN yum clean all ENV PATH "$HOME/bin:$PATH" diff --git a/docker/Dockerfile_x86_64 b/docker/Dockerfile_x86_64 index e9de76e8..81b59974 100644 --- a/docker/Dockerfile_x86_64 +++ b/docker/Dockerfile_x86_64 @@ -14,43 +14,72 @@ ENV QTDIR /opt/Qt4.8.7 ENV PATH "$QTDIR/bin:$PATH" RUN curl -O -L https://cmake.org/files/v3.9/cmake-3.9.0.tar.gz && \ - tar -zxf cmake-3.9.0.tar.gz && \ + tar -xf cmake-3.9.0.tar.gz && \ cd cmake-3.9.0 && \ - yum -y install curl-devel zlib-devel && \ + true '#manylinux1 provides curl-devel equivalent and libcurl statically linked \ + against the same newer OpenSSL as other source-built tools \ + (1.0.2s as of this writing)' && \ + yum -y install zlib-devel && \ ./configure --system-curl && \ - make && \ + make -j4 && \ make install && \ cd .. && \ rm -rf cmake-3.9.0* -RUN yum install autoconf automake bzip2 cmake freetype-devel gcc gcc-c++ libtool make mercurial pkgconfig zlib-devel -y && \ - yum remove nasm -y && \ - mkdir ~/ffmpeg_sources && \ - cd ~/ffmpeg_sources && \ +# https://trac.ffmpeg.org/wiki/CompilationGuide/Centos#GettheDependencies +# manylinux provides the toolchain and git; we provide cmake +RUN yum install freetype-devel bzip2-devel zlib-devel -y && \ + mkdir ~/ffmpeg_sources + +# Newer openssl configure requires newer perl +RUN curl -O -L https://www.cpan.org/src/5.0/perl-5.20.1.tar.gz && \ + tar -xf perl-5.20.1.tar.gz && \ + cd perl-5.20.1 && \ + ./Configure -des -Dprefix="$HOME/openssl_build" && \ + true '#perl build scripts do much redundant work \ + if running "make install" separately' && \ + make install -j4 && \ + cd .. && \ + rm -rf perl-5.20.1* + +RUN cd ~/ffmpeg_sources && \ + curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_1_1_1c.tar.gz && \ + tar -xf OpenSSL_1_1_1c.tar.gz && \ + cd openssl-OpenSSL_1_1_1c && \ + PERL="$HOME/openssl_build/bin/perl" ./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" shared zlib && \ + make -j4 && \ + true '#skip installing documentation' && \ + make install_sw && \ + rm -rf ~/openssl_build + +RUN cd ~/ffmpeg_sources && \ curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/2.13.02/nasm-2.13.02.tar.bz2 && \ - tar xjvf nasm-2.13.02.tar.bz2 && cd nasm-2.13.02 && ./autogen.sh && \ + tar -xf nasm-2.13.02.tar.bz2 && cd nasm-2.13.02 && ./autogen.sh && \ ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \ make -j4 && \ - make install && \ - cd ~/ffmpeg_sources && \ + make install + +RUN cd ~/ffmpeg_sources && \ curl -O -L http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz && \ - tar xzvf yasm-1.3.0.tar.gz && \ + tar -xf yasm-1.3.0.tar.gz && \ cd yasm-1.3.0 && \ ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \ make -j4 && \ - make install && \ - cd ~/ffmpeg_sources && \ + make install + +RUN cd ~/ffmpeg_sources && \ git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git && \ cd libvpx && \ ./configure --prefix="$HOME/ffmpeg_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm --enable-pic --enable-shared && \ make -j4 && \ - make install && \ - cd ~/ffmpeg_sources && \ + make install + +RUN cd ~/ffmpeg_sources && \ curl -O -L https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 && \ - tar xjvf ffmpeg-snapshot.tar.bz2 && \ + tar -xf ffmpeg-snapshot.tar.bz2 && \ cd ffmpeg && \ PATH=~/bin:$PATH && \ - PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" --enable-libvpx --enable-shared --enable-pic --bindir="$HOME/bin" && \ + PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" --enable-openssl --enable-libvpx --enable-shared --enable-pic --bindir="$HOME/bin" && \ make -j4 && \ make install && \ echo "/root/ffmpeg_build/lib/" >> /etc/ld.so.conf && \ @@ -60,28 +89,10 @@ RUN yum install autoconf automake bzip2 cmake freetype-devel gcc gcc-c++ libtool ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/root/ffmpeg_build/lib/pkgconfig ENV LDFLAGS -L/root/ffmpeg_build/lib -RUN mkdir libjpeg-turbo && \ - cd libjpeg-turbo && \ - export PATH=~/bin:$PATH && \ - curl -L https://kent.dl.sourceforge.net/project/libjpeg-turbo/1.5.3/libjpeg-turbo-1.5.3.tar.gz > libjpeg-turbo-1.5.3.tar.gz && \ - tar xzvf libjpeg-turbo-1.5.3.tar.gz && \ - cd libjpeg-turbo-1.5.3 && \ - export CFLAGS="-fPIC" && \ - export CXXFLAGS="-fPIC" && \ - autoreconf -fiv && \ - ./configure && \ - make && \ - make install && \ - cd ../../ && \ - rm -rf libjpeg-turbo - -ENV JPEG_LIBRARY /opt/libjpeg-turbo/lib64/libjpeg.a -ENV JPEG_INCLUDE_DIR /opt/libjpeg-turbo/include - RUN curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/uapi/linux/videodev2.h && \ curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/uapi/linux/v4l2-common.h && \ curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/uapi/linux/v4l2-controls.h && \ curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/linux/compiler.h && \ mv videodev2.h v4l2-common.h v4l2-controls.h compiler.h /usr/include/linux -ENV PATH "$HOME/bin:$PATH" \ No newline at end of file +ENV PATH "$HOME/bin:$PATH" diff --git a/docker/README.md b/docker/README.md index 2e8602bf..e31d7a07 100644 --- a/docker/README.md +++ b/docker/README.md @@ -10,6 +10,5 @@ The images have following extra software installed: - Qt 4.8.7 - Cmake 3.9.0 -- FFmpeg with libvpx (latest snapshots at the build time) -- libjpeg-turbo 1.5.3 +- FFmpeg with libvpx (latest snapshots at the build time) and recent openssl - Some missing headers included from more recent Linux to be able to enable V4L / V4L2 support in OpenCV \ No newline at end of file