Installing HandBrake CLI from Source on CentOS 6

Here at Xelacomp, my job requires me to transcode video from time to time. I like using HandBrake due to it's simplicity for Apple devices, and it's open source nature. I've also been testing CentOS 6 in the lab for the past month or so, so I thought I'd show you how to install the HandBrakeCLI binary to your CentOS 6.0 machine, via the command line.

This tutorial includes compiling the application from source, and grabbing all of the needed dependencies. If you plan compiling HandBrakeCLI for a production machine (say, a web server that transcodes video on-the-fly for HTML5, via a PHP script), you'll want to take a slightly different approach. You'll want to remove all of the tools and libraries used to compile for security reasons.

This tutorial probably also works on RedHat 6 and 6.1, as well as Scientific Linux 6 and 6.1, but neither has been tested...so don't quote me on that.

Anyway, here we go...

First things first, we just want the binary, since HandBrakeCLI doesn't really utilize any other processes or libraries while in use, we'll just copy our compiled binary to a place we can execute from any path (ie /usr/local/bin)

Let's grab our dependencies first. Not everything is need here, but it’s a simple task to grab all of the Development Tools and Development Libraries, so here it is.


yum groupinstall 'Development Tools' 'Development Libraries'

Now we need some application (HandBrakeCLI) specific dependencies.


yum install zlib-devel bzip2-devel dbus-glib-devel libgudev1-devel webkitgtk-devel libnotify-devel gstreamer-devel gstreamer-plugins-base-devel

Now we can CD into our local source directory


cd /usr/local/src

We need one more dependency that HandBrake requires, that’s not in the Base repositories, that dependency is YASM. Let’s grab the source, compile, and install.


wget http://www.tortall.net/projects/yasm/releases/yasm-1.1.0.tar.gz

Untar it...


tar xvzf yasm-1*.tar.gz

hop into the YASM directory

cd yasm-1*

Make sure YASM will compile correctly.

./configure

Compile it

make

Install it

make install

Done with YASM, now on to the good stuff, HandBrake.

Head back to our local source directly.

cd /usr/local/src

From here, we can grab the HandBrake trunk via the Subversion repo.

svn checkout svn://svn.handbrake.fr/HandBrake/trunk hb-trunk

Hop into our newly created folder called hb-trunk

cd hb-trunk

Here’s where we can just run configure, with a couple switches. We don’t want the GTK interface, nor do we need it since this is simply a remote CLI HandBrake machine. With this command, handbrake will actually build a working CLI binary for us in the hb-trunk build directory. Just run:

./configure --launch --disable-gtk

This may take a few minutes, just let it run.

Now we’ve got a binary that works, just copy it into one of your executable binary paths, preferably /usr/local/src, so you know that YOU compiled it, and that it’s not apart of something installed by a package manager.


cd build


cp HandBrakeCLI /usr/local/bin

BAM! You're done. Now, from any path in your system, you should be able to access the HandBrakeCLI binary by just typing HandBrakeCLI along with your input, output, and switches. Have fun HandBraking!

Comments

man i wish it was as easy as you say

got a fresh install of centos 6 - 64bit, been fumbling around to get HandBrake CLI installed, the first sign of trouble was

# yum groupinstall "Development Libraries"
...
Checking for new repos for mirrors
Warning: Group Development Libraries does not exist.
No packages in any requested group available to install or update

Then when i go to build handbrake i get this stuff at the end:


: libtoolize: Consider adding `AC_CONFIG_MACRO_DIR([m4])' to configure.ac and
: libtoolize: rerunning libtoolize, to keep the correct libtool macros in-tree.
: libtoolize: Consider adding `-I m4' to ACLOCAL_AMFLAGS in Makefile.am.
: autoreconf: running: /usr/bin/autoconf --include=m4 --force
: configure.ac:215: error: possibly undefined macro: AC_ADD_CFLAGS
: If this token and others are legitimate, please use m4_pattern_allow.
: See the Autoconf documentation.
: autoreconf: /usr/bin/autoconf failed with exit status: 1
: gmake: *** [contrib/libvorbis/.stamp.configure] Error 1
-------------------------------------------------------------------------------
time end: Sun Oct 23 19:10:13 2011
duration: 7 seconds (7.77s)
result: FAILURE (code 2)
-------------------------------------------------------------------------------
Build is finished!

well...

The Development Libraries group no longer exists on CentOS 6, however, if you do a groupinfo "Development Libraries" on a CentOS 5 host, you will see the list of packages you need to install. So first download and install the EPEL repo:

rpm -ivh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm

Then run the following yum install and you'll get all the packages from the `yum groupinstall "Development Libraries"`


yum install bzip2-devel glibc-devel libtermcap-devel log4cpp ncurses-devel pam-devel readline-devel zlib-devel boost-devel coolkey-devel curl-devel cyrus-sasl-devel db4-devel dbus-devel expat-devel gdbm-devel gmp-devel gpm-devel hesiod-devel krb5-devel kudzu-devel libacl-devel libattr-devel libcap-devel libogg-devel libselinux-devel libusb-devel libuser-devel libvorbis-devel libxml2-devel lockdev-devel newt-devel newt-perl openldap-devel openssl-devel pciutils-devel pcsc-lite-devel python-devel rpm-devel slang-devel sysfsutils xmlsec1-devel xulrunner-devel fipscheck-devel fuse-devel libassuan-devel libhbaapi-devel libksba libksba-devel libpciaccess-devel log4cpp-devel perl-Archive-Zip perl-Convert-ASN1 perl-Crypt-SSLeay perl-DateManip perl-LDAP perl-TimeDate perl-XML-Dumper perl-XML-Grove perl-XML-NamespaceSupport perl-XML-SAX perl-XML-Twig perl-libxml-perl pth pth-devel python-dmidecode python-imaging python-suds sblim-cmpi-dhcp-devel systemtap-sdt-devel tog-pegasus-devel fribidi

HOWEVER, even after getting all the libraries installed, you will still get errors. What I found to be easiest for now is install libdvdcss (I used RPMForge) and then install the handbrake rpm from http://pkgrepo.linuxtech.net/el6/release/x86_64/handbrake-cli-0.9.5-1.el...

rpm -ivh http://pkgrepo.linuxtech.net/el6/release/x86_64/handbrake-cli-0.9.5-1.el6.x86_64.rpm

It seems you're right.

It used to be in the grouplist under yum. I'll have to look into it. I'll make sure the right dependancies are listed and edit the post to reflect the correct commands. For right now, don't use this post, I'll add a comment when it's ready :)