image

Installing FFmpeg on headless ubuntu 12.04+

[<Back>] [<Edit>]

Installing FFmpeg on headless ubuntu 12.04+

This guide supports Ubuntu 12.10 (Quantal Quetzal), Ubuntu 12.04 (Precise Pangolin), and Ubuntu 11.10 (Oneiric Ocelot). Separate guides are available for Ubuntu 10.04 (Lucid Lynx) and Ubuntu 8.04 (Hardy Heron). This guide will provide the latest FFmpeg code and enable several external encoding and decoding libraries: fdk-aac (AAC encoder), libfaac (AAC encoder), libmp3lame (MP3 encoder), libopencore-amr (AMR encoder/decoder), librtmp (for additional RTMP protocols), libtheora (Theora encoder), libvorbis (Vorbis encoder), libvpx (VP8 encoder/decoder), and libx264 (H.264 encoder). These are optional and may be omitted if desired. This guide will also install many filters, including the subtitles filter for hardcoding subtitles.

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

Preparation

Remove any existing packages:

sudo apt-get remove ffmpeg x264 libav-tools libvpx-dev libx264-dev yasm
  

Note: The multiverse repository must be enabled in order to install the libfaac-dev package.

Get the dependencies (Ubuntu Desktop users):

sudo apt-get update
sudo apt-get -y install autoconf automake 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 libspeex-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev \
  libx11-dev libxext-dev libxfixes-dev pkg-config texi2html zlib1g-dev
  

Get the dependencies (Ubuntu Server or headless users):

sudo apt-get update
sudo apt-get -y install autoconf automake build-essential checkinstall git libass-dev libfaac-dev \
  libgpac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev librtmp-dev libspeex-dev \
  libtheora-dev libtool libvorbis-dev pkg-config texi2html zlib1g-dev
  

Installation

Yasm

Yasm is an assembler and is recommended for x264 and FFmpeg.

cd
wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
tar xzvf yasm-1.2.0.tar.gz
cd yasm-1.2.0
./configure
make
sudo checkinstall --pkgname=yasm --pkgversion="1.2.0" --backup=no \
  --deldoc=yes --fstrans=no --default
  

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.git
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
  

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

libvpx

VP8 video encoder and decoder.

cd
git clone --depth 1 http://git.chromium.org/webm/libvpx.git
cd libvpx
./configure --disable-examples --disable-unit-tests
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

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

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-libspeex --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
  
 

Finish

Installation is now complete and FFmpeg is now ready for use. You can keep the x264, libvpx, and ffmpeg directories in your home directory if you plan on updating later.


Optional Installation

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. When converting files with ffmpeg you can add -movflags faststart to have the same effect.

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
  

Updating FFmpeg

Development of FFmpeg and x264 is active and an occasional update can give you new features and bug fixes. First, remove some packages and then update the dependencies:

sudo apt-get -y remove ffmpeg x264 libx264-dev libvpx-dev
sudo apt-get update
sudo apt-get -y install autoconf automake 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 libspeex-dev libtheora-dev libva-dev libvdpau-dev libvorbis-dev \
  libx11-dev libxext-dev libxfixes-dev texi2html yasm zlib1g-dev
  

x264

cd ~/x264
make distclean
git pull
  

Now run ./configure, make, and checkinstall

fdk-aac

cd ~/fdk-aac
make distclean
git pull
  

Now run ./configure, make, and checkinstall

libvpx

cd ~/libvpx
make clean
git pull
  

Now run ./configure, make, and checkinstall

opus

cd ~/opus
make distclean
git pull
  

Now run ./configure, make, and checkinstall

FFmpeg

cd ~/ffmpeg
make distclean
git pull
  

Now run ./configure, make, and checkinstall


Reverting Changes Made by This Guide

To remove FFmpeg, x264, and other packages installed for this guide:

sudo apt-get autoremove autoconf automake build-essential checkinstall fdk-aac ffmpeg git libass-dev \
  libfaac-dev libgpac-dev libjack-jackd2-dev libmp3lame-dev librtmp-dev libsdl1.2-dev libspeex-dev \
  libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libvpx libx11-dev libxfixes-dev \
  opus pkg-config qt-faststart texi2html x264 yasm zlib1g-dev
  

Lastly, delete the x264, fdk-aac, libvpx, opus, and ffmpeg directories in your home folder.




By: https://ffmpeg.org/trac/ffmpeg/wiki/UbuntuCompilationGuide




 
Instagram Stats
pinoy
my Kung Fu