Linux DVD conversion to h264 aac mp4

So I get a week off, and what really needs to be done?!? I’ve been noticing the deterioration of my massive, 200+, DVD collection which contains ALL my former concerts, ensembles, studio recitals, grad recitals etc…

This of course is very precious to me and maintaining my data/media is always a balance of: newest and greatest way, good compression, high quality audio and video, longevity, and last but not least convenience.

For a long time now, the best option for me has been a transfer to the DVD format, and I have well over 200+ DVD vids of our concerts. I’ve been watching video codecs with hope, and finally with h264 and aac I have to say it really is incredible quality at a highly compressed bitrate.

So with the h264 (x264 in linux) codec (the video/size ratio is very good) and my dying DVDs, I decided to get this done, and I’ve learnt a few key commands that I’d like to share with whoever will listen. I’ll break it into steps:

1) Getting the info off the disc
Since these are all personal discs, a conversation about libdvdcss as it’s not needed. There are two good ways of doing this (the former is quicker, while the latter is far better at regaining lost data

ddrescue works really well if there are no/few problems with the disc (free from scratches):
dd_rescue -n -b 2048 /dev/cdrom dvd.iso

dd can be brutally slow, but gets everything:
dd if=/dev/cdrom of=dvd.iso conv=noerror,sync

2) joining VOBs
There are two ways to do this too. I’ll give the most logical and easiest first although I notice no difference at all between the two.

use cat:
cat VTS_01_1.VOB VTS_01_2.VOB VTS_01_3.VOB > combined.vob

use ffmpeg (you need 1.1 or newer for concat):
ffmpeg -i concat:VTS_01_1.VOB\|VTS_01_2.VOB\|VTS_01_3.VOB -c copy combined.vob

One neat thing about the ffmpeg command is you can include everything else and come up with a finished product like:
ffmpeg -i concat:VTS_01_1.VOB\|VTS_01_2.VOB\|VTS_01_3.VOB -c:v libx264 -crf 23 -c:a libfaac -ac 2 -ab 192k finished-video.mp4

3) Encoding video
I use ffmpeg for this:
ffmpeg -i combined.vob -c:v libx264 -crf 23 -c:a libfaac -ac 2 -ab 192k test.mp4

to break this last example down:
-i combined.vob -> is the concatted vob file
-c:v libx264 -> this is the codec (x264)
-crf 23 -> this is how you set the constant quality, a lower number means higher quality, bigger file
-c:a libfaac -> audio codec (faac)
-ac 2 -> stereo sound (channels = 2)
-ab 192k -> the audio bitrate, higher is better/bigger

and that’s pretty much it. For a 1 hour concert at 720p I’m getting about a 500-600mb file which is really good, and I’m using all open source software. I’m plowing through these videos, getting them backed up and safe. As soon as I complete this, the next stage is to run out to pick up a new 2TB HD, copy the files to that and move them offsite (just in case the house burns down…. you can NEVER be too safe with your data!

I like the quote:

“There are two types of people in this world, those who have lost data, and those who are going to lose data”

8 thoughts on “Linux DVD conversion to h264 aac mp4

  1. Great article. This is what I was looking for!! Just one question, with multiple audio VOB files, how would you select the audio stream? I read a lot about the -map, but I can’t figure how to add that in here

  2. as faac was not found, I used libmp3lame
    In Handbrake tutorials RF:20 is considered medium quality needed, wouldn’t it be better to replace 23 with 20?

    1. My blog, my settings 🙂 For my purposes, a quality of 20 did not meet my archival purposes, I encode a lot of music concerts and 20 was overkill.

  3. For concatenation conside something like: cat VTS_01_[1234].VOB | ffmpeg -i – -vf yadif -map 0:v -map 0:a myfile.mp4

    If you have more VOBS, do [1234567] etc upto or exceeed the available vobs. The -vf yadif filter is good if you’re backing up interlaced video and want to make it progressive ( like your computer screen! ) that way you can eliminate the jagged interlaced video. The map option is important too, some DVD’s have multiple audio — the map v and a get you to the ENGlish outputs but thats not always guaranteed and a longer story. Just wanted to contribute back to the blog.

  4. tip:

    dd if=/dev/cdrom of=dvd.iso conv=noerror,sync bs=

    will speed things up as dd tries to use either the block size set by bs option or the max allowed.


Leave a Reply

Your email address will not be published. Required fields are marked *