MY HDA Project: Automatic Disc Detection, Ripping & Encoding
Posted: Mon Jun 07, 2010 4:37 pm
I've been working for a long time on a set of scripts to make my file server as appliance-like as possible in regards to loading media: Pop a disc in, everything gets moved over, disc gets ejected, media put into encoding queue. At this time I feel conformable enough with their usability to share them with the rest of you. Hopefully this can help some people.
Some parts of this project are fairly well developed, others less-so but still useful. I have also used several well-known applications and scripts available online in this setup and I'll try to touch on each of them.
THE BIG PICTURE
Here's a break-down of the workflow.
[UDEV Rule Detects Disc Mount] => Launch disc identification script. (detectdisc)
Pops up a dialog box asking if you want to cancel automatic ripping, times out in 15 seconds and continues with rip.
-[Video DVD detected] => Launch DVD ripping script. (Qripdvd)
Rip entire DVD to scratch partition, create queue file, eject disc.
-[Audio CD detected] => Launch audio CD ripping/encoding script. (abcde)
ID album, rip, encode and sort into archive, eject disc.
-[Data Disc Detected] => Launch media file copy/sort script. (ripdata)
Media files are found and copied into archive, eject disc.
[Crontab schedules encoding queue manager] => Queue manager script. (Qmanager)
-[Qmanager] => Checks if encoder is already working via a job file, if not, it finds queue
file(s), creates job file (to indicate job is in-progress), launch encoder. (Qencode)
--[Qencode] => Encodes video from disc rip, moves finished file to archive, deletes scratch files.
-[Qmanager] => Removes queue file, job file.
Third-party software and scripts used in this work flow:
HandBrakeCLI
vobcopy
abcde
zenity
Of course, each of these may have their own dependencies and such. You'll have to get all the goodies to compile HandBrakeCLI, I won't go into that right now, maybe later.
MY SCRIPTS!
detectdisc_prompt & detectdisc
The first script "detectdisc_prompt" is the one actually launched by UDEV and in turn it launches the actual script "detectdisc". This is the only way I could make it work.
Qripdvd
Rips video DVD discs and creates a queue file for the manager.
Qmanager
Manages encoding of DVD rips, is scheduled via crontab.
Qencode
This is my baby, the one I've worked on for months now. It has two major functions.
1. By gathering data about the titles on the DVD it attempts to determine if the disc contains a movie, T.V. series episodes or some variation of those. Trust me, it's harder than it sounds.
2. Encodes the movie(s) or episode(s) as a very high quality mkv file with bells and whistles including: original audio pass-thru and stereo mixdown (for small T.V.s), subtitles, English language track detection on foreign language movies, chapters and seek. It's also easily configurable.
ripdata
Admittedly, this is my weakest effort but it seems to do the job. It searches a disc for set groups of file types and copies them into the archive. The search identification function needs some work, but the actual process of copying the files is quite robust. Still, it could use a little help.
EXTRA SCRIPTS
These aren't part of the workflow, but may come in handy.
DVDeval
This is the DVD-type detection coding from the Qencode script (above) as a standalone script. It comes in handy if you want to test the detection output and can also be referenced in your own encoding script since it store it results in tidy variables.
ripdvd
Not to be confused with the Qripdvd (above). This is the actual encoding portion of Qencode, plus the ripping portion of Qripdvd as a standalone script. It references DVDeval to get the info it needs to do the job. As long as it and DVDeval are in the same directory you can use this to rip and encode a mounted DVD.
Also remember, most of these scripts have a bunch of variables that need to be set, like path names and file owners, in order for them to work right. All of those variables are located in at the top of the script so they're easy to find.
Some parts of this project are fairly well developed, others less-so but still useful. I have also used several well-known applications and scripts available online in this setup and I'll try to touch on each of them.
THE BIG PICTURE
Here's a break-down of the workflow.
[UDEV Rule Detects Disc Mount] => Launch disc identification script. (detectdisc)
Pops up a dialog box asking if you want to cancel automatic ripping, times out in 15 seconds and continues with rip.
-[Video DVD detected] => Launch DVD ripping script. (Qripdvd)
Rip entire DVD to scratch partition, create queue file, eject disc.
-[Audio CD detected] => Launch audio CD ripping/encoding script. (abcde)
ID album, rip, encode and sort into archive, eject disc.
-[Data Disc Detected] => Launch media file copy/sort script. (ripdata)
Media files are found and copied into archive, eject disc.
[Crontab schedules encoding queue manager] => Queue manager script. (Qmanager)
-[Qmanager] => Checks if encoder is already working via a job file, if not, it finds queue
file(s), creates job file (to indicate job is in-progress), launch encoder. (Qencode)
--[Qencode] => Encodes video from disc rip, moves finished file to archive, deletes scratch files.
-[Qmanager] => Removes queue file, job file.
Third-party software and scripts used in this work flow:
HandBrakeCLI
vobcopy
abcde
zenity
Of course, each of these may have their own dependencies and such. You'll have to get all the goodies to compile HandBrakeCLI, I won't go into that right now, maybe later.
MY SCRIPTS!
detectdisc_prompt & detectdisc
The first script "detectdisc_prompt" is the one actually launched by UDEV and in turn it launches the actual script "detectdisc". This is the only way I could make it work.
Qripdvd
Rips video DVD discs and creates a queue file for the manager.
Qmanager
Manages encoding of DVD rips, is scheduled via crontab.
Qencode
This is my baby, the one I've worked on for months now. It has two major functions.
1. By gathering data about the titles on the DVD it attempts to determine if the disc contains a movie, T.V. series episodes or some variation of those. Trust me, it's harder than it sounds.
2. Encodes the movie(s) or episode(s) as a very high quality mkv file with bells and whistles including: original audio pass-thru and stereo mixdown (for small T.V.s), subtitles, English language track detection on foreign language movies, chapters and seek. It's also easily configurable.
ripdata
Admittedly, this is my weakest effort but it seems to do the job. It searches a disc for set groups of file types and copies them into the archive. The search identification function needs some work, but the actual process of copying the files is quite robust. Still, it could use a little help.
EXTRA SCRIPTS
These aren't part of the workflow, but may come in handy.
DVDeval
This is the DVD-type detection coding from the Qencode script (above) as a standalone script. It comes in handy if you want to test the detection output and can also be referenced in your own encoding script since it store it results in tidy variables.
ripdvd
Not to be confused with the Qripdvd (above). This is the actual encoding portion of Qencode, plus the ripping portion of Qripdvd as a standalone script. It references DVDeval to get the info it needs to do the job. As long as it and DVDeval are in the same directory you can use this to rip and encode a mounted DVD.
Also remember, most of these scripts have a bunch of variables that need to be set, like path names and file owners, in order for them to work right. All of those variables are located in at the top of the script so they're easy to find.