Skip to content

Instantly share code, notes, and snippets.

@rosstimson
Created October 13, 2015 20:37
Show Gist options
  • Save rosstimson/05a697008faa0f87524b to your computer and use it in GitHub Desktop.
Save rosstimson/05a697008faa0f87524b to your computer and use it in GitHub Desktop.
Easily get ffmpeg on Fedora with support for all the things.
# Dockerfile for ffmpeg with pretty much support for everything as per:
# https://trac.ffmpeg.org/wiki/CompilationGuide/Centos
# includes codecs with weird licensing like MP3 and AAC.
#
FROM fedora
MAINTAINER Ross Timson <[email protected]>
# Install build requirements.
RUN dnf install -y autoconf automake cmake freetype-devel gcc gcc-c++ git libtool make mercurial nasm pkgconfig zlib-devel
# Yasm
RUN cd /usr/local/src \
&& git clone --depth 1 git://github.com/yasm/yasm.git \
&& cd yasm \
&& autoreconf -fiv \
&& ./configure --prefix="/usr/local" \
&& make \
&& make install
# libx264
RUN cd /usr/local/src \
&& git clone --depth 1 git://git.videolan.org/x264 \
&& cd x264 \
&& ./configure --prefix="/usr/local" --enable-static \
&& make \
&& make install
# libx265
RUN cd /usr/local/src \
&& hg clone https://bitbucket.org/multicoreware/x265 \
&& cd /usr/local/src/x265/build/linux \
&& cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="/usr/local" -DENABLE_SHARED:bool=off ../../source \
&& make \
&& make install
# libfdk_aac
RUN cd /usr/local/src \
&& git clone --depth 1 git://git.code.sf.net/p/opencore-amr/fdk-aac \
&& cd fdk-aac \
&& autoreconf -fiv \
&& ./configure --prefix="/usr/local" --disable-shared \
&& make \
&& make install
# libmp3lame
RUN cd /usr/local/src \
&& curl -L -O http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz \
&& tar xzvf lame-3.99.5.tar.gz \
&& cd lame-3.99.5 \
&& ./configure --prefix="/usr/local" --disable-shared --enable-nasm \
&& make \
&& make install
# libopus
RUN cd /usr/local/src \
&& git clone https://git.xiph.org/opus.git \
&& cd opus \
&& autoreconf -fiv \
&& ./configure --prefix="/usr/local" --disable-shared \
&& make \
&& make install
# libogg
RUN cd /usr/local/src \
&& curl -O http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.gz \
&& tar xzvf libogg-1.3.2.tar.gz \
&& cd libogg-1.3.2 \
&& ./configure --prefix="/usr/local" --disable-shared \
&& make \
&& make install
# libvorbis
RUN cd /usr/local/src \
&& curl -O http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.gz \
&& tar xzvf libvorbis-1.3.5.tar.gz \
&& cd libvorbis-1.3.5 \
&& ./configure --prefix="/usr/local" --disable-shared \
# LDFLAGS="-L$HOME/ffmeg_build/lib" CPPFLAGS="-I$HOME/ffmpeg_build/include" ./configure --prefix="/usr/local" --with-ogg="$HOME/ffmpeg_build" --disable-shared \
&& make \
&& make install
# libvpx
RUN cd /usr/local/src \
&& git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git \
&& cd libvpx \
&& ./configure --prefix="/usr/local" --as=yasm --disable-examples \
&& make \
&& make install
# ffmpeg
#
# TODO: Work out why freetype support isn't working in order to use: --enable-libfreetype
RUN cd /usr/local/src \
&& git clone --depth 1 git://source.ffmpeg.org/ffmpeg \
&& cd ffmpeg \
&& PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" ./configure --prefix="/usr/local" --extra-cflags="-I/usr/local/include" --extra-ldflags="-L/usr/local/lib" --pkg-config-flags="--static" --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 \
&& make \
&& make install
# Cleanup.
RUN rm -rf /usr/local/src/* \
&& dnf clean all \
&& dnf erase -y autoconf automake cmake freetype-devel gcc gcc-c++ git libtool make mercurial nasm pkgconfig zlib-devel
# Define entrypoint so we can use container as if it's a standalone app.
ENTRYPOINT ["/usr/local/bin/ffmpeg"]
#!/usr/bin/env bash
# Build ffmpeg with pretty much support for everything as per:
# https://trac.ffmpeg.org/wiki/CompilationGuide/Centos
# includes codecs with weird licensing like MP3 and AAC.
#
# Tested on Fedora 22.
#
set -eux
# Install build requirements.
dnf install -y \
autoconf \
automake \
cmake \
freetype-devel \
gcc \
gcc-c++ \
git \
libogg-devel \
libtool \
libvorbis-devel \
libvpx-devel \
make \
mercurial \
nasm \
opus-devel \
pkgconfig \
yasm \
zlib-devel
# libx264
cd /usr/local/src
git clone --depth 1 git://git.videolan.org/x264
cd x264
./configure --prefix="/usr/local" --enable-static
make
make install
make distclean
# libx265
cd /usr/local/src
hg clone https://bitbucket.org/multicoreware/x265
cd /usr/local/src/x265/build/linux
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="/usr/local" -DENABLE_SHARED:bool=off ../../source
make
make install
# libfdk_aac
cd /usr/local/src
git clone --depth 1 git://git.code.sf.net/p/opencore-amr/fdk-aac
cd fdk-aac
autoreconf -fiv
./configure --prefix="/usr/local" --disable-shared
make
make install
make distclean
# libmp3lame
cd /usr/local/src
curl -L -O http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
tar xzvf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure --prefix="/usr/local" --disable-shared --enable-nasm
make
make install
make distclean
# ffmpeg
cd /usr/local/src
git clone --depth 1 git://source.ffmpeg.org/ffmpeg
cd ffmpeg
PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" ./configure --prefix="/usr/local" --extra-cflags="-I/usr/local/include" --extra-ldflags="-L/usr/local/lib" --pkg-config-flags="--static" --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265
make
make install
make distclean
hash -r
@diepeterpan
Copy link

For Fedora 32 I had to make the following changes:

  1. Optional install - "sudo dnf install numactl" and "sudo dnf install numactl-devel"
  2. Line 35: Change "git clone --depth 1 git://git.videolan.org/x264" to "git clone --depth 1 https://code.videolan.org/videolan/x264.git"
  3. Line 74: added "--extra-libs=-lpthread"

And that was it; compiled without problem.

@grantmcwilliams
Copy link

I'm on Fedora 38 and had to make the following changes in addition to the ones listed by diepeterpan

  1. Line 44: git clone --branch stable --depth 2 https://bitbucket.org/multicoreware/x265_git
  2. Line 45: cd /usr/local/src/x265_git/build/linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment