Friday, March 4, 2011

AutoDVDEncoder

   I wrote a script to help me encode DVDs to  to high quality Xvid videos in a Matroska container, with multiple AC3 audio streams (if the film is foreign), subtitles and chapters. The script was written in bash for GNU/Linux.

   Here is the story behind the script, in case you are interested. Skip forward to the next paragraph if you just want teh codez. If you don't know me, I have an HTPC that I set up (XBMC FTW) and I've spent a lot of time ripping my DVD collection to video files. Before I was using Xvid .avi's for compatibility reasons. I recently decided to switch to using Matroska (.mkv) files for the added benefits of having multiple audio tracks, subtitles and chapters in one file. My original script to do this involved a lot of manual changes for each DVD I wanted to encode (it was basically just the actual mencoder line from this new script, copied for each DVD I wanted to encode). This worked fine, but was tedious. I'd have to look up the title for each movie, see if English was supported if it was a foreign film, etc. Now that I decided to package everything in MKVs, it created more steps to my process and I decided to rethink my script. A little while later, this is what I came up with.

   This script was written to simplify encoding DVDs to high quality Xvid videos in a Matroska container, with multiple AC3 audio streams (if the film is foreign), subtitles and chapters. It can also encode all of the titles on a DVD over a certain length, in case you are encoding a DVD containing TV shows, or want to encode special features, etc. The script was written in bash for GNU/Linux. If you use Windows or Mac, too bad. In it’s simplest form it can be used like this:

AutoDVDEncoder.sh BestDVDEver

Before using it, you will need to change a few settings in the script. These are:
  • dvdpath - This is the path to the folder where your DVDs reside. This is not the folder that actually contains the DVD(s). i.e. /home/bob/DVDs not /home/bob/DVDs/SuperAwesomeDVD
  • moviepath - This is the path to the folder where you want the finished movies to go.
  • defaultlanguage - This is the default language. It uses the ISO 639-1 format
  • cores - Specify the number of cores your processor has.
  • assumedlongesttitle - Specify the default title to use when the title cannot be determined.

   The only required argument is the name of a singular DVD. You can also batch encode several DVDs like so:

AutoDVDEncoder.sh LameDVD "Octogenarian Paintball" TheLastChair

It will then try to automatically detect the longest track, crop settings, and use your default language to encode the movies. You can also specify the language of the DVD, if it is foreign with the -l argument, like so:

AutoDVDEncoder.sh "An Island of Crazy" -l ja "OMG Ponies" "It's Effing Cold - A Documentary" -l ru

When you leave out the -l argument for a movie, it will default to the language set in the script. Language codes use the ISO 639-1 format
There are also a total of four ways to specify the title.
1.) Let the script detect it for you. The script will automatically try to find the longest title and use that as the title to rip. The main title isn't always the longest, and it can't always detect the titles, so I made optoions for other ways.
2.) Set it using the -t argument.
3.) Set the title to default to when it can't be found automatically in the script.
4.) Set the title to default to when it can't be found automatically with the -a argument (this overrides the default set in the script).

An example of these would be:

AutoDVDEncoder.sh -a 1 "Extreme Basket Weaving" "The Guy Who Did Something" -t 6

In the above example if the main title for "Extreme Basket Weaving" wasn't found, it would default to 1. The title for "The Guy Who Did Something" would be set at 6.

   I'll try to make a list of dependencies later, but you will at least need libdvdcss, mencoder, mplayer, xvid, mkvtoolnix and lsdvd. Use at your own risk, there is very little error checking and I'm not responsible if you break anything. Anywho, here you go:

No comments:

Post a Comment