Skip to content

Instantly share code, notes, and snippets.

@swooningfish
Last active March 11, 2019 22:25
Show Gist options
  • Save swooningfish/4471378 to your computer and use it in GitHub Desktop.
Save swooningfish/4471378 to your computer and use it in GitHub Desktop.
Compile FFmpeg on Ubuntu
# Source from https://ffmpeg.org/trac/ffmpeg/wiki/UbuntuCompilationGuide
#Remove any existing packages:
sudo apt-get remove ffmpeg x264 libav-tools libvpx-dev libx264-dev
#Get the dependencies (Ubuntu Desktop users):
sudo apt-get update
sudo apt-get -y install autoconf build-essential checkinstall git libass-dev libfaac-dev \
libgpac-dev libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev \
librtmp-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev \
libx11-dev libxext-dev libxfixes-dev pkg-config texi2html yasm zlib1g-dev
#Get the dependencies (Ubuntu Server or headless users):
sudo apt-get update
sudo apt-get -y install autoconf build-essential checkinstall git libass-dev libfaac-dev \
libgpac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev librtmp-dev \
libtheora-dev libtool libvorbis-dev pkg-config texi2html yasm zlib1g-dev
# x264 - H.264 video encoder. The following commands will get the current source files, compile, and install x264.
cd
git clone --depth 1 git://git.videolan.org/x264
cd x264
./configure --enable-static
make
sudo checkinstall --pkgname=x264 --pkgversion="3:$(./version.sh | \
awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes \
--fstrans=no --default
# fdk-aac - AAC audio encoder.
cd
git clone --depth 1 git://github.com/mstorsjo/fdk-aac.git
cd fdk-aac
autoreconf -fiv
./configure --disable-shared
make
sudo checkinstall --pkgname=fdk-aac --pkgversion="$(date +%Y%m%d%H%M)-git" --backup=no \
--deldoc=yes --fstrans=no --default
# libvpx - VP8 video encoder and decoder.
cd
git clone --depth 1 http://git.chromium.org/webm/libvpx.git
cd libvpx
./configure
make
sudo checkinstall --pkgname=libvpx --pkgversion="1:$(date +%Y%m%d%H%M)-git" --backup=no \
--deldoc=yes --fstrans=no --default
# opus (optional) - Opus audio encoder and decoder. Add --enable-libopus to your ffmpeg ./configure line if you want to use this.
cd
git clone --depth 1 git://git.xiph.org/opus.git
cd opus
./autogen.sh
./configure --disable-shared
make
sudo checkinstall --pkgname=libopus --pkgversion="$(date +%Y%m%d%H%M)-git" --backup=no \
--deldoc=yes --fstrans=no --default
# FFmpeg - Ubuntu Server users should omit --enable-x11grab.
cd
git clone --depth 1 git://source.ffmpeg.org/ffmpeg
cd ffmpeg
./configure --enable-gpl --enable-libass --enable-libfaac --enable-libfdk-aac --enable-libmp3lame \
--enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libtheora \
--enable-libvorbis --enable-libvpx --enable-x11grab --enable-libx264 --enable-nonfree --enable-version3
make
sudo checkinstall --pkgname=ffmpeg --pkgversion="7:$(date +%Y%m%d%H%M)-git" --backup=no \
--deldoc=yes --fstrans=no --default
hash -r
#qt-faststart - This is a useful tool if you're showing your H.264 in MP4 videos on the web. It relocates some data in the video to allow playback to begin before the file is completely downloaded. Usage: qt-faststart input.mp4 output.mp4.
cd ~/ffmpeg
make tools/qt-faststart
sudo checkinstall --pkgname=qt-faststart --pkgversion="$(date +%Y%m%d%H%M)-git" --backup=no \
--deldoc=yes --fstrans=no --default install -Dm755 tools/qt-faststart \
/usr/local/bin/qt-faststart
# Add lavf support to x264 - This allows x264 to accept just about any input that FFmpeg can handle and is useful if you want to use x264 directly.
cd ~/x264
make distclean
./configure --enable-static
make
sudo checkinstall --pkgname=x264 --pkgversion="3:$(./version.sh | \
awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes \
--fstrans=no --default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment