1. Install needed applications
sudo apt-get install mplayer mencoder normalize-audio vorbis-tools mkvtoolnix gpac x264-bin
2. Rip DVD to harddisk
mplayer dvd://1 -v -dumpstream -dumpfile title.vob
- 1 is the stream you want to rip.
3. Rip subtitles
mencoder dvd://1 -nosound -ovc frameno -o /dev/null -slang en -vobsubout title
- 1 is the stream we extract the subs from
- slang is the desired language (en, de, fr, etc.)
- title is the basename of the vobsub files, in this case title.idx and title.sub
4. Convert audio to PCM
In case you want to keep the original AC3 audio step forward to 6.1!
mplayer title.vob -ao pcm:file=audio1.wav -vc dummy -aid 128 -vo null
- title.vob is the stream we already ripped in step 2
- audio1.wav is the name of the resulting PCM file
- -aid 128 chooses the first audio track
If you would like to rip another audio track (e.g. commentary or different language) repeat the above with the next track number (-aid 129 would be the second track) and save as audio2.wav.
normalize-audio audio1.wav
Repeat on audio2.wav etc. if you have more than one audio track.
6. Convert audio into Ogg Vorbis
oggenc -q5 audio1.wav
- -q5 is the desired quality of the first track. Wikipedia: Many users feel that Vorbis reaches transparency (sound quality that is indistinguishable from the original source recording) at a quality setting of -q5, approximately 160 kbit/s. Additional audio tracks can be encoded accordingly with lesser quality in order to save disc space.
6.1 Keep original Dolby Digital AC3 audio
In case you do not want to compress audio but keep the original AC3 track simply extract it from the VOB with
mplayer title.vob -aid 128 -dumpaudio -dumpfile title.ac3
7. Encode video
This example uses the two-pass-method and presumes progressive PAL video. Read here how to deal with telecined, interlaced and NTSC video.
First, we have to get rid of black borders around the movie. Hence we playback the file with the cropdetect filter.
mplayer title.vob -vf cropdetect
Move a little forward in the movie using the arrow-up key and let MPlayer find the correct settings for you. If you are finished quit MPlayer and copy the part -vf crop=720:432:0:76 from the console. Of course your values might differ from this example.
Now create a file which runs the first and second pass consecutively.
gedit videnc
Paste the following into that file and adjust the cropping values with the ones you got from the procedure above
# First pass
mencoder -v\
title.vob\
-vf pullup,softskip,crop=720:432:0:76\
-ovc x264 -x264encopts subq=4:bframes=3:b_pyramid:weight_b:turbo=1:pass=1:psnr:bitrate=1000\
-nosound\
-of rawvideo\
-o title.264
# Second pass
mencoder -v\
title.vob\
-vf pullup,softskip,crop=720:432:0:76\
-ovc x264 -x264encopts subq=6:4x4mv:8x8dct:me=3:frameref=5:bframes=3:b_pyramid:weight_b:pass=2:psnr:bitrate=1000\
-nosound\
-of rawvideo\
-o title.264
Since MEncoder is not able to save directly into Matroska containers we encode the video in raw format convert it later into .mp4 and finally mux everything (video, audio, subtitles) together with mkvmerge. Interested in what all those options mean? If everything fits your needs save videnc.
Encoding of MPEG-4 AVC video is a time consuming matter. On my AMD Athlon64 3000+ a 90 minute movie takes about 3 hours for the first and again about 5 hours for the second pass. Best is to let your machine work over night while you sleep.
Run videnc
sh videnc
8. Mux video into MP4 container
Good morning! ;)
If encoding went fine we are ready to put that x264 file into an MP4 container
MP4Box -add title.264 title.mp4
You can already verify the result by playing it in MPlayer.
9. Muxing it all together
Start up the MKV files creator
mmg
and simply drag & drop your files into the Input files box
- title.mp4
- audio1.ogg
- audio2.ogg
- title.idx (not title.sub!)
You might have noticed that we did not scale the video during the encoding process. That is because Matroska handles the aspect ratio itself. Simply define the languages and track names in the Tracks box and choose the correct aspect ratio. Choose an output filename (the default would produce title.mkv) and hit Start muxing.
Changelog:
- 9. Oct 2006 – fixed encoding parameters
- 9. Oct 2006 – added telecined, interlaced, NTSC
Todo:
- Encode to a certain file size
http://ubuntuforums.org/showthread.php?t=273635&goto=newpost
originally posted: 2006-10-08 16:15:04 -0400
Just 9 quick steps, eh? I had no idea it was that quick and easy to do.
I’m all over it. Thanks
Any idea why on my Ubuntu install I don’t have a dvd:// ? Mplayer fails to play a DVD also, says it can’t find dvd://1 When i load a DVD it mounts as /media/[dvdname]
thanks for writing a tutorial. I played around with it a lot and I noticed a crucial mistake in what you did:
You use the -nosound option with mencoder which can cause a lot of trouble, as audiofiles and videofiles can get a different playtime because of this. read more here:
http://lists.mplayerhq.hu/pipermail/mplayer-docs/2005-September/006304.html
so please just use -oac copy option instead of -nosound.
You need bitrate=X among x264encopts or newer mencoder versions won’t work. Otherwise, great doc, thanks!
I’ve finally managed to script this (e.g. the last step can be written as “mkvmerge -v -o title.mkv title.mp4 *.ac3 *.idx”).