├── .gitignore ├── LICENSE ├── README.md ├── ruby-xenial └── Dockerfile └── video-transcoding └── Dockerfile /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.swp 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Nate Todd 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Video Transcoding for Docker 2 | 3 | Docker support for [https://github.com/donmelton/video_transcoding](https://github.com/donmelton/video_transcoding) 4 | 5 | The Docker image is [available on Docker Hub](https://hub.docker.com/r/ntodd/video-transcoding/). 6 | 7 | ## Prerequisites 8 | 9 | You must be running [Docker for Mac](https://docs.docker.com/engine/installation/mac/), [Docker for Linux](https://docs.docker.com/engine/installation/linux/), or [Docker for Windows](https://docs.docker.com/engine/installation/windows/). 10 | 11 | ## Usage 12 | 13 | To run the video_transcoding gem in Docker, execute the following: 14 | 15 | ``` 16 | # Docker for Mac & Linux 17 | docker run -itv "`pwd`":/data ntodd/video-transcoding 18 | 19 | # Docker for Windows 20 | docker run -itv C:\My\Current\Path:/data ntodd/video-transcoding 21 | ``` 22 | 23 | This will: 24 | 25 | 1. Download the `ntodd/video-transcoding` Docker image (unless already downloaded) 26 | 2. Mount the current working directory on your host machine as a shared volume inside the container 27 | 3. Run an interactive bash shell with access to your current directory and the video_transcoding cli tools 28 | 29 | For best results on Docker for Mac or Windows, set your CPU count in preferences to the maximum available for your machine. 30 | 31 | To update to the latest version: 32 | 33 | ``` 34 | docker pull ntodd/video-transcoding:latest 35 | ``` 36 | -------------------------------------------------------------------------------- /ruby-xenial/Dockerfile: -------------------------------------------------------------------------------- 1 | # ntodd/ruby-xenial:2.4.1 2 | 3 | FROM ubuntu:xenial 4 | LABEL maintainer="Nate Todd " 5 | 6 | ENV RUBY_MAJOR=2.4 \ 7 | RUBY_VERSION=2.4.1 \ 8 | RUBY_DOWNLOAD_SHA256=a330e10d5cb5e53b3a0078326c5731888bb55e32c4abfeb27d9e7f8e5d000250 \ 9 | RUBYGEMS_VERSION=2.6.12 \ 10 | BUNDLER_VERSION=1.15.4 11 | 12 | RUN set -ex \ 13 | && apt-get update \ 14 | && apt-get install -y --no-install-recommends \ 15 | bzip2 \ 16 | ca-certificates \ 17 | libffi-dev \ 18 | libgdbm3 \ 19 | libssl-dev \ 20 | libyaml-dev \ 21 | procps \ 22 | zlib1g-dev \ 23 | && rm -rf /var/lib/apt/lists/* \ 24 | \ 25 | # skip installing gem documentation 26 | && mkdir -p /usr/local/etc \ 27 | && { \ 28 | echo 'install: --no-document'; \ 29 | echo 'update: --no-document'; \ 30 | } >> /usr/local/etc/gemrc \ 31 | \ 32 | # some of ruby's build scripts are written in ruby 33 | # we purge system ruby later to make sure our final image uses what we just built 34 | && buildDeps=' \ 35 | autoconf \ 36 | bison \ 37 | gcc \ 38 | libbz2-dev \ 39 | libgdbm-dev \ 40 | libglib2.0-dev \ 41 | libncurses-dev \ 42 | libreadline-dev \ 43 | libxml2-dev \ 44 | libxslt-dev \ 45 | make \ 46 | ruby \ 47 | wget \ 48 | xz-utils \ 49 | ' \ 50 | && apt-get update \ 51 | && apt-get install -y --no-install-recommends $buildDeps \ 52 | && rm -rf /var/lib/apt/lists/* \ 53 | \ 54 | && wget -O ruby.tar.gz "https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR%-rc}/ruby-$RUBY_VERSION.tar.gz" \ 55 | && echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.gz" | sha256sum -c - \ 56 | \ 57 | && mkdir -p /usr/src/ruby \ 58 | && tar -xzf ruby.tar.gz -C /usr/src/ruby --strip-components=1 \ 59 | && rm ruby.tar.gz \ 60 | \ 61 | && cd /usr/src/ruby \ 62 | \ 63 | # hack in "ENABLE_PATH_CHECK" disabling to suppress: 64 | # warning: Insecure world writable dir 65 | && { \ 66 | echo '#define ENABLE_PATH_CHECK 0'; \ 67 | echo; \ 68 | cat file.c; \ 69 | } > file.c.new \ 70 | && mv file.c.new file.c \ 71 | \ 72 | && autoconf \ 73 | && ./configure --disable-install-doc --enable-shared \ 74 | && make -j"$(nproc)" \ 75 | && make install \ 76 | \ 77 | && apt-get purge -y --auto-remove $buildDeps \ 78 | && cd / \ 79 | && rm -r /usr/src/ruby \ 80 | \ 81 | && gem update --system "$RUBYGEMS_VERSION" \ 82 | && gem install bundler --version "$BUNDLER_VERSION" 83 | 84 | # install things globally, for great justice 85 | # and don't create ".bundle" in all our apps 86 | ENV GEM_HOME=/usr/local/bundle \ 87 | BUNDLE_PATH="$GEM_HOME" \ 88 | BUNDLE_BIN="$GEM_HOME/bin" \ 89 | BUNDLE_SILENCE_ROOT_WARNING=1 \ 90 | BUNDLE_APP_CONFIG="$GEM_HOME" \ 91 | PATH=$BUNDLE_BIN:$PATH 92 | 93 | RUN mkdir -p "$GEM_HOME" "$BUNDLE_BIN" \ 94 | && chmod 777 "$GEM_HOME" "$BUNDLE_BIN" 95 | 96 | CMD [ "irb" ] 97 | -------------------------------------------------------------------------------- /video-transcoding/Dockerfile: -------------------------------------------------------------------------------- 1 | # ntodd/video-transcoding:0.21.1 2 | 3 | FROM ntodd/ruby-xenial:2.4.0 4 | LABEL maintainer="Nate Todd " 5 | 6 | ENV GEM_VERSION 0.25.2 7 | ENV NASM_VERSION 2.13.01 8 | ENV FDKAAC_VERSION 0.1.6 9 | ENV LIBX265_VERSION 2.9 10 | ENV HANDBRAKE_VERSION 1.1.2 11 | ENV FFMPEG_VERSION 4.1 12 | 13 | # install build dependencies to compile ffmpeg from master 14 | RUN set -ex \ 15 | && buildDeps=' \ 16 | autoconf \ 17 | automake \ 18 | build-essential \ 19 | git \ 20 | libass-dev \ 21 | libbz2-dev \ 22 | libfontconfig1-dev \ 23 | libfreetype6-dev \ 24 | libfribidi-dev \ 25 | libharfbuzz-dev \ 26 | libjansson-dev \ 27 | libogg-dev \ 28 | libsamplerate-dev \ 29 | libtheora-dev \ 30 | libtool \ 31 | libvorbis-dev \ 32 | libxml2-dev \ 33 | m4 \ 34 | make \ 35 | patch \ 36 | pkg-config \ 37 | python \ 38 | tar \ 39 | libtool-bin \ 40 | texinfo \ 41 | wget \ 42 | zlib1g-dev \ 43 | yasm \ 44 | cmake \ 45 | cmake-curses-gui \ 46 | mercurial \ 47 | libmp3lame-dev \ 48 | libopus-dev \ 49 | libvpx-dev \ 50 | libx264-dev \ 51 | unzip \ 52 | mkvtoolnix \ 53 | mp4v2-utils \ 54 | mpv \ 55 | ' \ 56 | && apt-get update \ 57 | && apt-get install -y --no-install-recommends $buildDeps \ 58 | && mkdir -p /usr/src/ffmpeg/bin \ 59 | && mkdir -p /usr/src/ffmpeg/build \ 60 | && PATH="/usr/src/ffmpeg/bin:$PATH" \ 61 | && cd /usr/src/ffmpeg \ 62 | # NASM 63 | && wget http://www.nasm.us/pub/nasm/releasebuilds/$NASM_VERSION/nasm-$NASM_VERSION.tar.bz2 \ 64 | && tar xjvf nasm-*.tar.bz2 \ 65 | && cd nasm-* \ 66 | && ./autogen.sh \ 67 | && PATH="/usr/src/ffmpeg/bin:$PATH" ./configure --prefix="/usr/src/ffmpeg/build" --bindir="/usr/src/ffmpeg/bin" \ 68 | && PATH="/usr/src/ffmpeg/bin:$PATH" make -j"$(nproc)" \ 69 | && make install \ 70 | && cd /usr/src/ffmpeg \ 71 | && rm -rf nasm-* \ 72 | # libx264 stable 73 | && git clone -b stable http://git.videolan.org/git/x264.git x264 \ 74 | && cd x264 \ 75 | && PATH="/usr/src/ffmpeg/bin:$PATH" ./configure --prefix="/usr/src/ffmpeg/build" --bindir="/usr/src/ffmpeg/bin" --enable-static --disable-opencl \ 76 | && PATH="/usr/src/ffmpeg/bin:$PATH" make -j"$(nproc)" \ 77 | && make install \ 78 | && cd /usr/src/ffmpeg \ 79 | && rm -rf x264-snapshot* \ 80 | # libfdk-aac 81 | && git clone https://github.com/mstorsjo/fdk-aac.git \ 82 | && cd fdk-aac && git checkout tags/v$FDKAAC_VERSION \ 83 | && autoreconf -fiv \ 84 | && ./configure --prefix="/usr/src/ffmpeg/build" --disable-shared \ 85 | && make -j"$(nproc)" \ 86 | && make install \ 87 | && cd /usr/src/ffmpeg \ 88 | && rm -rf mstorsjo-fdk-aac* \ 89 | # libx265 90 | && wget -O x265.tar.gz https://bitbucket.org/multicoreware/x265/downloads/x265_$LIBX265_VERSION.tar.gz \ 91 | && tar xzvf x265.tar.gz \ 92 | && cd x265_*/build/linux \ 93 | && PATH="/usr/src/ffmpeg/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="/usr/src/ffmpeg/build" -DENABLE_SHARED:bool=off ../../source \ 94 | && PATH="/usr/src/ffmpeg/bin:$PATH" make -j"$(nproc)" \ 95 | && make install \ 96 | && cd /usr/src/ffmpeg \ 97 | && rm -rf x265 \ 98 | # HandbrakeCli 99 | && git clone https://github.com/HandBrake/HandBrake.git \ 100 | && cd HandBrake && git checkout tags/$HANDBRAKE_VERSION \ 101 | && ./configure --launch-jobs=$(nproc) --disable-gtk --launch \ 102 | && cd build && make install \ 103 | && cd /usr/src/ffmpeg \ 104 | && rm -rf HandBrake \ 105 | # FFmpeg 106 | && wget -O ffmpeg.zip https://github.com/FFmpeg/FFmpeg/archive/n$FFMPEG_VERSION.zip \ 107 | && unzip ffmpeg.zip \ 108 | && mv FFmpeg* ffmpeg_src \ 109 | && cd ffmpeg_src \ 110 | && PATH="/usr/src/ffmpeg/bin:$PATH" PKG_CONFIG_PATH="/usr/src/ffmpeg/build/lib/pkgconfig" ./configure \ 111 | --prefix="/usr/src/ffmpeg/build" \ 112 | --pkg-config-flags="--static" \ 113 | --extra-cflags="-I/usr/src/ffmpeg/build/include" \ 114 | --extra-ldflags="-L/usr/src/ffmpeg/build/lib" \ 115 | --bindir="/usr/src/ffmpeg/bin" \ 116 | --extra-libs=-lpthread \ 117 | --enable-gpl \ 118 | --enable-libass \ 119 | --enable-libfdk-aac \ 120 | --enable-libfreetype \ 121 | --enable-libmp3lame \ 122 | --enable-libopus \ 123 | --enable-libtheora \ 124 | --enable-libvorbis \ 125 | --enable-libvpx \ 126 | --enable-libx264 \ 127 | --enable-libx265 \ 128 | --enable-nonfree \ 129 | && PATH="/usr/src/ffmpeg/bin:$PATH" make -j"$(nproc)" \ 130 | && make install \ 131 | && hash -r \ 132 | && cd / \ 133 | && mv /usr/src/ffmpeg/bin/ff* /usr/local/bin \ 134 | && rm -rf /usr/src/ffmpeg 135 | 136 | RUN set -ex \ 137 | # Install application dependencies 138 | && apt-get purge -y --auto-remove $buildDeps \ 139 | && rm -rf /var/lib/apt/lists/* \ 140 | && gem install video_transcoding -v "$GEM_VERSION" \ 141 | && mkdir /data 142 | 143 | WORKDIR /data 144 | 145 | CMD [ "/bin/bash" ] 146 | --------------------------------------------------------------------------------