ThorneLabs

Linux Install and Encode with HandBrake on the Command Line

• Updated May 5, 2020


HandBrake is a great tool to rip DVDs and convert them to a particular format.

The following steps will go through how to install HandBrake from source on Fedora and Enterprise Linux based distributions.

Repository Packages Required

I encountered make compile problems without intltool and gcc-c++.

yum install libdvdread libdvdnav intltool gcc-c++ subversion

The doc/BUILD-Linux file from the source directory states the following packages may need to be installed:

yum install yasm zlib-devel bzip2-devel libogg-devel libtheora-devel \
libvorbis-devel libsamplerate-devel libxml2-devel fribidi-devel \
freetype-devel fontconfig-devel libass-devel dbus-glib-devel \
libgudev1-devel webkitgtk-devel libnotify-devel \
gstreamer-devel gstreamer-plugins-base-devel

libdvdcss Source Install

libdvdcss is required to decrypt the DVD encryption so HandBrake can access the media files.

Clone the source code:

git clone git://git.videolan.org/libdvdcss

cd libdvdcss

Configure, make, and make install the binary:

./configure
make
sudo make install

Create links to the shared libraries:

echo '/usr/local/lib' > /etc/ld.so.conf.d/libdvdcss.conf
ldconfig -v

HandBrake Source Install

Checkout HandBrake source code:

svn co svn://svn.handbrake.fr/HandBrake/trunk handbrake-svn

cd handbrake-svn

Configure without GTK:

./configure --disable-gtk

Fedora 19 needs the following line removed for make to work:

sed -i -e ā€˜/gets is a security/dā€™ ./build/contrib/m4/m4-1.4.16/lib/stdio.h

make the binary:

cd ./build
gmake

Install the binary:

sudo make install

Using HandBrake Presets

The following preset is from HandBrake’s Built-In Presets.

High Profile H.264 With All the Bells and Whistles

HandBrakeCLI -i /mnt/dvd/VIDEO_TS/ -o movie.mp4 -e x264 -q 20.0 -a 1,1 -E faac,copy:ac3 -B 256,256 \
-6 dpl2,auto -R Auto,Auto -D 0.0,0.0 -f mp4 --detelecine --decomb --loose-anamorphic -m \
-x b-adapt=2:rc-lookahead=50

Command breakdown:

HandBrakeCLI
    -i /mnt/dvd/VIDEO_TS/           # Input device/folder
    -o movie.mp4                    # Output filename
    -e x264                         # Video encoder
    -q 20.0                         # Video quality
    -a 1,1                          # Audio tracks, separated by commas
    -E faac,copy:ac3                # Audio encoder, copy used for passthrough
    -B 256,256                      # Audio bitrate, separated by commas for multi-tracks
    -6 dpl2,auto                    # Surround sound downmixing
    -R Auto,Auto                    # Audio samplerate
    -D 0.0,0.0                      # Extra dynamic range compression to the audio
    -f mp4                          # Output format
    --detelecine                    # Detelecine (ivtc) video with pullup filter
    --decomb                        # Selectively deinterlaces when it detects combing
    --loose-anamorphic              # Store pixel aspect ratio with specified width
    -m                              # Add chapter markers (mp4 and mkv output formats only)
    -x b-adapt=2:rc-lookahead=50    # Specify advanced x264 options

References