Compile FFmpeg on Scientific Linux

This guide is based on a minimal Scientific Linux 6.3 installation and will install FFmpeg with several external encoding libraries. This guide is kept relatively up to date with FFmpeg development and library sources, and should also work for recent Red Hat Enterprise Linux (RHEL), Fedora and CentOS.

Note: The # indicates that the command should be executed as superuser or root.

Preparation

Remove any existing packages:

# yum erase ffmpeg x264 x264-devel

Get the dependencies:

# yum install autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig wget zlib-devel

Make a source directory:

mkdir ~/ffmpeg-source

Installation

Yasm

Yasm is an assembler used by x264 and FFmpeg.

cd ~/ffmpeg-source
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
# make install

Note: If you do not require certain encoders you may skip the relevant section and then remove the appropriate ./configure option in FFmpeg. For example, if libvorbis is not needed, then skip that section and then remove –enable-libvorbis from the Install FFmpeg section.

x264

H.264 video encoder.

cd ~/ffmpeg-source
git clone git://git.videolan.org/x264
cd x264
./configure --enable-static
make
# make install

libfdk_aac

AAC audio encoder.

cd ~/ffmpeg-source
git clone --depth 1 git://github.com/mstorsjo/fdk-aac.git
cd fdk-aac
autoreconf -fiv
./configure --disable-shared
make
# make install

LAME

MP3 audio encoder.

cd ~/ffmpeg-source
wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
tar xzvf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure --disable-shared --enable-nasm
make
# make install

libogg

Required for libtheora and libvorbis.

cd ~/ffmpeg-source
wget http://downloads.xiph.org/releases/ogg/libogg-1.3.0.tar.gz
tar xzvf libogg-1.3.0.tar.gz
cd libogg-1.3.0
./configure --disable-shared
make
# make install

libtheora

Theora video encoder.

cd ~/ffmpeg-source
wget http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.gz
tar xzvf libtheora-1.1.1.tar.gz
cd libtheora-1.1.1
./configure --disable-shared
make
# make install

libvorbis

Vorbis audio encoder.

cd ~/ffmpeg-source
wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.3.tar.gz
tar xzvf libvorbis-1.3.3.tar.gz
cd libvorbis-1.3.3
./configure --disable-shared
make
# make install

libvpx

VP8 video encoder.

cd ~/ffmpeg-source
git clone http://git.chromium.org/webm/libvpx.git
cd libvpx
./configure
make
# make install

FFmpeg

cd ~/ffmpeg-source
git clone git://source.ffmpeg.org/ffmpeg
cd ffmpeg
./configure --enable-gpl --enable-libfdk_aac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree
make
# make install

Compilation is now complete and ffmpeg should now be ready to use. The rest of this guide shows how to update or remove FFmpeg.

Note: Keep the ffmpeg-source directory and all contents if you intend to update or uninstall as shown below.

Updating x264, libvpx, and FFmpeg

First uninstall x264, libvpx, and FFmpeg:

cd ~/ffmpeg-source/x264
# make uninstall
cd ~/ffmpeg-source/ffmpeg
# make uninstall
cd ~/ffmpeg-source/libvpx
# make uninstall

Update x264

cd ~/ffmpeg-source/x264
make distclean
git pull

Then run ./configuremake, and make install as shown in the Install x264 section.

Update libvpx

cd ~/ffmpeg-source/libvpx
make clean
git pull

Then run ./configuremake, and make install as shown in the Install libvpx section.

Update FFmpeg

cd ~/ffmpeg-source/ffmpeg
make distclean
git pull

Then run ./configuremake, and make install as shown in the Install FFMPEG section.

Reverting changes made by this guide

cd ~/ffmpeg-source/yasm-1.2.0
# make uninstall
cd ../x264
# make uninstall
cd ../lame-3.99.5
# make uninstall
cd ../libogg-1.3.0
# make uninstall
cd ../libvorbis-1.3.3
# make uninstall
cd ../libvorbis-1.3.3
# make uninstall
cd ../libvpx
# make uninstall
cd ../ffmpeg
# make uninstall
rm -rf ~/ffmpeg-source
# yum erase autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig wget zlib-devel

Copy your ssh public key to a server from a machine that doesn’t have ssh-copy-id

cat ~/.ssh/id_rsa.pub | ssh user@machine “mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys”
Copy your ssh public key to a server from a machine that doesn’t have ssh-copy-id

If you use Mac OS X or some other *nix variant that doesn’t come with ssh-copy-id, this one-liner will allow you to add your public key to a remote machine so you can subsequently ssh to that machine without a password.

cat ~/.ssh/id_rsa.pub | ssh <REMOTE> “(cat > tmp.pubkey ; mkdir -p .ssh ; touch .ssh/authorized_keys ; sed -i.bak -e ‘/$(awk ‘{print $NF}’ ~/.ssh/id_rsa.pub)/d’ .ssh/authorized_keys; cat tmp.pubkey >> .ssh/authorized_keys; rm tmp.pubkey)”

This one is a bit more robust — the remote machine may not have an .ssh directory, and it may not have an authorized_keys file, but if it does already, and you want to replace your ssh public key for some reason, this will work in that case as well, without duplicating the entry.
cat ~/.ssh/id_rsa.pub | ssh user@host ‘cat >> ~/.ssh/authorized_keys’
2012-12-08 17:00:47
cat ~/.ssh/id_rsa.pub | ssh tester@10.2.6.10 “mkdir -p ~/.ssh; cat >> ~/.ssh/authorized_keys; chmod 600 ~/.ssh/authorized_keys”

chmod authorized_keys so you don’t get “Authentication refused: bad ownership or modes for file /home/user/.ssh/authorized_keys”

chmod authorized_keys so you don’t get “Authentication refused: bad ownership or modes for file /home/user/.ssh/authorized_keys”

ssh <user>@<host> ‘mkdir -m 700 ~/.ssh; echo ‘ $(< ~/.ssh/id_rsa.pub) ‘ >> ~/.ssh/authorized_keys ; chmod 600 ~/.ssh/authorized_keys’
Creates the .ssh directory on the remote host with proper permissions, if it doesnt exist. Appends your public key to authorized_keys, and verifies it has proper permissions. (if it didnt exist it may have been created with undesireable permissions).

*Korn shell syntax, may or may not work with bash