Ripping/Converting DVDs into H264 format on Linux command line
If you prefer to use command line interface to deal with your linux needs, or simply do not have access to a graphical interface of your server, you can easily convert any DVDs into a very well compressed H264 format video.
The following step-by-step was made on a Ubuntu server but any kind of linux distribution would behave the same way.
The fist step is to install the Handbrake’s command line interface, so called Handbrake-CLI. To do this, you have to add a non-official repository to your software collection:
sudo add-apt-repository ppa:stebbins/handbrake-releases
after this, you can install Handbrake CLI using the well know process:
sudo apt-get install handbrake-cli
After this step, you have the tool to compress any video into H264 format. The following steps are required to rip (DeCSS) a DVD because Handbrake will refuse to work if the DVD is copy protected:
sudo apt-get install libdvdread4
This step will only allow you to watch copy protected DVDs. If you want to copy them to your hard drive and remove the copy protection, you need to manually run a custom shell script file that was installed with libdvdread4:
This will provide a library to every tool on your system if they require to remove the copy protection (DeCSS).
If you have a physical DVD in your drive, you can skip the following two steps. If you have a DVD ISO, you can skip the following one.
To create a DVD ISO file from a VIDEO_TS directory on your hard drive, run the following:
mkisofs -dvd-video -udf -o dvd.iso /folder-with-VIDEO_TS-in-it/
When you have the ISO, simply mount it:
sudo mount -o loop dvd.iso /mnt
You are close to removing copy protection! To do so, use vobcopy utility to copy your DVD video VOB files into a single large video file without copy protection (the –l option tells vobcopy to use a single large file instead of creating 2Gb chunks):
vobcopy -l -o outDir/
This will open the mounted ISO/physical disk and copy into a single VOB file, which can be converted to H264 video using Handbrake CLI (-q corresponds for quality; -B tells to compress the audio into 160kbps; -t tells which title to convert in case you have more than 1):
HandBrakeCLI -i outDir -o movie.mp4 -e x264 -q 20 -B 160 -t 1
Don’t forget to unmount your ISO at the end:
sudo umount /mnt
Done, download and enjoy your quality H264 video!