wiki:

CompilationGuide

/

Ubuntu


Version 63 (modified by llogan, 4 years ago) (diff)

cleanup; expand Finish section; add Also See section

Compile FFmpeg on Ubuntu

This guide for Ubuntu 13.04 Raring Ringtail will provide a local install of the latest FFmpeg tools and libraries including several external encoding and decoding libraries (codecs). This will not provide a system installation and therefore will not interfere with anything such as repository packages.

Separate guides are available for:


Get the Dependencies

Note: Copy and paste the whole code box for each step.

Ubuntu Desktop:

sudo apt-get update
sudo apt-get -y install autoconf automake build-essential git libass-dev libfaac-dev libgpac-dev \
  libmp3lame-dev libopus-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev \
  libvorbis-dev libvpx-dev libx11-dev libxext-dev libxfixes-dev pkg-config texi2html yasm zlib1g-dev

Ubuntu Server:

sudo apt-get update
sudo apt-get -y install 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 \
  yasm zlib1g-dev

Note: The multiverse repository must be enabled in order to install the libfaac-dev package. See more details on adding repositories.


Compilation & Installation

x264

H.264 video encoder. The following commands will get the current source files, compile, and install x264. See the x264 Encoding Guide for some usage examples.

mkdir ~/ffmpeg_sources && \
cd ~/ffmpeg_sources && \
git clone --depth 1 git://git.videolan.org/x264.git && \
cd x264 && \
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --enable-static && \
make && \
make install && \
make distclean

x264 can accept more inputs via lavf if it is compiled again after you compile ffmpeg. This is not a necessary step but is useful if you plan on directly using the x264 binary.

Note: You can download the nightly x264 source snapshot as an alternative to using git.

fdk-aac

AAC audio encoder.

cd ~/ffmpeg_sources && \
git clone --depth 1 git://github.com/mstorsjo/fdk-aac.git && \
cd fdk-aac && \
autoreconf -fiv && \
./configure --prefix="$HOME/ffmpeg_build" --disable-shared && \
make && \
make install && \
make distclean

Note: You can download a fdk-aac source snapshot as an alternative to using git.

ffmpeg

Note: Ubuntu Server users should remove --enable-x11grab from the following command:

cd ~/ffmpeg_sources && \
git clone --depth 1 git://source.ffmpeg.org/ffmpeg && \
cd ffmpeg && \
./configure --prefix="$HOME/ffmpeg_build" --extra-cflags="-I$HOME/ffmpeg_build/include" \
  --extra-ldflags="-L$HOME/ffmpeg_build/lib" --bindir="$HOME/bin" --enable-gpl --enable-libass \
  --enable-libfaac --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-libtheora \
  --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab && \
make && \
make install && \
make distclean \
hash -r \
source ~/.profile

Note: You can download the nightly FFmpeg source snapshot as an alternative to using git.


Finish

Installation is now complete and ffmpeg is now ready for use. Check to see if you're using your new ffmpeg:

$ ffmpeg 2>&1 | head -n1
ffmpeg version git-2013-05-18-5918b7a Copyright (c) 2000-2013 the FFmpeg developers

If you do not see FFmpeg developers in your output then something went wrong and you're probably using the fake "ffmpeg" from the repository.

You can keep the ffmpeg_sources directory if you plan on updating later. See Updating FFmpeg below for more details followed by instructions for reverting all changes made by this guide.


Updating FFmpeg (Ubuntu Desktop)

Development of FFmpeg and x264 is active and an occasional update can give you new features and bug fixes. First, remove (or move) the old files and then update the dependencies:

rm -rf ~/ffmpeg_builds ~/bin/{ffmpeg,ffplay,ffprobe,ffserver,x264}
sudo apt-get update
sudo apt-get -y install autoconf automake build-essential git libass-dev libfaac-dev libgpac-dev \
  libmp3lame-dev libopus-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev \
  libvorbis-dev libvpx-dev libx11-dev libxext-dev libxfixes-dev pkg-config texi2html yasm zlib1g-dev

x264

cd ~/ffmpeg_sources/x264
make distclean
git pull

Now run ./configure, make, and make install as shown in the Install x264 section.

fdk-aac

cd ~/ffmpeg_sources/fdk-aac
make distclean
git pull

Now run ./configure, make, and make install as shown in the Install fdk-aac section.

ffmpeg

cd ~/ffmpeg_sources/ffmpeg
make distclean
git pull

Now run ./configure, make, and make install as shown in the Install FFmpeg section.


Reverting Changes Made by This Guide

To remove ffmpeg, x264, and dependencies installed for this guide:

rm -rf ~/ffmpeg_builds ~/ffmpeg_sources ~/bin/{ffmpeg,ffplay,ffprobe,ffserver,x264}
sudo apt-get autoremove autoconf automake build-essential git libass-dev libfaac-dev libgpac-dev \
  libmp3lame-dev libopus-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev \
  libvorbis-dev libvpx-dev libx11-dev libxext-dev libxfixes-dev texi2html yasm zlib1g-dev
hash -r

If You Need Help

Feel free to ask your questions at the #ffmpeg IRC channel or the ffmpeg-user mailing list.


Also See