Install ffmpeg from source on Ubuntu

This tutorial is designed for a headless server, and does not install anything related to `X11`. These instructions assume that you have escalated to root (`sudo su`), and have been tested with Ubuntu 12.04, 12.10, & 13.04.
=Initial Installation=
# Remove old `ffmpeg`, `x264`, and `avconv`
{{{
apt-get remove -y ffmpeg x264 libav-tools yasm &&
apt-get autoremove -y
}}}
# Install dependencies. I added `python-dev` & `cython` because I use the `yasm` Python bindings; remove if you do not need them.
{{{
apt-get update && apt-get upgrade -y &&
apt-get install -y autoconf automake build-essential git libass-dev libfaac-dev libgpac-dev \
libmp3lame-dev libopus-dev libtheora-dev libtool libvorbis-dev libvpx-dev pkg-config texi2html \
zlib1g-dev python-dev cython
}}}
# Set up the sources directory
{{{
cd /usr/local/src/ &&
mkdir ffmpeg_sources &&
cd ffmpeg_sources/
}}}
# Install [[http://yasm.tortall.net/|yasm]]. The current version is 1.3.0 (as of 02/28/2015); check [[http://yasm.tortall.net/Download.html]] for new versions. Remove `–enable-python-bindings` if you do not need the `yasm` Python bindings.
{{{
wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz &&
tar -xvf yasm-1.3.0.tar.gz &&
cd yasm-1.3.0 &&
./configure –prefix=”/usr/local/src/ffmpeg_build” –bindir=”/usr/local/bin” –enable-python-bindings &&
make && make install && make distclean &&
cd .. &&
rm -Rf yasm-1.3.0.tar.gz
}}}
# Install [[http://www.videolan.org/developers/x264.html|x264]]
{{{
git clone –depth 1 git://git.videolan.org/x264.git &&
cd x264 &&
./configure –prefix=”/usr/local/src/ffmpeg_build” –bindir=”/usr/local/bin” –enable-static &&
make && make install && make distclean &&
cd ..
}}}
# Install [[https://github.com/mstorsjo/fdk-aac|fdk-aac]]
{{{
git clone –depth 1 git://github.com/mstorsjo/fdk-aac.git &&
cd fdk-aac &&
autoreconf -fiv &&
./configure –prefix=”/usr/local/src/ffmpeg_build” –bindir=”/usr/local/bin” –disable-shared &&
make && make install && make distclean &&
cd ..
}}}
# Install [[http://www.ffmpeg.org/|ffmpeg]]
{{{
git clone –depth 1 git://source.ffmpeg.org/ffmpeg &&
cd ffmpeg &&
./configure –prefix=”/usr/local/src/ffmpeg_build” –extra-cflags=”-I/usr/local/src/ffmpeg_build/include” \
–extra-ldflags=”-L/usr/local/src/ffmpeg_build/lib” –bindir=”/usr/local/bin” –extra-libs=”-ldl” –enable-gpl \
–enable-libass –enable-libfaac –enable-libfdk-aac –enable-libmp3lame –enable-libopus –enable-postproc \
–enable-libtheora –enable-libvorbis –enable-libvpx –enable-libx264 –enable-nonfree &&
make && make install && make distclean &&
hash -r &&
cd ..
}}}
=Updating=
# Remove old build files & binaries
{{{
rm -Rf /usr/local/src/ffmpeg_build /usr/local/bin/{ffmpeg,ffplay,ffprobe,ffserver,yasm,vsyasm,ytasm,x264}
}}}
# Update packages through package manager
{{{
apt-get update && apt-get upgrade -y
}}}
# Install `yasm`. The current version is 1.3.0 (as of 02/28/2015); check [[http://yasm.tortall.net/Download.html]] for new versions. Remove `–enable-python-bindings` if you do not need the `yasm` Python bindings.
{{{
cd /usr/local/src/ffmpeg_sources &&
wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz &&
tar -xvf yasm-1.3.0.tar.gz &&
cd yasm-1.3.0 &&
./configure –prefix=”/usr/local/src/ffmpeg_build” –bindir=”/usr/local/bin” –enable-python-bindings &&
make && make install && make distclean &&
cd .. &&
rm -Rf yasm-1.3.0.tar.gz
}}}
# Update source binaries
{{{
cd /usr/local/src/ffmpeg_sources/x264 &&
git pull &&
./configure –prefix=”/usr/local/src/ffmpeg_build” –bindir=”/usr/local/bin” –enable-static &&
make && make install && make distclean &&
cd ../fdk-aac &&
git pull &&
./configure –prefix=”/usr/local/src/ffmpeg_build” –disable-shared &&
make && make install && make distclean &&
cd ../ffmpeg &&
./configure –prefix=”/usr/local/src/ffmpeg_build” –extra-cflags=”-I/usr/local/src/ffmpeg_build/include” \
–extra-ldflags=”-L/usr/local/src/ffmpeg_build/lib” –bindir=”/usr/local/bin” –extra-libs=”-ldl” –enable-gpl \
–enable-libass –enable-libfaac –enable-libfdk-aac –enable-libmp3lame –enable-libopus –enable-postproc \
–enable-libtheora –enable-libvorbis –enable-libvpx –enable-libx264 –enable-nonfree &&
make && make install && make distclean &&
cd ..
}}}


Posted

in

,

by

Comments

3 responses to “Install ffmpeg from source on Ubuntu”

  1. James Avatar

    Thanks very much for this! I followed the official walkthrough on the ffmpeg site and it failed terribly – yours, copied and pasted, worked perfectly. Thanks!

    1. dlasley Avatar

      I’m always happy to hear when my tutorials are being used. Thanks for letting me know that it worked and for reading my blog!

  2. chiba erika Avatar

    I have problom with my ubuntu 14.04, problem is :
    ” Unable to create and execute files in /tmp. Set the TMPDIR environment variable to another directory and make sure that it is not mounted noexec. Sanity test failed. ”

    so this is the way to solve it :

    export TMPDIR=~/tmp_ffmpeg
    mkdir $TMPDIR

    ./configur bla bla bla

    Ref : StackOverflow and http://sysadmintutorial.blogspot.com

Leave a Reply to dlasley Cancel reply

Your email address will not be published. Required fields are marked *