PDA

View Full Version : Transcoding, DVD ripping FTW (in Linux)



boberman
06-28-2008, 06:10 AM
I don't know if I am a great tutorial writer but I'll give it a shot.

Have you ever wanted to store your dvds on your hard-drive but are too afraid of the space requirement? Do you want to avoid scratching your DVDs? Does the DMCA not apply to you? are you using linux? Then this guide is for you!

First off, a small disclaimer, in some countries it is considered illegal to break the DVD encryption. I am not encouraging you to break the law in any way, only to be able to back up your dvds in some meaningful format.

As you are reading this, I am assuming that you have a fairly good knowledge of linux and can install programs on it. I will try to keep all software in the GPL zone, but will give suggestions when I feel that the closed source stuff works better.

What you'll need for this tuturial.

Mplayer, Nero AAC encoder, x264, vobcopy, decss2 (might be call libdecss), libmad, and mkvtoolnix (preferably with the gui version) <- you should be able to get all of these for free without little hassle.

Where I use windows software is with wine and dvd-decrypter. I love dvd-decrypter and think it is the best ripping tool out there.

I once you get all that installed (no, Im not showing you how, that would be far more work then I want to commit to at this time) its time to enter the world of the console. Ill try and explain all the commands as we go along.

The first step is to get the raw data, you should have about 8 GB of free space available, at least. you do that with this command

vobcopy -t <whatever your movie is call> -l
Simple, right? Well, not exactly. This will take the longest video section and put it into one vob file. Thats great and all, but sometimes you don't want to see FBI warnings ect. to do that you will have to find the actual movie track (guess and check is your best method) and use the "-n" command to extract it.

once that finishes you will have a nice fresh new movie eating up your hard-drive space. If you have a Peta-byte of storage then your are done right now, if not then your next step is transcode it into a more efficient format.

Now, before I go on, you should know that the method of recording that I'm about to show you is lossy. That means the data in is not the same as the data out, IE you can't recreate your dvd file perfect with the output. However, with good encoding settings you can get the video looking so close that no human can tell the difference. (like ripping a CD to an MP3, the data changes but the differences are pretty much imperceptible. Well, actually I can tell the difference, thats why Ill be introducing you to a better codec)

These next two steps can be done in tandem if you so desire. basically what you will be doing is changing the video then the audio for the movie, saving them off to two files then putting the files in one easy to open container.

For the video the command is simply this

makefifo stream.y4m &&
x264 stream.y4m --crf 18 <you can leave this blank or insert options to your likeing, x264 defaults are weak, but should play on any computer> -o <title of your movie>.mkv &
mplayer -nosound -noframedrop -noautosub -vo yuv4mpeg:file=stream.y4m <title of your movie>.vob
The first command basically makes a file who's sole purpose is to fool programs that need file input rather then standard input. x264 is somewhat dumb and just looks at the extension to see if it needs a resolution. The next command tells x264 to get ready, basically, cause data is on the way. Notice the single & and not the && like earlier. that baiscally means don't wait until the program is finished to start the next program. You want to wait for the file to be created, but you don't want to wait for x264 to finish (because there is no data!).

The next line tells mplayer to push only the video in a raw format straight into that fake file you just created (it goes straight to x264 basically) the -nosound make mplayer not process sound,
-noframedrop keeps mplayer from skipping
-noautosub removes subtitles and
-vo ect tells it to use the correct format and store it in the right place.

x264 has LOTS of options and is currently actively being developed. I recommend grabbing the latest version from the git and recompiling as they are getting better by leaps and bounds. I didn't give you all the quality settings that I use because it really comes down to your personal preference when it comes to how intense you want the encoding to be (I drop my quad core to its knees when I encode because I like high quality stuff) the one option I will explain is the --crf.

I love crf mode, it basically tells x264 to calculate the bitrate for you. While it isn't perfect, it is usually fairly close when it comes to measuring the bitrate. crf 18 will give you a very good encode, though a bit bloated file. The other options of X264 will shrink down the file size with crf 18. (some of them). To be honest, I run at crf 20 myself and have even gone as high as 24 with fairly good results. You should adjust this value to the point where you can tell a difference (smaller = bigger files better quality, bigger = smaller files lower quality) and maybe a little lower because you will be looking closer at your videos once all is said and done.

So, now you have the video transcoded (or it is being transcoded) the next step is to get the audio done. again, the steps are pretty much the same

mkfifo tempaudio.wav &&
mplayer -alang en -channels <2 = stereo, 4 = surround 6 = 5.1 surround> -ao pcm:fast:file=tempaudio.wav -vo null -vc null &
neroAacEnc -if tempaudio.wav -of <movie>.aac -q 0.5
Much is the same as the video command, the only difference is its harder to disable video for some reason :). Not much to explain, but here goes
-alang selects which audio track to use, in this case english (en) your preference my vary.
-channels x tells mplayer to output different channels, 2 for sterio (1 for mono) and 6 for surround sound. 6 is usually safe, but 2 will produce smaller files.
-ao tells the file output format and the saving location.
for neroAac its
-if the in file
-io the out file
-q the quality (higher is better quality/bigger files)

There are other options available to nero so I would recommend some testing and the -help command to see what they are.

So you are done encoding (yeay!) and now it is time for you to Mux, IE put the audio and video back together. I prefer the MKV container but you may opt for the more familiar MP4 container or even AVI (Don't do the AVI, it may work but it wasn't built for H.264). My instructions will be only for MKV, to do MP4 you need a tool called MP4box.

There is only one command to mux, its mkvmerge <videofile>.MKV <audiofile>.aac

Of course there are other options. The gui makes them much easier to see so if you want to get technical I recommend using that.

So there you go, you should have a movie now in a fairly small file. Happy encoding!

Torrent of Flame
12-23-2008, 10:59 AM
Alot of people?

Bluray hasn't completely taken over, yet. It will do, like DvD and VHS were side by side for a bit.