sourcey / libsourcey

C++14 evented IO libraries for high performance networking and media based applications
https://sourcey.com/libsourcey
GNU Lesser General Public License v2.1
1.31k stars 347 forks source link

Docker Image with ffmpeg? #237

Closed james-maloney closed 6 years ago

james-maloney commented 6 years ago

Are there any docker images that have ffmpeg included?

james-maloney commented 6 years ago

My current attempt. Upgraded to Ubuntu:18.04 since it now has ffmpeg available via apt-get

FROM ubuntu:18.04
MAINTAINER Kam Low <hello@sourcey.com>

# Install the PPA for GCC 6 which is required for C++14
RUN apt-get update && \
  apt-get install -y software-properties-common && \
    add-apt-repository -y ppa:ubuntu-toolchain-r/test

# Install dependencies
RUN apt-get update && apt-get install -y \
  build-essential \
  pkg-config \
  git \
  curl \
  cmake \
  libx11-dev \
  libglu1-mesa-dev \
  gcc-6 \
  g++-6

# Install sudo
RUN apt-get update && apt-get install -y sudo && rm -rf /var/lib/apt/lists/*

# Use GCC 6
RUN sudo update-alternatives \
  --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 \
  --slave /usr/bin/g++ g++ /usr/bin/g++-6

# Install ffmpeg
RUN sudo apt-get update && apt-get install -y ffmpeg

# Download and extract precompiled WebRTC static libraries
# COPY vendor/webrtc-22215-ab42706-linux-x64 /vendor/webrtc-22215-ab42706-linux-x64
RUN mkdir -p /vendor/webrtc-22215-ab42706-linux-x64; \
  curl -sSL https://github.com/sourcey/webrtc-precompiled-builds/raw/master/webrtc-22215-ab42706-linux-x64.tar.gz | sudo tar -xzC /vendor/webrtc-22215-ab42706-linux-x64

# Install LibSourcey
RUN git clone https://github.com/sourcey/libsourcey.git && \
  cd /libsourcey && mkdir build && cd build && \
  cmake .. -DCMAKE_BUILD_TYPE=DEBUG -DBUILD_SHARED_LIBS=OFF -DBUILD_WITH_STATIC_CRT=ON \
           -DBUILD_MODULES=ON -DBUILD_APPLICATIONS=ON -DBUILD_SAMPLES=ON -DBUILD_TESTS=OFF \
           -DWITH_FFMPEG=ON -DWITH_WEBRTC=ON -DENABLE_LOGGING=OFF \
           -DWEBRTC_ROOT_DIR=/vendor/webrtc-22215-ab42706-linux-x64 \
           -DCMAKE_INSTALL_PREFIX=/libsourcey/install && \
  make VERBOSE=1 && \
  make install
  # cachebust

# Set the working directory to the LibSourcey install directory
WORKDIR /libsourcey/install

This errors out with

Sending build context to Docker daemon  85.89MB
Step 1/10 : FROM ubuntu:18.04
 ---> 452a96d81c30
Step 2/10 : MAINTAINER Kam Low <hello@sourcey.com>
 ---> Using cache
 ---> 7d6d62732f68
Step 3/10 : RUN apt-get update &&   apt-get install -y software-properties-common &&    add-apt-repository -y ppa:ubuntu-toolchain-r/test
 ---> Using cache
 ---> aaa113bcc836
Step 4/10 : RUN apt-get update && apt-get install -y   build-essential   pkg-config   git   curl   cmake   libx11-dev   libglu1-mesa-dev   gcc-6   g++-6
 ---> Using cache
 ---> e958aaf78432
Step 5/10 : RUN apt-get update && apt-get install -y sudo && rm -rf /var/lib/apt/lists/*
 ---> Using cache
 ---> c11f2500b027
Step 6/10 : RUN sudo update-alternatives   --install /usr/bin/gcc gcc /usr/bin/gcc-6 60   --slave /usr/bin/g++ g++ /usr/bin/g++-6
 ---> Using cache
 ---> 5119cc9e5d73
Step 7/10 : RUN sudo apt-get update && apt-get install -y ffmpeg
 ---> Using cache
 ---> 7b8c62994f14
Step 8/10 : RUN mkdir -p /vendor/webrtc-22215-ab42706-linux-x64;   curl -sSL https://github.com/sourcey/webrtc-precompiled-builds/raw/master/webrtc-22215-ab42706-linux-x64.tar.gz | sudo tar -xzC /vendor/webrtc-22215-ab42706-linux-x64
 ---> Using cache
 ---> 7fb5ba1b6bcc
Step 9/10 : RUN git clone https://github.com/sourcey/libsourcey.git &&   cd /libsourcey && mkdir build && cd build &&   cmake .. -DCMAKE_BUILD_TYPE=DEBUG -DBUILD_SHARED_LIBS=OFF -DBUILD_WITH_STATIC_CRT=ON            -DBUILD_MODULES=ON -DBUILD_APPLICATIONS=ON -DBUILD_SAMPLES=ON -DBUILD_TESTS=OFF            -DWITH_FFMPEG=ON -DWITH_WEBRTC=ON -DENABLE_LOGGING=OFF            -DWEBRTC_ROOT_DIR=/vendor/webrtc-22215-ab42706-linux-x64            -DCMAKE_INSTALL_PREFIX=/libsourcey/install &&   make VERBOSE=1 &&   make install
 ---> Running in 7d155b6361d4
Cloning into 'libsourcey'...
-- The C compiler identification is GNU 6.4.0
-- The CXX compiler identification is GNU 6.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE
-- Checking for one of the modules 'opencv'
CMake Warning at cmake/CMakeFindExtensions.cmake:122 (message):
  Failed to locate FFmpeg.  Please specify paths manually.
Call Stack (most recent call first):
  cmake/FindFFmpeg.cmake:62 (set_module_found)
  LibSourcey.cmake:212 (find_package)
  CMakeLists.txt:39 (include)

CMake Warning at cmake/FindFFmpeg.cmake:152 (message):
  Required component AVCODEC missing.
Call Stack (most recent call first):
  LibSourcey.cmake:212 (find_package)
  CMakeLists.txt:39 (include)

CMake Warning at cmake/FindFFmpeg.cmake:152 (message):
  Required component AVFORMAT missing.
Call Stack (most recent call first):
  LibSourcey.cmake:212 (find_package)
  CMakeLists.txt:39 (include)

CMake Warning at cmake/FindFFmpeg.cmake:152 (message):
  Required component AVUTIL missing.
Call Stack (most recent call first):
  LibSourcey.cmake:212 (find_package)
  CMakeLists.txt:39 (include)

CMake Warning at cmake/FindFFmpeg.cmake:152 (message):
  Required component AVDEVICE missing.
Call Stack (most recent call first):
  LibSourcey.cmake:212 (find_package)
  CMakeLists.txt:39 (include)

CMake Warning at cmake/FindFFmpeg.cmake:152 (message):
  Required component SWSCALE missing.
Call Stack (most recent call first):
  LibSourcey.cmake:212 (find_package)
  CMakeLists.txt:39 (include)

CMake Warning at cmake/FindFFmpeg.cmake:152 (message):
  Required component SWRESAMPLE missing.
Call Stack (most recent call first):
  LibSourcey.cmake:212 (find_package)
  CMakeLists.txt:39 (include)

-- Could NOT find FFmpeg (missing: FFmpeg_LIBRARIES FFmpeg_INCLUDE_DIRS FFmpeg_AVCODEC_LIBRARIES FFmpeg_AVCODEC_INCLUDE_DIRS FFmpeg_AVFORMAT_LIBRARIES FFmpeg_AVFORMAT_INCLUDE_DIRS FFmpeg_AVUTIL_LIBRARIES FFmpeg_AVUTIL_INCLUDE_DIRS FFmpeg_AVDEVICE_LIBRARIES FFmpeg_AVDEVICE_INCLUDE_DIRS FFmpeg_SWSCALE_LIBRARIES FFmpeg_SWSCALE_INCLUDE_DIRS FFmpeg_SWRESAMPLE_LIBRARIES FFmpeg_SWRESAMPLE_INCLUDE_DIRS)
-- Performing Test _flag_supported
-- Performing Test _flag_supported - Success
-- - Linking dependency libuv with libraries:
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of off64_t
-- Check size of off64_t - done
-- Looking for fseeko
-- Looking for fseeko - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- - Linking dependency minizip with libraries:
-- - Linking dependency http_parser with libraries:
WEBRTC_INCLUDE_DIR: /vendor/webrtc-22215-ab42706-linux-x64/include
WEBRTC_INCLUDE_DIRS: /vendor/webrtc-22215-ab42706-linux-x64/include;/vendor/webrtc-22215-ab42706-linux-x64/include/third_party/boringssl/src/include
-- Found WEBRTC: optimized;/vendor/webrtc-22215-ab42706-linux-x64/lib/x64/Release/libwebrtc_full.a;debug;/vendor/webrtc-22215-ab42706-linux-x64/lib/x64/Debug/libwebrtc_full.a
-- WEBRTC Variables:
-- -- Found: TRUE
-- -- Include Dirs: /vendor/webrtc-22215-ab42706-linux-x64/include;/vendor/webrtc-22215-ab42706-linux-x64/include/third_party/boringssl/src/include
-- -- Libraries: optimized;/vendor/webrtc-22215-ab42706-linux-x64/lib/x64/Release/libwebrtc_full.a;debug;/vendor/webrtc-22215-ab42706-linux-x64/lib/x64/Debug/libwebrtc_full.a
-- -- Debug Libraries:
-- -- Release Libraries:
-- -- Dependencies: -lrt;-lX11;-lGLU
-- Using BoringSSL
CMake Error at cmake/CMakeFindExtensions.cmake:95 (message):
  Required FFmpeg component AVCODEC missing.  Please recompile FFmpeg with
  AVCODEC enabled.
Call Stack (most recent call first):
  cmake/FindFFmpeg.cmake:62 (set_module_found)
  cmake/LibSourceyIncludes.cmake:52 (find_package)
  LibSourcey.cmake:286 (find_dependency)
  CMakeLists.txt:39 (include)

-- Configuring incomplete, errors occurred!
See also "/libsourcey/build/CMakeFiles/CMakeOutput.log".
The command '/bin/sh -c git clone https://github.com/sourcey/libsourcey.git &&   cd /libsourcey && mkdir build && cd build &&   cmake .. -DCMAKE_BUILD_TYPE=DEBUG -DBUILD_SHARED_LIBS=OFF -DBUILD_WITH_STATIC_CRT=ON            -DBUILD_MODULES=ON -DBUILD_APPLICATIONS=ON -DBUILD_SAMPLES=ON -DBUILD_TESTS=OFF            -DWITH_FFMPEG=ON -DWITH_WEBRTC=ON -DENABLE_LOGGING=OFF            -DWEBRTC_ROOT_DIR=/vendor/webrtc-22215-ab42706-linux-x64            -DCMAKE_INSTALL_PREFIX=/libsourcey/install &&   make VERBOSE=1 &&   make install' returned a non-zero code: 1

If I only install ffmpeg in the docker container it seems to be installed fine.

ffmpeg version 3.4.2-2 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.3.0-16ubuntu2)
  configuration: --prefix=/usr --extra-version=2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Hyper fast Audio and Video encoder

I'm a noob when it comes to building cross platform c++ libs so any help is much appreciated, thanks.

arkadiuk commented 6 years ago

Instead of

RUN sudo apt-get update && apt-get install -y ffmpeg

Try:

sudo apt-get install --yes libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libswresample-dev libpostproc-dev

james-maloney commented 6 years ago

@Aroslaw that worked!

added:

RUN sudo apt-get update && sudo apt-get install --yes libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libswresample-dev libpostproc-dev