I've been having some frustration with my efforts to encode video with Handbrake and the x264 encoder, and wanted to document it for posterity.
I have a small DVD collection that I have accumulated over the years. Unfortunately, I store them mostly in boxes as I don’t want to waste shelf space with DVDs that are never taken out of their cases. When they were on the shelf, they just got dusty. I've been infected by the MTV generation of instant gratification and don’t want to open the DVD cases, unless I really have to. Being a technology guy, I knew there had to be a better way. I'd thought of doing this sort of thing many years ago, when DeCSS was first released; when making a back-up of your DVD was a 10 step procedure of ripping audio separately from video, breaking decryption keys, picking codecs; it was a mess. I didn’t have the stomach for it. Thankfully, the process is now much easier, thanks to Handbrake.
Using Handbrake, you can copy an entire DVD's video and audio, synchronized, to a video file on your computer. Perfect.
A few years ago I started to do so, but it takes hours to do each DVD, so it's a long project. I'd copied all our movies, but left the TV series' till the end. As it turns out, they're much harder to slog through than the movies, because there can be anywhere from 3,4,5..9 DVDs per box set :|
I was originally ripping the DVDs using Handbrake 9.8.0, with the built in x264 encoder, on a Quad-Core AMD Phenom 9500 (2.2Ghz), using Ubuntu 12.04 LTS as my underlying OS.
Why Handbrake?
It's arguably the best, free, and allows command line scripting
Why x264?
It's also arguably the best, for quality
Why Ubuntu?
From snooping on the Handbrake web site, it seems they mention Ubuntu a lot, and my guess was that the authors either used it themselves, or had a preference for it somehow. As I'm fluent in several versions and flavours of Unix/BSD/Linux, why not use what they'd want? I was hoping for better support and performance.
Performance?
Once I had it all set up, I was getting ~35-40 fps (yes, frames per second) on ripping and encoding the video. If we round off, you can then see that a 2 hour DVD will take about 2 hours to rip and encode... and I have months of video to encode... there's got to be a better way.
How do you make Handbrake go faster?
I'd heard that the power of the CPU on the video/graphics card (the GPU) could be leveraged to do complex math functions. I looked into GPU acceleration of the encoding process. Unfortunately, it's too immature, it isn't ready yet, and I don't have any kick-ass video cards (GPUs) that would take on the task anyway.
What about more computers? Two heads are better than one!
I had some parts lying around... so I set to work assembling and purpose building them. I had mixed results.
I had an old AMD K7 1.2Ghz CPU and motherboard kicking around, and some matching ram (768Mb), video card, hard drive, etc.. so voila, a tiny ripping workstation. It would be slow, but how slow?
Well, I loaded Ubuntu 12.04 (32bit), and Handbrake, and encoding using the same "High Profile" as I was using on the AMD Phenom 9500... I got ~1.5-2.0fps. Umm.
It would take *days* to rip a single DVD. The AMD K7 simply doesn’t have any video encoding instruction sets built in that would allow it to do the work with any efficiency, and the 1.2Ghz processor doesnt have any brute strength either. Okay, that idea is dead.
I also had an old IBM xSeries 336 8837 with dual Intel Xeon 2.8Ghz processors (totalling 4 cores) - That should perform as well, or better, than my little quad-core AMD workstation class CPU, no?
I loaded it up with Ubuntu 12.04 (64bit), Handbrake, and was sorely disappointed.
All settings remaining equal, between the quad-core AMD and the quad-core Xeon, I can only get half the FPS out of the Xeons... Why?
Well, I'm guessing, but I think the x264 encoder has better built-in multimedia instruction sets to draw on in the AMD Phenom over the Intel Xeon which probably blows it away in other areas; just not video encoding. I am getting consistently 15-20fps on the x336 - which is very disappointing. Considering the redundant power supplies and heat from the CPUs are heating the room which it is sitting in, I don't think I'll keep it on much longer.
The Handbrake GUI is quite friendly and more than adequate if you're looking to rip one thing, but for multiple, and doing so with repeatable accuracy, I use the command line.
Here is the command line I've put together based on other people's input from forums regarding how to rip ALL the video content from a DVD (not just the main feature) to a high quality MPEG4 file/container.
$> for i in `seq 99`; do HandBrakeCLI -i /dev/dvd -t $i --preset "High Profile" -o NameOfTheThingYoureRipping-$i.m4v; done
The above script will repeat for track 1, 2, 3.. 99 and rip each video track to a separate appropriately named (-$i) m4v file. Handy for compilation DVDs!
NB
Throughout this experiment I've been very impressed regarding how well Ubuntu has worked, and the hardware support for the oddball pieces was shockingly good too.
References:
http://www.videolan.org/developers/x264.html
http://handbrake.fr/details.php
http://www.ubuntu.com/project
No comments:
Post a Comment