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

x264 benchmark compilation & installation guide for MidnightBSD 0.4

MidnightBSD Logo

System prerequisites

To compile and install the x264 benchmark on MidnightBSD some basic dependencies need to be fulfilled first. To do that we will use the modified FreeBSD ports system which is called mports on MidnightBSD. By using mports we will be compiling all the necessary packages from source code as the superuser root:

After installation of those packages, you should change the login shell of your user as well as the root user to ensure that the rest of this guide will work for you properly:

After that all users including the superuser should log off and log back in so that the login shell change will take effect.

The benchmarking software itself

To be able to use x264, we need the decoder filters from libavcodec (in short libav) and of course the x264 encoder itself, which will be linked against libav during the course of configuration and compilation. Additionally, we need the benchmark input video, download mirrors for that are available at the bottom of the x264 [benchmark results list]. If you like, you may also use ffmpeg/ffms as a replacement for libav.

For simplicities sake, we shall assume, that the files are now placed in /home/user/x264src/. So on the terminal we switch to that directory and start with libav. Please unpack the archive like tar -xzvf , after which you will see a new libav subfolder. Change to that new folder, so that you can begin to do the necessary modifications and configurations:

Since MidnightBSD has departed quite a bit from its origins since its time as a FreeBSD 6 fork, and since it has also swallowed up some stuff from OpenBSD and NetBSD, the system has become somewhat unique. This is also reflected by the kernel/platform strings that do not show FreeBSD as it is done in PC-BSD, but rather its own identification string MidnightBSD all the way down to the kernel itself. Since the libav build system does not know about a BSD derivative called MidnightBSD, we will need to modify the build environment a bit to make it happen. First thing will be a modification of the configure script, which needs a small addendum, for which you can use your favorite text editor like vi or nano, which you can also get from the mports tree:


Right after that, add the following part for proper MidnightBSD detection:


Also, the system will fail to locate the Posix threading library which is required for multicore/-thread support. This deficiency is easily corrected by telling the system how to link against the proper Posix library. This can be done by setting a simple environment variable. After that step, we can continue to configure the source tree and compile & install libav as root right away. Please note that if you close the terminal after setting the environment variable, you will need to set it again in any newly opened terminal window:

Now libav is installed and we may continue with x264 itself.

First, let's unpack x264, again in folder /home/user/x264src like: tar -xjvf <x264 archive> and change to the newly created x264 subfolder right afterwards.

In x264' case three scripts will require editing, the configure script, then the larger config.guess and last but not least version.sh. We will start with the last one, as version.sh will only need editing of the first line - called the shebang line - so that the system can locate the bash shell with which the script has to be executed:


Replace this first line with:


The same thing is also necessary in the configure script:


Again, replace the first line with this:


Additionally to that, the configure script needs some small parts added to it, look for the following:


Below that part, add this:

    LDFLAGS="$LDFLAGS -lm -lpthread"

Finally, let's take a look at config.guess, where we will need to adapt the operating system detection routines for MidnightBSD:

  UNAME_PROCESSOR=`/usr/bin/uname -p`
  case ${UNAME_PROCESSOR} in
        echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
        echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
  exit ;;

Above that passage, please add the following:

  UNAME_PROCESSOR=`/usr/bin/uname -p`
  case ${UNAME_PROCESSOR} in
        echo x86_64-unknown-midnightbsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
        echo ${UNAME_PROCESSOR}-unknown-midnightbsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
  exit ;;

When that's done, we need to extend some environment variables, because the x264 build system can otherwise not locate libav which is required for the benchmark to operate. After those variables have been (re)set, the configure script can be launched:

You may want to check whether the configure scripts output shows the line "lavf yes" after configuration. x264 will be able to link against libav only if this is the case. If it says "lavf no", you will need to analyze the output in the file config.log to determine what might have gone wrong. Now like on some other systems, the configure script will have created a faulty config.mak that we will need to fix before starting the actual compilation. Look for the following line:

LDFLAGSCLI = -L. -lavformat -lavcodec -lswscale -lavutil -lm -lz -lbz2 -lpthread -lswscale -lavutil

This line which you will find near the end of the config.mak should be replaced with the following string:

LDFLAGSCLI = -L. -L/usr/local/lib -lavformat -lavcodec -lswscale -lavutil -lm -lz -lbz2 -lpthread -lswscale -lavutil

Now we can do the actual compilation and installation:

Now x264 is also installed and ready for operation. The basic functionality of the software can be checked by running x264 --version. If that works, and the binary shows it's been linked against libswscale and libavformat, everything went smoothly. Now you can download the following benchmarking script:

This file launchbenchmark.sh needs to be copied into the subfolder dedicated to the benchmark, if it does not yet exist, please just created it: mkdir -p /home/user/x264benchmark. You should also put the input video elephantsdream_source.264 into that folder.

So now you can basically just launch the benchmark, so just enter the following line after ensuring that the script is executable (chmod +x ./launchbenchmark.sh) and while of course sitting in /home/user/x264benchmark:

That could look somewhat like this (click to enlarge). The result can be read from the terminal after the benchmark is done, the important value here is the one that will be shown besides the string "Real":

MidnightBSD Screenshot

Depending on the host machine that might take some hours, in extreme cases even days, weeks or months. If you have problems with this guide or if there are any additional questions about the x264 benchmark on NetBSD/BSD, please refer to the [according forum thread] and ask there. The forum is german, but if you ask in english, you will still get a reply, at least by me. :)

[Back to the x264 benchmark results list]

[Comment on this guide]