ejes consulting

Techincal Consulting Design and Automation

Archive for October 2010

ubuntu Headless Video Recoding with Handbreak CLI

leave a comment »

I have a lot of movies.  A lot. They are all in a digital format of some sort or another on my NAS server.

I like uniformity, that is, I like all my media in one format.  I have an iPhone (which I also love) so, I’ve been leaning (sadly) toward mp4 for my library.  Also, sadly, my library has already been coded mostly in XviD (the open source DivX.)  So I need to convert my old “.avi” movies to “.mp4”.   This is called “re-coding.”

When I was initially thinking of doing headless recoding I was going to use ffmepg.  ffmpeg is amazing for doing things like this – and what it’s specifically designed for.  I however have been using “HandBrake (http://handbrake.fr/)” on my Mac and I really like the simplicity and it does a very good job.

Why mess with a good thing?

I found out that HandBrake has a command line client (http://handbrake.fr/downloads2.php) which is available in all operating systems except, Linux.  Ubuntu specifically.

Looking around I found that there are nightly “unsupported” development builds for Ubuntu, and since Handbrake is public software and any support you receive for it would be pure fluke; this unsupported version looked better and better.

More importantly there is an option to learn how to use this PPA (personal package archive) system that Ubuntu (https://launchpad.net/ubuntu/+ppas) has been tooting it’s horn over.

The “PPA” archive (available here: https://edge.launchpad.net/~stebbins/+archive/handbrake-snapshots) for Handbrake supports Maverick, Lucid, and Karmic – and since I can’t remember what my system is; I run a little lsb_release.

root@ubuntu:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 10.04.1 LTS
Release:        10.04
Codename:       lucid
root@ubuntu:~#

Look at that, I run Lucid (Ubuntu 10.04).  It’s “supported.”

To add a PPA it’s actually very easy, you have to use a command called “add-apt-repository.”  I didn’t have it at first:

root@ubuntu:~# add-apt-repository
add-apt-repository: command not found
root@ubuntu:~#

But that’s easily fixed by installing “python-software-properties”

root@ubuntu:~# apt-get install python-software-properties
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
python-software-properties
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 0B/30.8kB of archives.
After this operation, 1,126kB of additional disk space will be used.
Selecting previously deselected package python-software-properties.
(Reading database ... 54647 files and directories currently installed.)
Unpacking python-software-properties (from .../python-software-properties_0.75.10.1_all.deb) ...
Processing triggers for man-db ...
Setting up python-software-properties (0.75.10.1) ...
Processing triggers for python-central ...
root@ubuntu:~#

Then you can run, apt-add-repository with the correct repository information (found here: https://edge.launchpad.net/~stebbins/+archive/handbrake-snapshots):

root@ubuntu:~# apt-add-repository ppa:stebbins/handbrake-snapshots
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /etc/apt/secring.gpg --trustdb-name /etc/apt/trustdb.gpg --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver keyserver.ubuntu.com --recv 43D3A9F60C58A7169778E6FB8771ADB0816950D8
gpg: requesting key 816950D8 from hkp server keyserver.ubuntu.com
gpg: key 816950D8: "Launchpad HandBrake Snapshots" not changed
gpg: Total number processed: 1
gpg:              unchanged: 1
root@ubuntu:~#

(since I already ran it my output above will not match yours)

Once that’s installed, you can quickly use – apt-get install handbrake-cli, to install it:

root@ubuntu:~# apt-get install handbrake-cli
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
handbrake-cli
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 6,119kB of archives.
After this operation, 13.9MB of additional disk space will be used.
Get:1 http://ppa.launchpad.net/stebbins/handbrake-snapshots/ubuntu/ lucid/main handbrake-cli
svn3570ppa1~lucid1 [6,119kB]
Fetched 1,446kB in 7s (199kB/s)
Selecting previously deselected package handbrake-cli.
(Reading database ... 54665 files and directories currently installed.)
Unpacking handbrake-cli (from .../handbrake-cli_svn3570ppa1~lucid1_i386.deb) ...
Setting up handbrake-cli (svn3570ppa1~lucid1) ...
root@ubuntu:~#

Then you can simply use it:

root@ubuntu:~# HandBrakeCLI
Missing input device. Run HandBrakeCLI --help for syntax.
root@ubuntu:~#

Handbrake has a very good tutorial on how to use its command line client, and even has all the normal built in presets: http://trac.handbrake.fr/wiki/CLIGuide

Advertisements

Written by ejes

October 5, 2010 at 10:08 am

Posted in Tutorials

Tagged with , , , , ,