uphpu presentation: ripping dvds

I gave a short presentation last night at uphpu on ripping and encoding DVDs under Linux. I wanted to type up a few notes on some stuff I mentioned during the meeting.

Short version: Use Handbrake (available on Linux, Mac OS X and Windows). I’ve gone through a lot of applications through the years trying to find that “perfect rip”, and Handbrake beats everything hands down. I’m a videophile who likes everything looking as nice as it can, and this is what I use regularly.

Accessing DVDs

The first things you’ll need installed on your box is libdvdread and libdvdcss. libdvdread will access the DVD filesystem, and libdvdcss will decrypt the DRM on the disc. These should both ship with your distro, or if they don’t, should be relatively easy to acquire.

I use a lot of command line tools to access DVDs, so my focus was on that. The reason for that is because I have a lot of shell scripts to rip my massive library of discs, and I store data about them in a database.

lsdvd is the first stop. A very small app that uses libdvdread to display human and script-friendly output of the details of your disc.

mplayer dvd:// and mplayer dvdnav:// plus the optional track (dvd://3) or optional -dvd-device argument to specify the location of the device or ripped ISO.

I use dd to copy the contents of the entire disc to the harddrive and then rip it from there, to avoid wear and tear on the DVD drive, and also because I can do things like simultaneously rip one disc in the background and encode another at the same time.

When accessing the drive, you’ll want to use mplayer or some other program to access the drive and decrypt the CSS so that the drive itself caches the access. Otherwise, it may lock up.

I use pv to dump the disc and give me a pretty progress bar with ripping ETA and disc read speed: pv -ptre -w 80 /dev/dvd | dd of=movie.iso

If you want to extract the chapters, you can use dvdxchap, which is part of the ogmtools package.

DVD Tracks

Every movie I’ve run into has one track specifically for the video. Using lsdvd you can find the longest track, time-length wise, and that will be the movie.

TV shows on DVD often put many episodes into one track, where one or more chapters may contain an episode. You’ll need to examine these yourself to find out where each one starts and each one ends.

Another caveat is that they are not always ordered on the track or on the DVD in the same order that shows up in the menu. The best advice when accessing tracks and titles on DVDs is to never assume anything, if you are trying to preserve order.

DVD Subtitles

Subtitles on DVDs come in two formats: VobSub and Closed Captioning. VobSub subtitles are images that are overlaid onto the picture. Closed captioning is a text format.

If you have a ripped VOB (DVD MPEG-2 video), you can extract the subtitles using a program called ccextractor. It will save the subtitles to SRT, a subtitle format that can be muxed into your final video.

Encoding DVDs

Handbrake is a very “smart” application that will make things extremely easy on you. It supports encoding using three codecs: x264, ffmpeg and theora. x264 is an actively-developed H.264 video codec, and is used professionally by many companies. It also has a lot of options that you may find useful in your encode, based on your target playback device (ipod, ipad, iphone, apple tv, htpc, computer, etc.).

Handbrake supports muxing (or putting audio and video into a wrapper format) to two containers: MP4 and Matroska. MP4 is a very popular standard used in lots of places. It’s an open-specification. Audio is usually AAC. Matroska is an open-source openly developed container format that has a standardized specification. Support for it is growing in a lot of devices. Matroska can handle multiple video streams, multiple audio streams, multiple subtitles, stores metadata, chapters and attachments. Strictly speaking, either one will work fine for most people’s needs, but for those looking for advanced usage and tagging, Matroska will fit your needs. On linux, the tools for muxing and accessing information about a Matroska file are found in the mkvtoolnix package.

Deinterlacing and Decombing

Most movies will be progressive video, meaning that each frame is one full picture. Production studios and DVD authors may have their video interlaced. Interlaced video is where half of the frame is shown in quick succession where the second half is shown. On older TVs (like the CRT tube TVs) display at a native resolution of 480i, so you won’t notice the lines. Progessive displays (computer monitors, HDTVs, etc.) will display the lines and it can be a visual annoyance.

Handbrake uses filters to convert interlaced video to progressive video, called deinterlacing. Decombing is also a feature that Handbrake supports, which is basically “smart” deinterlacing. It is safe to turn on the decombing filter to the default setting for all your encodes, and let Handbrake automatically convert your video for you. Don’t use the deinterlacing filter unless you specifically know what you are doing.

Please see 100fps.com for a quick explanation of video deinterlacing.

Other Handbrake Features

Handbrake has lots of handy features. It has support for “profiles” which is a combined set of preferences for container format, video codec, audio codecs, preferred subtitle settings, post-processing, deinterlacing, decombing, and all the H.264 settings that come with x264.

One nice thing it will do as well is auto-crop your feature film for you. This is a boon if you have a letterbox source video, where the movie itself is in widescreen, but the presentation is in fullframe.

You can also “queue” up your encodes, so Handbrake can be working on multiple files. You don’t need to wait for one to finish before assigning it it’s next task.

Handbrake is also multi-threaded when using x264 to encode your video. With a six-core desktop, I have been able to encode video using the “Normal” profile between 160 to 180 frames per second. Meaning a 25 minute video will take about 2 1/2 minutes to encode.

PHP Classes

I’ve got some small classes that I use in my shell scripts for Matroska and Handbrake (v0.95 required). You may or may not find these helpful. I should warn that these are just used on my own set of scripts, so they may or may not be very clean or can have small bugs.


If you want more information, here are some good places to go:

Multimedia wiki
Handbrake forums

Also, feel free to contact me if you have any questions, and I’ll be glad to help.

working with teenagers

Even before I started going back to school and focusing on psychology, I had a pretty good idea of what I wanted to do with my life: working with people who had general life problems. But as I focus that even tighter, I realize that I’ve always wanted to work with teenagers. Why is that? The more I study psychology, the more I realize how fascinating the adolescent development stage is.

There are so many questions that I have, that I have to wonder how it is people deal with it. I’ll admit that part of the reason for my quest is to find answers that I myself, still struggle with. I think in a lot of ways I’ve always had a mental capacity of someone twenty years older than me. I’m not claiming a high intelligence or anything like that, rather that my mind was always churning out so many possibilities and trying to understand societal factors at a really young age. As an example, in my introductory sociology class, I find myself constantly getting frustrated at the material presented, because I understood this stuff when I was about ten years old. I just “got it” really early on. It makes me a little upset when doing the coursework, because I keep looking for deeper answers and insight to the issues, but this class is only going to be able to go into the basics, just because of it’s broad academic goal.

Anyway, the reason for all of that is that while I had a lot of external social factors figured out early on, I never really understood relationships myself growing up too well. In fact, it’s safe to say I still struggle with that a great deal. Which is one reason that studying to help out youth is so helpful to me as well.

Consider all the things that are being developed during adolescence. It’s a lot of firsts, and it can be a completely terrifying and crazy time. Teenagers start to develop real, deep relationships for the first time. In some cases, they are introduced to their first romances. They develop the skills to create real relationships that have meaning and structure, that are beyond simpler ones where in their younger years, they innocently played together. For the first time, they have peers that they can relate to on an emotional level, and share with them those unique perspectives.

I have *always* had the opinion that teenagers get written off way too easily, and that has always fueled my desire in part to be someone who gives them a listening ear for a change. Adults generally shrug off problems that teens have and either discount their issues (which, from their perspective, really aren’t that important) or just throw out platitudes like “You’ll grow out of it.” For someone going through that, at the time, making light of the situation just tells them that you are not someone they can discuss their feelings with. So, I try to listen, listen, listen, and hear what they are saying.

I’d like to say that I’m good at it, but unfortunately, I’ve seen myself doing the “adult” thing sometimes, and trying to jump straight to a lecture when someone tells me what they’re going through, or just thinking the whole “drama” is entertaining.

As adults, in retrospect, we think that the issues that youth are going through are trivial. And for adults, they are. But the problem for the youth is that this is the first time they’ve ever even had these types of issues.

What is it about growing up that makes us change so much? Yesterday I was at church, and I saw some little kid about four years old running through the halls having the time of his life. He would get stopped by some random elderly mother who would give him a pat, a hug, and a kind word. That’s your entire life when you’re a little kid. Having fun, running around, playing with toys, and everyone telling you how sweet and wonderful you are.

Then, as you transition into being a little older, people don’t constantly give you hugs. Instead, you start to look like an adult, so people treat you like one, whether you are emotionally prepared for that or not. Responsibilities are heaped upon you, procedures and details become more important as you gain emerging autonomy. Everything is just confusing.

Then there is the transition into adulthood as well. What purpose of life do teenagers have? Adolescence is a temporary lifestyle, and people do “grow out of it.” It seems to me in a lot of ways that the individualism that teenagers search for with such tenacity disappears as they enter school and the workforce and learn to conform to the status quo instead, and just disappear completely. What happened to those people who just a few years before, were so full of thoughts, and ideas, and dreams? Where do all those things disappear to? I think about that one a lot, in particular, because I, myself, have a bit of a Peter Pan complex, I suppose. As an adult, I’m just doing everything that I always wanted to as a teenager because now I have the means available. But in my perspective, I’m just trying to live my dreams that I’ve held on to all these years, and I don’t really see anything wrong with that. I’m happy following that path.

Teenagers just experience an interesting, unique time of life. They’ll never be the same way again. It’s a great time to really, have time, to explore life and it’s subtleties, and think about what it is they want to do. It can be pretty confusing as so many external factors suddenly become important socially and personally. It’s the time when lifelong perspectives and opinions can take seed. How could people discard and ignore those where when they are the most vulnerable and the most curious at the same time? That’s the kind of situations I want to work with, if only because I feel like I have an extreme level of sensitivity to what they are going through. It’s the chance to work with people before they’ve settled into their routines. It’s before they become bigots, poets, writers, workers, religious, biased, and whatever else you can think of. Fascinating time period, I think. Completely volatile and chaotic, but at the same time, it’s an awesome experience to talk with people who are still completely open minded and not settled in their ways.

Good times. That’s what I wanna work with. :)