One of the biggest benefits, at least to me, of using x264 under Linux is because the sole 64-bit capable machine I have access to only has a 32-bit version of Windows on it. For people in this kind of situation, Linux is a good way to use the full 64-bit power of the computer while not needing to buy another OS (unless you go with Red Hat, et al). And the difference in encoding time between 32- and 64-bit versions of x264 can be pretty dramatic.
The best approach, in my opinion, would be to set this up by distribution (and version, if you feel the need, and the process differs so greatly). For instance:
Ubuntu 8.10 [Intrepid Ibex]:
0. This process uses GCC 4.3.2 to do the compiling. I don't know how this might change under a different version of GCC. Just be aware of this fact. Also be aware that this may require that you have the Universe and/or Multiverse repositories open.
1. Install the necessary dependencies (you can do this in Synaptic if you want, but I'm going to use the Terminal commands for ease of doing all this in one go). You only need to do this once.
Code: Select all
sudo apt-get update
sudo apt-get install build-essential git-core checkinstall yasm texi2html
Code: Select all
wget http://www.zlib.net/zlib-1.2.3.tar.gz
tar -zxf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure
make
sudo make install
Code: Select all
wget http://superb-east.dl.sourceforge.net/sourceforge/gpac/gpac-0.4.5.tar.gz
wget http://voxel.dl.sourceforge.net/sourceforge/gpac/gpac_extra_libs-0.4.5.tar.gz
tar -zxf gpac-0.4.5.tar.gz
tar -zxf gpac_extra_libs-0.4.5.tar.gz
cd gpac_extra_libs
cp -r * ../gpac/extra_lib
cd ../gpac
chmod +x configure
./configure --disable-opengl --use-js=no --use-ft=no --use-jpeg=no --use-png=no --use-faad=no --use-mad=no --use-xvid=no --use-ffmpeg=no --use-ogg=no --use-vorbis=no --use-theora=no --use-openjpeg=no
make lib
make apps
sudo make install-lib
sudo make install
sudo cp bin/gcc/libgpac.so /usr/lib
4. Download, compile, and install x264. If you want to use some of the common patches* (see links below), download the diff files and copy them to the x264 directory (the one git creates). Then replace file.diff in line #4 to the actual name of the patch and repeat for as many of the patches as necessary.
Code: Select all
cd ~/
git clone git://git.videolan.org/x264.git
cd x264
patch -p1 <file.diff
./configure --enable-shared --extra-cflags="-march=pentium3"
make
sudo checkinstall --fstrans=no --install=yes --pkgname=x264 --pkgversion "1:0.svn-$(grep X264_VERSION config.h | cut -d' ' -f 4)-0.0ubuntu1" --default
sudo ldconfig
http://gcc.gnu.org/onlinedocs/gcc-4.3.2 ... 64-Options
*Patches:
x264_win_zone_parse_fix_05.diff:
http://skystrife.com/x264/
x264_hrd_pulldown.10_interlace.diff:
http://forum.doom9.org/showpost.php?p=1 ... count=1726
Keep up with patches here:
http://forum.doom9.org/showthread.php?t=130364
Now then, as far as using x264 is concerned, I'm going to assume you already know how to use x264 from the command line. If necessary, fire up MeGUI or Zarx264gui under Windows, make them expose the command line options, copy those down, and then bring that text file over to your Linux install.
What I'm going to explain instead is how to feed x264 your video so that you don't need to bother with trying to get raw video encoded correctly (which can be a real bitch - see my second post for a quick fix of sorts).
Linux builds of x264 don't support AVI or AviSynth input, because of fairly obvious reasons (lack of VFW and subsequently, lack of a *working* AviSynth 3.0). This presents a challenge, because otherwise you would need to output your video in raw format and then give this to x264 - however, doing that eliminates both the framerate and resolution information from the file, and requires you to specify this in x264's options. Quite frankly, this can be annoying. But there is a solution. Let's go into more detail below.
You'll want to make sure that mplayer is installed first. The best option for this is to go to Applications->Add/Remove Programs, and find SMPlayer (which I prefer because of the GUI; if you want standard mplayer, you can get it from Synaptic or something). Install it.
The video should be in a lossless format that mplayer can open. This could be any number of things; personally, I use YV12-mode HuffYUV (ffvhuff, if you wanna be technical about it). Uncompressed YV12 would be fine as well.
Now that that's done, we're all set. What's going to happen is that we'll make a named pipe using mkfifo, then have mplayer open the video, and pipe it over to x264.
Code: Select all
mkfifo input.y4m
x264 input.y4m <options> | mplayer -nosound -vo yuv4mpeg:file=input.y4m inputfile
Code: Select all
mkfifo input.y4m
x264 input.y4m --crf 18.0 --ref 16 --mixed-refs --no-fast-pskip --bframes 16 --b-adapt 2 --b-pyramid --weightb --direct auto --deblock 1:1 --subme 9 --trellis 2 --partitions all --8x8dct --scenecut 100 --threads auto --thread-input --sar 1:1 --aud --progress --no-dct-decimate --no-psnr --no-ssim --output "dawn.mp4" | mplayer -nosound -vo yuv4mpeg:file=input.y4m dawn.avi
Most of this information is cobbled together from various other sources (primarily the Doom9 forums and Ubuntu forums) I found online or asked about directly. If you want to customize your builds with special flags then you can check with ./configure --help on a per-program basis.