Building HandBrake for Windows

Command line interface and LibHB

Building the HandBrake CLI and LibHB (hb.dll) for Windows requires Linux and a recent MinGW-w64 toolchain. Ubuntu 18.04 LTS (Bionic Beaver) and 16.04 LTS (Xenial Xerus) are recommended; other distros may work as well. In all cases, we recommend you build the MinGW-w64 toolchain using our instructions and the included script, as most packaged versions have issues that can produce non-functioning builds.

The following instructions are for Ubuntu 18.04 LTS (Bionic Beaver) and 16.04 LTS (Xenial Xerus).

Dependencies:

Additional dependencies not available in the Ubuntu 16.04 LTS base repository:

Additional MinGW-w64 toolchain dependencies:

Install dependencies.

sudo apt-get update
sudo apt-get install automake autoconf build-essential cmake curl gcc git intltool libtool libtool-bin m4 make patch pkg-config python tar yasm zlib1g-dev

For Ubuntu 18.04 (Bionic Beaver), install nasm from the base repository.

sudo apt-get install nasm

For Ubuntu 16.04 LTS (Xenial Xerus), the nasm version in the base repository is too old, so compile from source.

curl -O https://www.nasm.us/pub/nasm/releasebuilds/2.13.02/nasm-2.13.02.tar.bz2
tar -xf nasm-2.13.02.tar.bz2
cd nasm-2.13.02
./configure --prefix=/usr/local --enable-sections --enable-lto
make -j$(nproc)
sudo make install
source ~/.bashrc
cd ..

Install the additional dependencies required to build the MinGW-w64 toolchain.

sudo apt-get install bison bzip2 flex g++ gzip pax

Clone the HandBrake repository.

git clone https://github.com/HandBrake/HandBrake.git && cd HandBrake

Build the MinGW-w64 toolchain using the included script, where username is your user name. Feel free to choose a different output path, if desired.

scripts/mingw-w64-build x86_64 /home/username/toolchains/

This process will take a few minutes, then provide you with instructions for adding the resulting binaries location to your environment’s PATH. Do this now.

Build HandBrake. For higher quality audio, enable the FDK AAC encoder by appending --enable-fdk-aac. Builds including FDK AAC must be for personal use only and may not be distributed.1

./configure --cross=x86_64-w64-mingw32 --enable-qsv --launch-jobs=$(nproc) --launch

When complete, you will find HandBrakeCLI.exe in the build directory and hb.dll in build/libhb.

To start over, simply remove the build directory.

rm -rf build

Graphical interface

The following tools are required to build and run the GUI.

Clone https://github.com/HandBrake/HandBrake.git using your git client.

Source code for the GUI resides in the win\CS folder and the solution file is named HandBrake.sln. Make sure HandBrakeWPF is set as the startup project in the Solution Explorer by right-clicking the name and selecting “Set as startup project”.

To build the GUI, select Build Solution from the Build menu.

When complete, locate the output folder where HandBrake.exe is created (typically in win\CS\HandBrakeWPF\bin\..., depending on the selected build profile). Copy hb.dll to this folder. This completes the build process.


  1. The FDK AAC encoder is only provided in source code form and is not fully compatible with the GNU General Public License Version 2 used by HandBrake. Builds including FDK AAC must be for personal use only and may not be distributed. Do not share the build product with others.