Saturday, December 30, 2006

Play that DVD on your phone

Sure, you paid for that movie on DVD. You didn't care what format it was in, you just wanted the movie. Now you're busy like me and you want to watch it on your cell phone or handheld video player. This article tells you how it's possible, without buying any software.

Before I get into that, though, I have to warn you. The movie studios don't want you to have that content available in the format you desire. You're going to break the laws of several nations on your way to convenient video. Such is life. When you get busted, I didn't tell you to do it, I only told you how. BTW, this guide is for media shifting and legitimate backups only. Don't go using this information for sharing purposes. If you didn't buy access to the content, you've got no right to it. If you're not sure you have a legal right to make backups in your local area, consult the services of a legal professional before continuing.

On with the show. This isn't the only way to do this, but it's a convenient way if you have the necessary equipment. You'll need:

A windows computer
A linux computer
A device to play your video on that plays MPEG2.

The first thing you need to do is to get it off of the DVD and onto the hard drive of your windows PC in an unencrypted format. For this you can use the program DVD Decrypter. Just install it from the downloads section of http://www.doom9.org/ and insert the DVD. The default settings almost always work. You'll want to do one movie first, just to be sure you have it right. After that if you're converting bunches it might be best to decrypt several at a time.

The next thing is to get it out of the DVD file format and into something a little more portable. For this you can use Auto Gordian Knot (AutoGK). It's available from the same source. In this step choose encoding as AVI with Xvid video codec and MP3 VBR for the audio. For output settings choose 100 percent target quality, rather than size or CD's based output. That way your output will come all in one file and it will only require one pass (it's faster). Also, multiple sessions of lossy compression introduce unwanted artifacts in the output. Always keep the maximum quality until the final rendering step. Don't worry -- the file will be small enough to fit in your player when you're done. If you're doing a batch, choose Add Job and then select a different disk folder and output file and add it to the batch. Click start.

AutoGK uses some external programs to convert your file according to the settings you gave it. They're installed with AutoGK, though and you don't have to think about them much. The first time you use them though, at various steps you'll be prompted to accept their license terms. AutoGK is doing the really hard part here. It's converting the original coded and compressed video into a different video code basically by uncompressing the images and then recompressing them in the new format one at a time. A movie has hundreds of thousands of image frames, so this can take some time. In addition to this it's doing the same thing with the audio portion of the movie, and keeping the sound in synch. If your computer isn't completely stable and reliable, this is when you find out.

Once you have your output .avi file, you need to get it over to the linux computer so you can process it with ffmpeg. It's possible to get ffmpeg installed on your windows computer, but there's no way I can provide instructions for that in a blog post. If your computers are networked, you can just save the file over to the linux box. Otherwise you can burn the file to a DVD. It can be pretty large, though. Some of these files will be more than 2GB. You can also use an external hard drive. External HDD's are available in larger sizes. Most current linux distributions can read the files off of an NTFS formatted external hard drive. If the hard drive is formatted with FAT32 instead, you'll have to keep your file sizes under 2GB. However you get it there, you'll want the .avi file on a hard drive that's local to your linux box.

When you have the file on your linux box the last step is easy. You'll need ffmpeg. It comes with most linux distributions, but if you don't have it, get it the same way you get your other software. (Note for windows only users: linux usually comes with software to install thousands of useful programs like this for free.) While you're at it get vlc (videolan-client) as well for watching movies. Run ffmpeg on the file like this:

# ffmpeg -i IN.avi -s 352x288 -ab 32 -ac 1 -b 64 -ss 25:00.00 OUT.mpg

Replace IN.avi and OUT.mpg with the files you want of course. The options are like so:
-i IN.AVI - the input file
-s 352x288 - The output resolution. Use what's appropriate for your device.
-ab 32 - Audio bitrate 32kbps
-ac 1 - Mono output
-b 64 - Video bitrate, 64kbps
-ss 25:00.00 - Start 25 seconds into the video

How long it takes to convert varies with your computer power. On a Core2 Duo laptop the decrypting takes about 20 minutes. The convertion to AVI takes about an hour. On an Athlon 2500+ the .mpg conversion takes about 30 minutes. All of that for a typical 90 minute movie, using the settings above. The finished movie might be 96MB. Quality is about what you would expect for watching a DVD on your phone.

The last step is to get the .mpg movie into your device. SD media is great for this, or you can use whatever synch system comes with your device. Since it's unencrypted baseline video, it should play in almost anything that claims to be a video capable device. A two GB SD card holds about 20 typical movies.

If you have better ideas for how to do this more conveniently, I would love to see your comments.

No comments: