Tuesday, May 3, 2011

Compile x264 on Windows

x264 is a popular open-source H.264 encoder. It comes with the build files for Linux environment. To build project on Windows, the easiest approach is to do this using MingW/MSYS.
All the information is from the link: http://doom10.org/index.php?topic=26.0. However, the procedure in that page can be much simplified as explained in this post.

1. Operating System

Windows 7 Home Premium (64-bit operating system)

2. Software and configuration


2.1. MingW/MSYS

Go to page: http://sourceforge.net/projects/mingw/files/
Simply click "Download mingw-get-inst-20110316.exe (576.1 KB)to download and install software.
When asked to select software features, check "C++ compiler", and "MingW Devloper Toolkit". These are good features, but may not be necessary to compile x264.
Add the path to MingW/bin to system path. For example, I install MingW under "c:\work", so I add "C:\work\MinGW\bin". This is needed in order to search for the libraries to run x264, especially libpthread-2.dll.

2.2. Download yasm


Download yasm of the latest version (version 1.1.0 currently, http://www.tortall.net/projects/yasm/releases/yasm-1.1.0-win32.exe). 
Copy this file to the MinGW\bin folder, and rename it to yasm.exe.


2.3. Download x264 source code

The latest x264 encoder can be downloaded from the following page:
http://www.videolan.org/developers/x264.html

3. Compile


3.1. Open "MingW shell"


3.2. Go to the top-level directory of x264 project

MingW shell will have a linux/unix like directory structure, and it will be at some unfamiliar directory by default. I downloaded x264 to "c:\work\x264", so go to the folder using the following command:
$ cd /c/work/x264
However, if you will not be able to see a folder "/c".

3.3. Run "make" to compile the code


$ make
It will run "./configure", followed by actual "make". If you forget to download yasm, "./configure" command will report such error.