Your message has been sent.
This article has been saved to your account.
Go to my account
This article has been emailed to your Kindle.
Send this article
Complete the form below to send this article, Compiling and Running Handbrake in Ubuntu, to a friend (or to yourself). We will never share your details (or your friend's) with anyone. For more information, read our Privacy Policy.
Handbrake is considered the Swiss Army knife of video conversion tools. Running on the three major operating system platforms, Handbrake can open a huge variety of formats, including common ones that others can't handle (like the titles in the MPEG TS structure of a DVD). Handbrake outputs to a small selection of efficient formats, including H.264/MPEG-4 AVC, MPEG-4 ASP and Theora video. It has advanced features including chapter marking, subtitle inclusion and audio selection, plus filters for optimising video. On Linux, Handbrake can make use of the libdvdcss2 library to decrypt CSS-protected DVDs in-place during encoding, saving the need to use DVD Decrypter or another tool, usually through Wine. This article by Delan Azabani will guide you through the process for building Handbrake, installing it and converting video with it.
Background
Handbrake has stable builds for Windows, Mac, Ubuntu and Fedora. The developers of Handbrake haven't made a stable release for quite some time, leaving the latest version at 0.9.4. While this generic version is good enough for most people, generally it's better to build Handbrake yourself, on your computer for best results. The official PPA is only for Karmic Koala (9.10), and though packages are meant to be forward-compatible, the interface doesn't work in Lucid (10.04) at all. Hunter Kaller's PPA has a proper Lucid build, but for most installations, the video output is garbled. Where does that leave us? A build from the trunk.
Compiling Handbrake
To compile our own copy of Handbrake, we must obtain the source code from the Subversion repository. If you don't have Subversion (the default install doesn't), install it from the Ubuntu repositories:
sudo apt-get install subversion
To download the source code, you must run Subversion in a terminal:
svn checkout svn://svn.handbrake.fr/HandBrake/trunk hb-trunk
Before we compile Handbrake, we must install some dependant packages - without knowing and installing these, the compile process will stop again and again until we install all the packages one at a time:
sudo apt-get install yasm build-essential \
autoconf libtool zlib1g-dev libbz2-dev intltool libglib2.0-dev \
libdbus-glib-1-dev libgtk2.0-dev libhal-dev libhal-storage-dev \
libwebkit-dev libnotify-dev libgstreamer0.10-dev \
libgstreamer-plugins-base0.10-dev
After changing to hb-trunk, run the configure script:
cd hb-trunk
./configure
The configuring process should take less than two seconds (but don't worry if it takes longer; only worry if there are errors printed). Ignore the message that "lipo" and "xcodebuild" are not found; they are for Mac OS X builds only. Now we can build Handbrake. It is always best to compile using as many concurrent build processes as you have cores, so the make command will now look like:
make -jX
where X is the number of cores you have in your computer. To build Handbrake, change into build and run make:
cd build
make -j4


If you see weird output and you're using a j value higher than 1, don't be alarmed; it's just that the processes are all fighting over stdout so some output gets mixed. This may take five minutes to half an hour, depending on your computer's processing speed. On my Intel Q9650, it took around five to ten minutes. Unless you see errors at the end of the output (in which case they should be fixed before moving on), you're ready to install Handbrake! Make sure that any copy of Handbrake from a repository is uninstalled first:
sudo apt-get purge ^handbrake.*\$
Finally, run sudo make install to install Handbrake. Congratulations! If all went well, you should be able to run /usr/local/bin/ghb or find Handbrake in Applications > Sound & Video and Handbrake should launch! If all didn't go well, The build docs may be able to solve your problem. Check it out; it has helped me many times before.
Working with Handbrake
In this section we will add a video source and apply picture, video, audio, and subtitle settings.
Adding a video source
Handbrake incorporates a queue system that allows you to batch-convert various titles with one click. (Excluding those used to make the queue.) To add a video source (a Handbrake term for a file or directory that can contain one or more titles, a VIDEO_TS folder being one that can have many), click on Choose Video Source:

Once you've chosen a file (or DVD or directory), the titles will be scanned. You can use the Title dropdown to select the one you wish to encode (the longest one is automatically selected, which is convenient for DVDs). You can constrain the chapters, seconds or frames that are encoded by using the controls below the title selector. Remember to choose a preset (on the right); High Profile is much better than Normal, and don't forget to select your container format (MPEG-4 or Matroska). The MPEG-4 container format only supports a limited number of streams, and doesn't allow subtitles unless they're rendered on to the video (burned in).
Picture settings


The Picture Settings window allows you to adjust cropping and aspect ratio settings. For instance, you can set up non-square pixels, which is just like DVD and SD digital TV works: a 720x576 video can in fact be 16:9 widescreen, as it's stretched to display as 1024x576. This dialog also allows you to add filters to improve the appearance of the output video, including the ability to deinterlace the video stream. Check the Show Preview checkbox to see a frame of the video, and encode a short piece of the video to observe the filter in action.
Video settings

The Video tab allows you to choose the codec, framerate and basic quality settings for the video encoding. At present, only H.264/MPEG-4 AVC, Theora and MPEG-4 ASP are supported. You must use the Matroska container for Theora. On the right hand side, you can choose a quality factor, a constant bitrate or a target video size. The quality factor is the best to use as it allows for a variable bitrate encoding; allowing more data for high-detail sequences. A lower quality factor (drag to right) outputs a higher quality video. Note that for H.264, a quality factor of zero equates to a lossless encoding, but in my experience hasn't worked properly as the output is garbled. A two-pass encoding allows for a higher-quality encoding as the encoder can analyse the input without encoding, however it can take up to twice as long as a single pass.
Audio settings

The audio tab allows you to control the audio streams that are encoded and included in the final output video file. A track may be included by default; you can remove it for video with no audio, or add more. To do so, choose a source track, and configure the output encoding settings before clicking the plus icon to add the track. These settings are not affected by a preset change, as available audio tracks may vary.
Subtitle settings

The subtitle tab can help include subtitles in the output video. If you're choosing to use the MPEG-4 output container, you won't be able to choose subtitles that can be turned off; instead they'll be rendered onto the video (in which case you shouldn't include more than one or else overlapping subtitles will arise). Like the audio tab, choose the subtitle type first before clicking the plus icon. Also like the audio tab, settings here are not affected by presets, as the available subtitles may vary.
Finalising and encoding
You can set up chapter markers and advanced H.264 encoding settings (obviously only applicable with the H.264 output encoding) in the other two tabs available. Most of the time you won't need to modify H.264 settings; the Normal, High and device profiles have good choices that create quality videos with a low file size. Once you've set up the settings for the video, you can either click Encode if this is the last or only job, or Add to Queue for adding more jobs.
If you have a queue with multiple jobs, you may find it useful to click Show Queue to observe the progress of the encoding jobs. The Activity Window is also a very helpful tool to read debugging information, especially if your videos aren't outputting correctly or even encoding at all.
Custom presets
With Handbrake's plethora of options, you may find it tiring to set up all your settings for the video each time you start Handbrake, so saving a profile with preset settings may be quite helpful. Once you've set up everything the way you want, click the save button under the preset list. Please remember that some options will not be remembered in the preset (including some audio and subtitle options) as these streams may vary from source to source.
Conclusion
As the blog post for the Handbrake 0.9.4 release says:
There's an old proverb in the video encoding world: "Speed, size, quality: pick two." It means that you always have to make a trade-off between the time it takes to encode a video, the amount of compression used, and the picture quality. Well, this release of HandBrake refuses to compromise. It picks all three.
This quote is very true compared to other encoders that lack proper optimisation. Handbrake works extremely fast and pretty soon after starting an encoding job, you'll have to put down that cocktail; your Handbrake queue is done!

If you have read this article you may be interested to view :
- Control of File Types in Ubuntu
- Network Based Ubuntu Installations
- Ubuntu 9.10: How To Upgrade
- Install GNOME-Shell on Ubuntu 9.10 Karmic Koala
- Five Years of Ubuntu
- Ubuntu User Interface Tweaks
- What's New In Ubuntu 9.10 "Karmic Koala"
- Securely Encrypt Removable Media with Ubuntu
- Folding @ Home on Ubuntu: Cancer Research Made Easy
- Securing Network Services with FreeBSD Jails
- Create a Local Ubuntu Repository using Apt-Mirror and Apt-Cacher
About the Author :
Delan Azabani is a Linux and web developer based in Western Australia. In his spare time, he writes articles about web applications and Linux topics. He has extensive experience in PHP, JavaScript and C++, and can be reached at his website, http://azabani.com/, or by email, at delan.azabani@gmail.com.
Books From Packt
|
|
|



Post new comment