Compiling x264 (Video Encoder) From Source
From ArchWiki
Contents |
Introduction
H.264/MPEG-4 AVC is a very efficient video encoding standard that was designed to produce higher quality videos at lower bitrates (and hence lower file size) than current options. It is an excellent choice for gaining the best quality possible for a limited size, such as a CD. It has widespread use, inlcuding the BBC and SKY high definition services, Blu-ray Disc and the HD DVD format. The main competition comes from MPEG-4 ASP (the standard that DivX and Xvid are based on) and Microsoft's VC-1.
The open source implementation of H.264 is the x264 codec, which has become very popular. It has come out on top in several tests and competitions, including Doom9's codec shoot-out 2005 and this comparison of encoding options.
If you are planning on encoding video, it is a good idea to compile x264 from the git repository. Because of it's heavy development, using the most up to date version is recommended (although development has slowed somewhat since first inception, there are still ongoing improvements being made). You can use this encoder with mencoder, which can be installed via pacman through the Mplayer package, or it can be compiled from source aswell.
Preparation
- First you have to install git:
pacman -Sy git
- One of the make dependencies is the Yasm assembler:
pacman -Sy yasm
- Then you can download the files from the git repository. This shows how you put the files in the folder ~/x264/, but you can do this in any directory you choose:
cd git clone git://git.videolan.org/x264.git x264
Compilation
Now compilation can begin. Navigate to the folder you placed the files in and compile as root with whatever options you choose:
- Navigate to the git directory you downloaded the files to:
cd /home/USER/x264/
- Configure with your own options before the make command. If you have a more than one CPU, 'enable the pthread' option:
./configure --prefix=/usr/local --enable-pthread make make install
The x264 codec can be uninstalled with the 'make uninstall' command:
cd /home/USER/x264/ su make uninstall
Keeping x264 up to date
- Navigate to the source directory and uninstall x264 (this might not be entirely necessary, but it only takes 5 seconds):
cd /home/USER/x264/ su make uninstall
- Update any files that are out of date using git (unchanged files need not be redownloaded):
git pull
You can then run the compilation commands again and you have an up to date version of the x264 codec.