Handbrake Compile

Compiling HandBrake on Linux

These instructions are for building the *released* version of HandBrake. If you are building SVN, see the instructions in the source tree doc/BUILD-Linux.

Install Dependencies

What you need depends on your distribution.

The GTK UI introduces some significant extra build requirements. If you intend to disable building the GUI with `configure –disable-gtk’ you will not need many of these packages installed.

For Ubuntu you need:

  • subversion (cli/gui)
  • yasm (cli/gui)
  • build-essential (cli/gui)
  • autoconf (cli/gui)
  • libtool (cli/gui)
  • zlib1g-dev (cli/gui)
  • libbz2-dev (cli/gui)
  • libxml2-dev (cli/gui)
  • libogg-dev (cli/gui)
  • libtheora-dev (cli/gui)
  • libvorbis-dev (cli/gui)
  • libsamplerate-dev (cli/gui)
  • libfribidi-dev (cli/gui)
  • libfreetype6-dev (cli/gui)
  • libfontconfig1-dev (cli/gui)
  • libass-dev (cli/gui)
  • intltool (gui)
  • libglib2.0-dev (gui)
  • libdbus-glib-1-dev (gui)
  • libgtk2.0-dev (gui)
  • libgudev-1.0-dev (gui)
  • libwebkit-dev (gui)
  • libnotify-dev (gui)
  • libgstreamer0.10-dev (gui)
  • libgstreamer-plugins-base0.10-dev (gui)
  • libappindicator-dev (gui)

To install these packages:

sudo apt-get install subversion yasm build-essential autoconf libtool \
zlib1g-dev libbz2-dev libogg-dev libtheora-dev libvorbis-dev \
libsamplerate-dev libxml2-dev libfribidi-dev libfreetype6-dev \
libfontconfig1-dev libass-dev intltool libglib2.0-dev libdbus-glib-1-dev \
libgtk2.0-dev libgudev-1.0-dev libwebkit-dev libnotify-dev \
libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libappindicator-dev

For Fedora you need the following package groups:

  • Development Tools
  • Development Libraries
  • X Software Development (gui)
  • GNOME Software Development (gui)

To install these package groups:

sudo yum groupinstall "Development Tools" "Development Libraries" \
"X Software Development" "GNOME Software Development"

Also for Fedora you need the following additional packages:

  • yasm (cli/gui)
  • zlib-devel (cli/gui)
  • bzip2-devel (cli/gui)
  • libogg-devel (cli/gui)
  • libtheora-devel (cli/gui)
  • libvorbis-devel (cli/gui)
  • libsamplerate-devel (cli/gui)
  • libxml2-devel (cli/gui)
  • fribidi-devel (cli/gui)
  • freetype-devel (cli/gui)
  • fontconfig-devel (cli/gui)
  • libass-devel (cli/gui)
  • dbus-glib-devel (gui)
  • libgudev1-devel (gui)
  • webkitgtk-devel (gui)
  • libnotify-devel (gui)
  • gstreamer-devel (gui)
  • gstreamer-plugins-base-devel (gui)

To install these packages:

sudo 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

QuickStart Build Instructions

  • apt-get -y install libmp3lame-dev lame libjansson4 libjansson-dev x264 libx264-142 libx264-dev libgtk-3-dev
svn checkout svn://svn.handbrake.fr/HandBrake/trunk hb-trunk
cd hb-trunk
./configure --launch

Or if you want HandBrakeCLI only:

svn checkout svn://svn.handbrake.fr/HandBrake/trunk hb-trunk
cd hb-trunk
./configure --launch --disable-gtk

If there are errors at this stage, you’re missing some prerequisite.

Assuming that all goes well, you should now have a HandBrakeCLI binary in the build directory and a ghb binary in the build/gtk/src directory. You can execute it in place or copy it wherever you like.

You may also want to install, run:

cd build
sudo make install

This will install the binary and add a HandBrake option to your “Applications->Sound & Video” menu.

Full Compiling Guide

This is just a simple quick-start guide. For the real meat and potatoes, see the latest Linux build documentation. Topics covered there include:

  • Running configuration and build commands on subsequent compiles (hint, do it from the build/ directory, not the trunk)
  • Configuring options like 64-bit builds and cross-compilation
  • Cleaning build files
  • Tweaking contrib libraries

HandBrake CLI

Syntax: HandBrakeCLI [options] -i -o

### General Handbrake Options————————————————

-h, –help Print help
-u, –update Check for updates and exit
-v, –verbose <#> Be verbose (optional argument: logging level)
-C, –cpu Set CPU count (default: autodetected)
-Z. –preset Use a built-in preset. Capitalization matters, and if the preset name has spaces, surround it with double quotation marks
-z, –preset-list See a list of available built-in presets
–dvdnav Use dvdnav (Experimental)

### Source Options———————————————————–

-i, –input Set input device
-t, –title Select a title to encode (0 to scan only, default: 1)
-L, –longest Select the longest title
-c, –chapters Select chapters (e.g. “1-3” for chapters 1 to 3, or “3” for chapter 3 only, default: all chapters)
–angle Select the DVD angle
–previews <#:B> Select how many preview images are generated (max 30), and whether or not they’re stored to disk (0 or 1). (default: 10:0)
–start-at-preview <#> Start encoding at a given preview.
–stop-at Stop encoding at a given frame, duration (in seconds), or pts (on a 90kHz clock)
### Destination Options——————————————————

-o, –output Set output file name
-f, –format Set output format (mp4/mkv, default: autodetected from file name)
-m, –markers Add chapter markers (mp4 and mkv output formats only)
-4, –large-file Use 64-bit mp4 files that can hold more than 4 GB. Note: Breaks iPod, PS3 compatibility.
-O, –optimize Optimize mp4 files for HTTP streaming
-I, –ipod-atom Mark mp4 files so 5.5G iPods will accept them

### Video Options————————————————————

-e, –encoder Set video library encoder (ffmpeg,x264,theora) (default: ffmpeg)
-x, –x264opts Specify advanced x264 options in the same style as mencoder:
option1=value1:option2=value2
-q, –quality Set video quality (0.0..1.0)
-Q, –cqp Use with -q for CQP instead of CRF
-S, –size Set target size
-b, –vb Set video bitrate (default: 1000)
-2, –two-pass Use two-pass mode
-T, –turbo When using 2-pass use the turbo options on the first pass to improve speed
(only works with x264, affects PSNR by about 0.05dB, and increases first pass speed two to four times)
-r, –rate Set video framerate (5/10/12/15/23.976/24/25/29.97)
Be aware that not specifying a framerate lets HandBrake preserve a source’s time stamps,
potentially creating variable framerate video
–vfr, –cfr, –pfr Select variable, constant or peak-limited frame rate control. VFR preserves the source timing. CFR makes the output constant rate at the rate given by the -r flag (or the source’s
average rate if no -r is given). PFR doesn’t allow the rate to go over the rate specified with the -r flag but won’t change the source timing if it’s below that rate. If none of these flags are given, the default is –cfr when -r is given and -vfr otherwise

### Audio Options———————————————————–

-a, –audio Select audio track(s), separated by commas More than one output track can be used for one
input. (“none” for no audio, “1,2,3” for multiple tracks, default: first one)
-E, –aencoder Audio encoder(s) (faac/lame/vorbis/ac3/dts) ac3 and dts meaning passthrough Separated by commas for more than one audio track. (default: guessed)
-B, –ab Set audio bitrate(s) (default: 160) Separated by commas for more than one audio track.
-6, –mixdown Format(s) for surround sound downmixing
Separated by commas for more than one audio track. (mono/stereo/dpl1/dpl2/6ch, default: dpl2)
-R, –arate Set audio samplerate(s) (22.05/24/32/44.1/48 kHz) Separated by commas for more than one audio track.
-D, –drc Apply extra dynamic range compression to the audio, making soft sounds louder. Range is 1.0 to 4.0 (too loud), with 1.5 – 2.5 being a useful range. Separated by commas for more than one audio track.
-A, –aname Audio track name(s), Separated by commas for more than one audio track.

### Picture Settings———————————————————

-w, –width Set picture width
-l, –height Set picture height
–crop Set cropping values (default: autocrop)
-Y, –maxHeight <#> Set maximum height
-X, –maxWidth <#> Set maximum width
–strict-anamorphic Store pixel aspect ratio in video stream
–loose-anamorphic Store pixel aspect ratio with specified width
–custom-anamorphic Store pixel aspect ratio in video stream and directly control all parameters.
–display-width Set the width to scale the actual pixels to
at playback, for custom anamorphic.
–keep-display-aspect Preserve the source’s display aspect ratio when using custom anamorphic
–pixel-aspect Set a custom pixel aspect for custom anamorphic
(–display-width and –pixel-aspect are mutually exclusive and the former will override the latter)
–itu-par Use wider, ITU pixel aspect values for loose and custom anamorphic, useful with underscanned sources
–modulus Set the number you want the scaled pixel dimensions
to divide cleanly by, for loose and custom anamorphic modes (default: 16)
-M –color-matrix Set the color space signaled by the output
<601 or 709> (Bt.601 is mostly for SD content, Bt.709 for HD,
default: set by resolution)

### Filters———————————————————

-d, –deinterlace Deinterlace video with yadif/mcdeint filter
(default 0:-1:-1:1)
or

-5, –decomb Selectively deinterlaces when it detects combing
(default: 1:2:6:9:80:16:16)
-9, –detelecine Detelecine (ivtc) video with pullup filter
Note: this filter drops duplicate frames to
restore the pre-telecine framerate, unless you
specify a constant framerate (–rate 29.97)
(default 1:1:4:4:0:0)
-8, –denoise Denoise video with hqdn3d filter
(default 4:3:6:4.5)
or

-7, –deblock Deblock video with pp7 filter
(default 5:2)
-g, –grayscale Grayscale encoding

### Subtitle Options————————————————————

-s, –subtitle Select subtitle track(s), separated by commas
More than one output track can be used for one
input.
(“1,2,3” for multiple tracks.
A special track name “scan” adds an extra 1st pass.
This extra pass scans subtitles matching the
language of the first audio or the language
selected by –native-language.
The one that’s only used 10 percent of the time
or less is selected. This should locate subtitles
for short foreign language segments. Best used in
conjunction with –subtitle-forced.
-F, –subtitle-forced Only display subtitles from the selected stream if
the subtitle has the forced flag set. May be used in
conjunction with “scan” track to auto-select
a stream if it contains forced subtitles.
Separated by commas for more than one audio track.
(“1,2,3” for multiple tracks.
If “string” is omitted, the first trac is forced.
–subtitle-burn “Burn” the selected subtitle into the video track
If “number” is omitted, the first trac is burned.
–subtitle-default Flag the selected subtitle as the default subtitle
to be displayed upon playback. Setting no default
means no subtitle will be automatically displayed
If “number” is omitted, the first trac is default.
-N, –native-language Specifiy the your language preference. When the first
audio track does not match your native language then
select the first subtitle that does. When used in
conjunction with –native-dub the audio track is
changed in preference to subtitles. Provide the
language’s iso639-2 code (fre, eng, spa, dut, et cetera)
–native-dub Used in conjunction with –native-language
requests that if no audio tracks are selected the
default selected audio track will be the first one
that matches the –native-language. If there are no
matching audio tracks then the first matching
subtitle track is used instead.
–srt-file SubRip SRT filename(s), separated by commas.
–srt-codeset Character codeset(s) that the SRT file(s) are
encoded in, separted by commas.
Use ‘iconv -l’ for a list of valid
codesets. If not specified latin1 is assumed
–srt-offset Offset in milli-seconds to apply to the SRT file(s)
separted by commas. If not specified zero is assumed.
Offsets may be negative.
–srt-lang Language as an iso639-2 code fra, eng, spa et cetera)
for the SRT file(s) separated by commas. If not specified
then ‘und’ is used.
–srt-default Flag the selected srt as the default subtitle
to be displayed upon playback. Setting no default
means no subtitle will be automatically displayed
If “number” is omitted, the first srt is default.
“number” is an 1 based index into the srt-file list

Compiling handbrake on centos

Reference pulled from Ben’s Journal.

 

The fix turned out to be as follows. I edited the file:

 ./contrib/libvorbis/module.defs

and changed:

 LIBVORBIS.CONFIGURE.bootstrap = rm -fr aclocal.m4 autom4te.cache configure; autoreconf -I m4 -fiv;

to:

LIBVORBIS.CONFIGURE.bootstrap = rm -fr aclocal.m4 autom4te.cache configure; sh autogen.sh;

(and yes, that trailing ‘;’ is necessary)