Rip DVDs to iTunes Automatically for iPod, AppleTV, iPhone
First things first!
This is a tutorial on how to rip DVDs you own and not how to steal movies!
That said, there is a legitimate need to be able to take DVDs you own and turn them into files that can be streamed/played, installed on your iPod or iPhone, or used with an AppleTV or other media device. This is a tutorial on how I do it for one of my clients along with a script I customized to make the whole process easy.
The set-up I have for one of my clients is a central Mac Mini server (headless – no keyboard/monitor/mouse) which we use for the iTunes server. It runs iTunes all the time and does not do much of anything else. We have a number of AppleTV’s on the network and each of them is paired with the iTunes library on the Mac Mini server. This set-up allows my client to play/stream any music or movies in the iTunes library on any AppleTV. This works well for their purposes.
The issue I needed to solve for my client was to make it easy to rip all of their media/content into iTunes. Automating the music ripping was easy as iTunes has built in preferences for automating the ripping of music. Just go to iTunes preferences and tell it to rip a music CD when one is inserted in the Mac Mini and when complete, eject it. Done.
But what about DVD movies?
Well iTunes does not yet have any capability to rip in DVDs. This is likely due to the encryption surrounding DVDs and the Copyright Millenium Act of blah blah blah. But where iTunes falls short, there are many programs that can fill the gap. MacTheRipper is one. It can decrypt the DVD and save the files to your hard drive. But I needed to go one step further. I needed to convert the DVD into an AppleTV/iPhone/iPod compatible format, namely MP4.
An awesome application called HandBrake allows you to not only decrypt DVDs but it can also convert to many different formats including MP4. This was perfect for my needs. So I showed it to my client and walked them through the steps to rip DVDs. First you insert the DVD. Then you open HandBrake. Then you select the settings for the rip. Then rip the file. Then move it to the iTunes library. All in all, not too complex, but certainly not going to work when we have 5 people all trying to do this. Its just not going to work.
So I wondered if I could automate it much like iTunes automates the ripping of music CDs. And the answer is that you can, using a version of Handbrake called Handbrake CLI (Command Line Interface). Basically this version is just like the GUI version, except that there is no GUI. The CLI version is made for scripting.
So what I wanted was this:
- Insert a DVD into the Mac Mini
- Have a script kick off that did the rip and added the resulting MP4 to iTunes
- Eject the DVD
I am not a programmer. So I looked around for something that might do what I wanted. I did not find anything that was exactly what I needed but I did find some things that were close and gave me a good starting point.
First was the great site Mac OS X Hints which had an article sort of close to what I wanted. But in the comments I found a link to the site of John Muhl:
http://sever.caenim.com/etcetera/handbrake-cli-guide/automatic/
John’s scripts sounded like they did everything I needed. But it had a few issues for my specific needs:
- The scripts encode for m4v format and I needed mp4
- The DVD name determination algorithm did not grab the full name of some DVDs (especially with spaces in the name)
- The eject command was not working correctly due to issue #2
- I also wanted a feature where the resulting mp4 was automatically added to itunes.
So while John’s scripts got me most of the way there, I needed to customize it a bit. So I changed the format to mp4 and re-wrote the DVD name determination algorithm to be a little more robust for DVDs that had spaces in the name. Once the name algorithm was fixed, the eject issue was also fixed. The last feature was telling AppleScript to add the track to itunes. This required a little playing, but was not that hard in the end.
I can’t say these scripts are the finest example of scripting/programming out there. But it seems to work well and does what I needed. So I thought I would share the results as I bet many others are interested in doing the same thing.
Happy ripping.
7 comments7 Comments so far
Leave a reply


hello..i was just wondering if this will work with a windows computer..or do you need a mac? or do you need no computer at all? =] lol. thanks.
Carl,
You’ve been there haven’t you? Trying to find a solution to what you think has GOT to be the most common problem there is.. And there’s bits and pieces, but yet, no bueno.
Then, I found your script. EXACTLY what I’ve been trying to piece together with a python script and an applescript. Yours was so simple, so ahhh yes….
It’s folks like you who share the wealth that make this world go round. Thank you for your willingness to share.
hi thanks for this, i am actually in the process of doing this on and off for the past week, and was looking for a script or two like this.
One question for you: Why do you want mp4 instead of m4v as Handbrake does m4v for apple tv which i think includes 5.1 surround ? Just wondered? thanks
Carl
This is exactly what i am looking for – but my lack of technical awareness and ability leaves me stumped when you get to the /usr/local/bin/ bit. I can’t find this directory anywhere and wouldn’t know where to begin with the root thing. Can you help?
So today I found a bug in one of the scripts. The encode.dvd.sh script and also the encode.DetermineDVDname.dvd.sh script both assumed that the DVD was always the first device in the disk device chain (disk1). But in fact this is not always the case.
So I changed this line:
DVD=”disk1″
to this instead:
DVD=`diskutil list | awk ‘{ field = $NF }; END{ print field }’`
This new line no longer assumes the DVD is disk1. It now assumes it is the LAST disk in the “diskutil list” command. Perhaps this is also a silly assumption, but it seems to be working for now and I am not sure how to find the DVD title by diskutil list command otherwise. I am sure there is a way, but for now I think this is fairly reliable.
Not sure the differences between mp4 and m4v. But I think they are sort of (?) the same.
http://en.wikipedia.org/wiki/MPEG-4_Part_14
http://discussions.apple.com/thread.jspa?messageID=5060972
“There sure is confusion between .mp4 and .m4v because people think they are different when they are not. These 2 suffixes can be applied to MPEG-4 video files that are exactly the same in every way. Double-click the file and there’ll be different behavior: .mp4 opens in QuickTime Player whereas .m4v opens in iTunes by default. But drag-and-drop onto either application will open either file type.”
/usr/local/bin/ is only accessible via the Terminal (Applications—>Utilities folder). Terminal is a command line program.
And while you are at it, Root access to your machine is also through the terminal. You have to enable it first on a Mac OS X machine. Be careful…you can screw up your machine if you don’t know what you are doing.