Voodooalert+x264 Logo
US+UK Flagge DE+AT Flagge
Change language:

x264 benchmark compilation & installation guide for Linux

Linux Logo

System prerequisites

To be able to compile and install the x264 benchmark on Linux, a set of basic software needs to be present on the system. That includes:

Typically those tools are included with or can be installed from your Linux distributions software repository, like with yum install gcc on RedHat derivatives or aptitude install build-essential on Debian Linux. Where you don't have a yasm assembler, you may usually easily compile it from source code, ./configure && make && make install is usually sufficient, as long as the GCC build toolchain is already present.

If you don't have any access to those tools, maybe because you're on an embedded system, you could try your luck with an ELDK (Embedded Linux Development Kit), which is available for some ARM, PowerPC and MIPS microarchitectures:

To use an ELDK on an embedded system, you'll need a bit more than just the ELDK itself, but that shall be discussed further down. For now, we'll deal with a regular Linux installation.

The benchmarking software itself

To be able to use x264, we'll need the decoding filters of libavcodec (in short libav) and the x264 encoder itself, which is being linked against libav during compilation. Additionally, the benchmarks input video will also be required, download mirrors for that are linked at the bottom of the [benchmarks results list]. As a replacement for libav you may also use ffmpeg/ffms, if preferred for any reason.

For simplicities sake, we'll assume that you have the files in /home/user/x264src/. Additionally we'll assume that you have a rather modern system available and with yasm installed. On the shell, we'll navigate to said folder and start with libav. The archive at hand is easily unpacked with tar -xzvf <filename.tgz>, after which you'll see a libav folder. Go to that folder, and run the following commands as root (If you do not want to run compilers and linkers as root, you can do the last step only as root). The --prefix option is optional here. Should you be running a non-LSB/POSIX-compliant system (rare!), you might need to specify a different path here like / or maybe /usr:

Now libav is installed. We can now continue to build and link x264 itself. Please unpack the x264 source code by running tar -xjvf last_x264.tar.bz2 and then go to the newly created x264 folder. Similar to before. Should you be running a non-LSB/POSIX-compliant system (rare!), you might need to specify a different path here, like / or /usr. If you really need to do that, you'd also need to edit the config.mak after running configure, changing the directive LDFLAGSCLI = -L. to something like LDFLAGSCLI = -L. -L/lib or LDFLAGSCLI = -L. -L/usr/lib or something similar right at the end of the file:

Now you can verify the functionality by running x264 --version. If that works, and the binary shows that it's been linked against libswscale and libavformat, then everything went smoothly. If you indeed have a system where no assembler code paths exist for, e.g. a DEC Alpha or a very old Intel x86 like a Pentium MMX, you may need to specify --disable-asm as an option for both configure scripts. Installing yasm is entirely unnecessary in such a case. Now you can download the benchmarking script launchbenchmark.sh here:

Now copy that file launchbenchmark.sh to a new subfolder, which will be used for the benchmark itself. If necessary, create it: mkdir -p /home/user/x264benchmark and chmod +x the script. Also put the input video file elephantsdream_source.264 in there.
Now the benchmark can be run, just enter the following line while sitting in the folder /home/user/x264benchmark:

When running, it may look somewhat like this:

Linux Screenshot

After completion, just read the "Real" value from the terminal.

Depending on the machine this may take hours, in extreme cases days or even weeks or months. If you're doing this remotely via SSH or something similar, you may want to think about using a screen session, that can be safely pushed to the background, so you don't have to keep an open interactive login shell all the time. Before using screen, please read the documentation first: man screen.

Embedded systems & ELDK

If you - like mentioned previously - had to use an ELDK, you should be able to handle chroot jails to use it properly. Not all machines are fit for an ELDK, some need to be cracked first (routers, NAS boxes), others just don't have enough storage for it, but in some cases, an ELDK can help to equip a compiler- and package manager-less system with the proper toolchains.

To use chroot properly, just extract the chosen ELDK on the target system, we'll assume the target folder /eldk here. After that you need to prepare a few more things, before you may use the ELDK in a proper way. The /dev and /proc subsystems need to be set up, like shown below:

After that, you can enter your chroot jail by running chroot /eldk as root. Somewhere within that /eldk folder you should also have your libav and x264 source code. For some embedded systems this alone won't be enough though. Some have no swap space configured, which can break the benchmark if there is too little memory available. So you might need to set up a swap file, like shown below, where we start to do that outside of the chroot jail, and then switch to the inside to complete the operation. In this example we will create a 1GB swap file:

When your embedded system is all prepared, you may want to compile and install the yasm assembler within the chroot jail (if necessary, e.g. if you have an ARM CPU with NEON), and after that just compile and run libav+x264 as shown previously.

[Back to the x264 benchmark results list]

[Comment on this guide]