Skip to content

Instantly share code, notes, and snippets.

@kauld
Forked from freedomlang/install-ffmpeg-centos.sh
Last active November 6, 2022 18:13
Show Gist options
  • Save kauld/379a269c4bc24e152b4b002875fd8676 to your computer and use it in GitHub Desktop.
Save kauld/379a269c4bc24e152b4b002875fd8676 to your computer and use it in GitHub Desktop.
Compile ffmpeg in Fedora 37
#!/bin/bash
if [ "`/usr/bin/whoami`" != "root" ]; then
echo "You need to execute this script as root."
exit 1
fi
INSTALL_DIR="./builds/ffmpeg"
###############################################################################
# ffmpeg installer for centos 7
# based on instructions at https://trac.ffmpeg.org/wiki/CompilationGuide/Centos
###############################################################################
yum install -y autoconf automake bzip2 bzip2-devel cmake freetype-devel gcc gcc-c++ git libtool make mercurial pkgconfig zlib-devel
mkdir ~/$INSTALL_DIR/ffmpeg_sources
# NASM
cd ~/$INSTALL_DIR/ffmpeg_sources
curl -O -L https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.bz2
tar xjvf nasm-2.14.02.tar.bz2
cd nasm-2.14.02
./autogen.sh
./configure --prefix="$HOME/$INSTALL_DIR/ffmpeg_build" --bindir="$HOME/$INSTALL_DIR/bin"
make
make install
# Yasm
cd ~/$INSTALL_DIR/ffmpeg_sources
curl -O -L https://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
tar xzvf yasm-1.3.0.tar.gz
cd yasm-1.3.0
./configure --prefix="$HOME/$INSTALL_DIR/ffmpeg_build" --bindir="$HOME/$INSTALL_DIR/bin"
make
make install
# libx264
cd ~/$INSTALL_DIR/ffmpeg_sources
git clone --depth 1 https://code.videolan.org/videolan/x264.git
cd x264
PKG_CONFIG_PATH="$HOME/$INSTALL_DIR/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/$INSTALL_DIR/ffmpeg_build" --bindir="$HOME/$INSTALL_DIR/bin" --enable-static
make
make install
# libx265
cd ~/$INSTALL_DIR/ffmpeg_sources
hg clone https://bitbucket.org/multicoreware/x265
cd ~/$INSTALL_DIR/ffmpeg_sources/x265/build/linux
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/$INSTALL_DIR/ffmpeg_build" -DENABLE_SHARED:bool=off ../../source
make
make install
# libfdk_aac
cd ~/$INSTALL_DIR/ffmpeg_sources
git clone --depth 1 https://github.com/mstorsjo/fdk-aac
cd fdk-aac
autoreconf -fiv
./configure --prefix="$HOME/$INSTALL_DIR/ffmpeg_build" --disable-shared
make
make install
# libmp3lame
cd ~/$INSTALL_DIR/ffmpeg_sources
curl -O -L https://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz
tar xzvf lame-3.100.tar.gz
cd lame-3.100
./configure --prefix="$HOME/$INSTALL_DIR/ffmpeg_build" --bindir="$HOME/$INSTALL_DIR/bin" --disable-shared --enable-nasm
make
make install
# libopus
cd ~/$INSTALL_DIR/ffmpeg_sources
curl -O -L https://archive.mozilla.org/pub/opus/opus-1.3.1.tar.gz
tar xzvf opus-1.3.1.tar.gz
cd opus-1.3.1
./configure --prefix="$HOME/$INSTALL_DIR/ffmpeg_build" --disable-shared
make
make install
# libvpx
cd ~/$INSTALL_DIR/ffmpeg_sources
git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git
cd libvpx
./configure --prefix="$HOME/$INSTALL_DIR/ffmpeg_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm
make
make install
# ffmpeg itself
cd ~/$INSTALL_DIR/ffmpeg_sources
curl -O -L https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
tar xjvf ffmpeg-snapshot.tar.bz2
cd ffmpeg
PATH="$HOME/$INSTALL_DIR/bin:$PATH" PKG_CONFIG_PATH="$HOME/$INSTALL_DIR/ffmpeg_build/lib/pkgconfig" ./configure \
--prefix="$HOME/$INSTALL_DIR/ffmpeg_build" \
--pkg-config-flags="--static" \
--extra-cflags="-I$HOME/$INSTALL_DIR/ffmpeg_build/include" \
--extra-ldflags="-L$HOME/$INSTALL_DIR/ffmpeg_build/lib" \
--extra-libs=-lpthread \
--extra-libs=-lm \
--bindir="$HOME/$INSTALL_DIR/bin" \
--enable-gpl \
--enable-libfdk_aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-nonfree
make
make install
sudo ln -s /usr/bin/ffmpeg $HOME/$INSTALL_DIR/bin/ffmpeg -y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment