There is a point to this story, but it has temporarily escaped my mind...
Contact Me FaceBook LinkedIn RSS Feed

Install Handbrake on CentOS 5.x

My desktop computer where I do my video encoding with HandBrake is taking about 48 hours to encode each Blu-Ray movies that I've attempted. It takes about 2.5 hours for each hour with DVD movies. I have an HP DL580 server with 4 Dual-Core CPU sockets with hyper-threading enabled providing 16 logical CPUs. I use it as my virtualization server. So I decided to create an 8-CPU/8 GB memory virtual machine to encode my videos. I prefer CentOS 5.x for Server Linux so I set out to document how I installed and configured the virtual to run HandBrake. Moving the video encoding to this server has reduced the encoding time. The same movie that took 48 hours only took 11 hours with the above configuration. I experimented with a 16 CPU/16 GB Memory and the encode time only went down to 10 hours. Using a 4 CPU/8 GB memory increased the encode time up to 32 hours, so I think that I'll leave it in the 8-CPU/8 GB memory configuration for now…

Install the Extra Packages for Enterprise Linux (EPEL) RPM Repository

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm

Download HandBrake Source code

wget http://handbrake.fr/rotation.php?file=HandBrake-0.9.5.tar.bz2
tar jxf HandBrake-0.9.5.tar.bz2

Install packages necessary to build the binary:

yum install libtool jam rpmdevtools bzip2-devel zlib-devel subversion git \
yasm-devel yasm intltool gcc-c++ make

Since CentOS 5.x uses older libraries, you need to update autoconf before building HandBrake. However, it is not advisable to install a newer version on top of the stock 2.59 version, so install it to an alternate location:

wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.61.tar.bz2
tar xjf autoconf-2.61.tar.bz2
cd autoconf-2.61
./configure --prefix=/opt/autoconf
make
make install
cd ..

Finally, build the program:

cd HandBrake-0.9.5
export PATH=/opt/autoconf/bin:$PATH
./configure --disable-gtk
cd build
make

The build process will begin and download more source code and libraries from the web. When it completes, you will have the HandBrakeCLI binary in the HandBrake directory. I copy this file to the OPT directory:

mkdir -p /opt/handbrake
cp HandBrakeCLI /opt/handbrake
chmod +x /opt/handbrake/HandBrakeCLI

After that, I can then use one of the following commands after updating the title (-t) and chapters (-c) parameters:

cat > /opt/handbrake/hd << EOF
#For High Definition:
BDNAME=$1
TITLE=$2

/opt/handbrake/HandBrakeCLI -i /export/input/bd/$BDNAME -t $TITLE \
  -o /export/output/$BDNAME-$TITLE.m4v  -f mp4 -4  --deinterlace="fast" \
  -w 1920 -l 1080 -e x264 -q 20  -a 1,1 -E faac,copy:ac3 \
  -2 -6 dpl2,auto -R Auto,Auto -B 160,auto -D 0.0,0.0 -m --verbose=2 \
  2>&1 | tee /tmp/$BDNAME-$TITLE.log
EOF

cat > /opt/handbrake/sd << EOF
#For Standard Definition:
DVDNAME=$1
TITLE=$2

/opt/handbrake/HandBrakeCLI -i /export/input/dvd/$DVDNAME -t $TITLE \
  -o /export/output/$DVDNAME-$TITLE.m4v  -f mp4 -4  --deinterlace="fast" \
  -w 720 -l 400 -e x264 -q 20 --pfr  -a 1,1 -E faac,copy:ac3 \
  -2 -6 dpl2,auto -R Auto,Auto -B 160,auto -D 0.0,0.0 -m --verbose=2 \
  2>&1 | tee /tmp/$DVDNAME-$TITLE.log
EOF

cat > /opt/handbrake/scan << EOF
#Scan Titles
if [ -d "/export/input/bd/$1" ]
then
  /opt/handbrake/HandBrakeCLI -i /export/input/bd/$1 -t 0 -v 0 2>&1| \
    tee /tmp/$1-scan.log
fi

if [ -d "/export/input/dvd/$1" ]
then
  /opt/handbrake/HandBrakeCLI -i /export/input/dvd/$1 -t 0 -v 0 2>&1| \
    tee /tmp/$1-scan.log
fi

echo
echo
echo
echo
echo

cat /tmp/$1-scan.log | grep -B 3 "+ duration" | egrep "(Feature|duration|title)"
EOF

chmod 755 /opt/handbrake/hd
chmod 755 /opt/handbrake/sd
chmod 755 /opt/handbrake/scan

To make this server accessable via the network so that I can copy files back and forth, I install SAMBA and configure it this way:

yum install samba
mkdir -p /export/input/bd
mkdir -p /export/input/dvd
mkdir -p /export/output
chown nobody /export/input/dvd /export/input/bd /export/output
chgrp nobody /export/input/dvd /export/input/bd /export/output

cat > /etc/samba/smb.conf << EOF
#======================= Global Settings =====================================

[global]
        netbios name = HANDBRAKE
        workgroup = HOME
        os level = 20
        winbind enable local accounts = no
        security = share
        preferred master = no
        passdb backend = tdbsam

#============================ Share Definitions ==============================
[InputDVD]
        wide links = no
        writeable = yes
        public = yes
        path = /export/input/dvd
        public = yes

[InputBD]
        wide links = no
        writeable = yes
        public = yes
        path = /export/input/bd
        public = yes

[Output]
        wide links = no
        writeable = yes
        public = yes
        path = /export/output
        public = yes
EOF
/sbin/iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT
service iptables save

chkconfig smb on
service smb start
 
linux/handbrake_centos.txt · Last modified: 2011/04/02 18:05 by julian@julianscorner.com
 
Copyright © 2011 by Julian Easterling. SOME RIGHTS RESERVED.

Creative Commons License
Except where otherwise noted, content on this site is
licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.


All of the opinions expressed on this website are those of Julian Easterling and
do not represent the views of any of my current and previous clients or employers in any way.

If you notice an error on the site or content that has not been properly attributed, bring
it to my attention using the contact page and I will endeavor to fix it as soon as I can.

I accept no responsibility or liability for any damages incurred by following any of
my advice or by using any of the information on my site or of those sites that I link to.