| Version 3 (modified by llogan, 14 months ago) (diff) |
|---|
Compile FFmpeg on Ubuntu
This guide supports Ubuntu Precise Pangolin 12.04, Ubuntu Oneiric Ocelot 11.10, Ubuntu Natty Narwhal 11.04, and Ubuntu Maverick Meerkat 10.10.
Note: Copy and paste the whole code box for each step.
Preparation
Remove any existing packages:
sudo apt-get remove ffmpeg x264 libvpx-dev libx264-dev
Get the dependencies:
sudo apt-get update sudo apt-get -y install build-essential checkinstall git libfaac-dev libjack-jackd2-dev \ libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev \ libva-dev libvdpau-dev libvorbis-dev libx11-dev libxfixes-dev texi2html yasm zlib1g-dev
Installation
x264
H.264 video encoder. The following commands will get the current source files, compile, and install x264.
cd
git clone 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
Note: See using snapshots if you are having connection issues with the Git server.
libvpx
VP8 video encoder and decoder.
cd
git clone 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
FFmpeg
cd
git clone --depth 1 git://source.ffmpeg.org/ffmpeg
cd ffmpeg
./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb \
--enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 \
--enable-nonfree --enable-version3 --enable-x11grab
make
sudo checkinstall --pkgname=ffmpeg --pkgversion="5:$(date +%Y%m%d%H%M)-git" --backup=no \
--deldoc=yes --fstrans=no --default
hash x264 ffmpeg ffplay ffprobe
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. See Updating FFmpeg below for more details. Some optional steps are next followed by instructions on updating FFmpeg and finally instructions on reverting all changes made by this guide.
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.
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. See a more detailed explanation of what this means.
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 build-essential git checkinstall yasm texi2html \ libfaac-dev libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev \ libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libva-dev libvdpau-dev \ libvorbis-dev libx11-dev libxfixes-dev zlib1g-dev
x264
cd ~/x264 make distclean git pull
Now run ./configure, make, and make install as shown in the Install x264 section.
libvpx
cd ~/libvpx make clean git pull
Now run ./configure, make, and make install as shown in the Install libvpx section.
FFmpeg
cd ~/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 other packages added for this guide:
sudo apt-get -y autoremove x264 ffmpeg qt-faststart build-essential git checkinstall \ yasm texi2html libfaac-dev libjack-jackd2-dev libmp3lame-dev libsdl1.2-dev libtheora-dev \ libva-dev libvdpau-dev libvorbis-dev libvpx libx11-dev libxfixes-dev zlib1g-dev
Lastly, delete the x264, libvpx, and ffmpeg directories in your home folder.
If You Need Help
Feel free to ask your questions at the #ffmpeg IRC channel or the ffmpeg-user mailing list.


