How-To: Automate DVD & Blu-Ray (Backup, Encoding & Tagging)
Posted: Tue Oct 20, 2009 4:19 am
Batch Rip Actions for Automator
How-to Automate DVD & Blu-Ray (Backup, Encoding & Tagging) for Mac OS X 10.9 Mavericks
Introduction
Backing up a DVD or Blu-Ray library can be an arduous, time consuming task. Using a GUI tool is a simple task if you do one occasionally, but a lot of us have amassed large collections that would take days, weeks, months or even years to complete.
And, if you’ve ever tried to encode an entire season of TV episodes you know how laborious a project this can be as well: Insert a DVD, rip the disc, choose your encode settings, select and add each title to the queue, process the file, add iTunes metadata; rinse and repeat for each of the discs in the season … and don't even get me started on manually doing this with Blu-ray.
The good news is that most of these tasks can be easily automated to remove the manual intervention required. Just insert a disc and it will rip automagically. When done, pop in another. If you’ve got Mac with two or three optical drives connected, fill em' up and you’ll save yourself some trips. Set a repeating encode schedule, and at midnight HandBrakeCLI will encode each track within the min/max duration you set in your workflow. You can even set it do multiple encodes if you'd like an iPad version, Android version, though you owe it to yourself to get an iPhone , and an Apple TV 1080p version. All you need to do now is the tagging, but why should you do it? It's a computer after all … why not automate that as well! If you want to get really fancy, you can take your workflow to the next level by using folder actions or Noodlesoft's Hazel to backup your rips, add the finished files to all the iTunes Libraries on your network and stream em' to an Apple TV. Virtually anything is possible with automation.
This tutorial is broken up into components that can be used individually or together to create one, simple, automated batch workflow.
Workflow Components
Note: This tutorial assumes you have some familiarity with Mac OS X and the ripping/encoding process. The focus of this tutorial is how to AUTOMATE your workflow. It is NOT intended to be A BEGINNERS GUIDE to DVD/BD encoding. If you are new to any of the concepts presented in this tutorial, I highly recommend engaging in some of the fantastic forum threads on the macrumors and handbrake forums to help get you started. Then, return to this tutorial after you have become comfortable with the process and have been successful doing it manually. See the section "Additional Resources" for more info.
About Batch Rip Actions for Automator
Batch Rip Actions for Automator is an application that provides Actions and Workflows to automate the rip and encode process.
These actions began as a series of scripts that made up my batch rip workflow. When I started writing this tutorial, the focus was to illustrate how to create these scripts and tie them together. However, with the introduction of Snow Leopard, it became clear to me that offering pre-compiled Automator actions and Service workflows would make this a much simpler process.
An Automator workflow consists of a sequence of discrete tasks called actions. An Automator action is a kind of functional building block. Each action performs an individual step you might currently do manually‚ such as ripping a disc, changing filenames, encoding files with HandBrake, or tagging files with iTunes metadata. Some actions like Batch Encode, go a step further and perform many operations in one process. For example, with each Blu-ray source it finds … it will create an mkv file, select the main video, audio, and subtitle tracks. Then, send them to HandBrake which will encode it to mp4, then download all the iTunes tags for your title and tag the file. Imagine doing this manually!
Batch Rip Actions for Automator follows the recommended approach of ripping the complete folder structure of your optical media to your hard drive. For DVD media, this is done with FairMount. For BD media, we use MakeMKV. MakeMKV is still in beta and doesn't fully support BD+ titles and may not work with every disc or drive. If MakeMKV doesn't work for you manually, it's not gonna work with Batch Rip Actions for Automator.
Note: MakeMKV and HandBrake do not support every type of copy-protection and may not work with every disc or drive. The rule is, if it doesn't work for you manually, it's not gonna work with Batch Rip Actions for Automator.
If you encounter a disc that MakeMKV or HandBrake can't copy, I highly recommend trying AnyDVDHD. AnyDVDHD is developed by SlySoft.com and is considered the gold standard for disc backup. The upside to AnyDVDHD is that it fully supports Blu-Ray copying and creates a true backup of the entire disc. The downside is that it is Windows only. AnyDVDHD can be used with the free, open source VirtualBox for Mac, VMware Fusion (recommended) and Parallels.
Once the disc's contents have been ripped to the hard drive, the movies or TV episodes are encoded to an iTunes compatible MP4 format and tagged with metadata iTunes, AppleTV or other devices can manage.
The actions provided in this bundle include:
Batch Rip
This action copies video DVD and BD discs to a chosen folder correctly named for automatic tagging.
Batch Encode
This action encodes DVD/BD content to m4v/mkv and tags them with iTunes metadata. This action receives input from the Finder, other actions, or batch folders specified in the action panel. Input types: DVD-ROM, BD-ROM, VIDEO_TS, BDMV, m2ts, mkv, mp4, m4v, avi, mpg, and mov. Other options include: Growl notification, multiple encodes, and custom HandBrake settings.
Add TV Tags
This action searches thetvdb.com database and adds iTunes metadata for the specified TV episode mp4/m4v files. Other options include: renaming, removing tags and optimizing.
Add Movie Tags
This action searches themoviedb.org and tagchimp.com databases and adds iTunes metadata for the specified mp4/m4v files. Other options include: renaming files and folders, removing tags, optimizing, and managing chapter information.
Add Movie Poster
This action will add cover art to selected files.
Add Genre to Movie File
This action tags mp4 files with a selected iTunes genre.
Tag Inspector
This action displays the iTunes metadata for the input file.
Get Source Info from HandBrake
This action scans each source with HandBrakeCLI and saves the info to a text file.
Rename TV Items
This action searches thetvdb.com for shows matching the query and renames items to the selected search result and user specified series, season and episode or disc number.
This tutorial will focus on how to use these actions and their related Automator workflows. But before we get started, we need to install our applications and set up our batch folders.
Getting Started
To complete this tutorial you will need to download and install the following:
Batch Rip Actions for Automator v1.1.1
Installing Batch Rip Actions for Automator
What you need to get started
Batch Rip Actions for Automator requires the following applications be installed in your Applications Folder. For convenience, I've provided links to these applications via the Download menu in the menu bar.
MANDATORY
FairMount v1.1
FairMount is a free tool that allows decryption of DVD content on the fly for a convenient access. FairMount does not perform the actual decryption, it simply forwards the data to libdvdcss which is used for decryption - thus, libdvdcss must be installed for FairMount to work.
Note: Fairmount is included in the application bundle.
HandBrakeCLI v0.9.9
HandBrake is an open-source, GPL-licensed, multiplatform, multithreaded DVD to MPEG-4 converter, available for MacOS X, Linux and Windows. The Command Line Interface version of HandBrake is a lot faster and more flexible than the MacGui. Using scripting you can automate HandBrakeCLI to encode your files as a background process using the same parameters you'd set in the GUI. Install in /Applications.
Note: DVD disc input is only supported if libdvdcss is installed.
libdvdcss v1.2.12
libdvdcss is a simple library designed for accessing DVDs like a block device without having to bother about the decryption. libdvdcss must be installed for Fairmount & HandBrake to work with encrypted DVDs. Run the installer and libdvdcss will be installed in your /usr/lib directory.
FOR BLU-RAY/HD ENCODING, YOU'LL NEED THE FOLLOWING:
MakeMKV v1.6.12
MakeMKV is the only mac native app for ripping Blu-ray discs. However, at this time it may not work with every disc or drive. It converts DVDs and BDs into a set of MKV files. MakeMKV has a GUI and a command-line (makemkvcon) interface that's located in the application's bundle. Install in /Applications.
About Growl Support
Growl v1.3
Growl is a notification system for Mac OS X: it allows applications and scripts that support Growl to send you notifications.
Batch Rip and Batch Encode both contain Growl support. The GrowlNotify command-line tool is needed by these actions to notify the Growl application. GrowlNotify is available from the growl website's general downloads page: Growl's download page.
Managing Your Batch Rip Files and Folders
A well planned folder structure will make your workflow much easier to manage. Most of these workflows rely on consistent paths to the source and destination folders, as well as the paths to the actions and applications themselves. For most users, your files should be processed on your local hard disk. External drives can be used, but in some cases they may slow down the speed of your encoding.
For this tutorial, we'll use your ~/Movies folder as the container for your workflow files and folders. Keeping your workflow under this one directory will make this process much easier. You can then have Hazel or Automator move the finished rips and encoded files to another drive or remote volume after they are done.
IMPORTANT: These workflows rely on one important piece of information that needs to be set for each disc, Video Kind. Video Kind is a variable we use in the actions to identify whether a disc contains a Movie or TV Show. The easiest way I've found to do this is to simply rip TV Shows to one folder and Movies to another. A script can then determine a disc's "kind" based on its location. The Batch Rip action allows you to set the video kind for each disc inserted. Also included are two Services located in your Services folder that will add the “video kind” as a Spotlight comment to selected files or folders.
With the video kind set, the Batch Encode action will know whether to encode every episode for TV Shows or only the main feature for Movies. You can also set unique min/max durations for each video kind. Video kind also helps for auto-tagging. Auto-tagging during the encoding process only works reliably for movies. TV Shows need to be done as a separate process after the files have been encoded to ensure that all the episodes have been verified, and sorted in order.
Creating Your Batch Folders
If you chose to have the installer create your Batch Folders during the workflow installation process, they will be located in your ~/Movies directory. If not, follow the steps below to create your Batch Folders:
Using the Workflow Editor
Batch Rip Actions for Automator includes a series of Automator "Service" workflow files pre-built to work with the actions.
The Actions contained in a workflow can have fields, pop-up menus, checkboxes, and other user-interface elements for configuring the action. Batch Rip Actions for Automator features a Workflow Editor to help you quickly edit and save your workflow options.
To edit a workflow:
Using Batch Rip Service Workflows
A Service is a special type of Automator workflow that can be used from another application or the Finder via contextual menus throughout the OS. Some services require input such as movie files. These types of services can be context sensitive, and only appear in the correct application or if the correct type of input is selected.
In this tutorial, there are two ways we run Services:
Using Batch Rip to Automate DVD/BD Ripping
Batch Rip uses several technologies to automate the ripping process. For DVDs, FairMount and libdvdcss (installed separately) are used to decrypt the DVDs on your system. A subroutine within the Action will then copy the entire DVD to your hard drive. Also, if your have more than one DVD drive, this Action will allow multiple DVDs to copy at the same time. The Action also includes Growl notification support, option to search for show/movie titles for the copy, and an option to eject the discs when finished.
For Blu-Ray, the process is essentially the same, except we use MakeMKV which extracts each title that's between the min/max duration you set in the action. The action also includes an option to do a full BD backup. BD discs are processed sequentially.
Using the Batch Rip Services
There are two Automator Services that can be used with the Batch Rip action.
Batch Rip • Batch Rip.workflow
This service receives no input and will act on all mounted video discs. If a BD-ROM or DVD-ROM is mounted, this Service displays a prompt that will cancel after 30 seconds, if no action is received from the user. The prompt will ask if you'd like to copy the disc. Choosing Movie or TV Show will set the video kind for that disc; and repeat for each disc mounted. The action will then copy each disc to your Batch Rip TV or Batch Rip Movies folder. There is also an option to search and select the correct "title" for your source disc which will help for auto-tagging later. You can also set the action to run automatically which disables the dialogs and uses the default video kind set in the action panel.
To use it: Open the application menu (to the right of the Apple menu), choose Services > "Batch Rip • Batch Rip".
Batch Rip • Batch Rip (Finder).workflow
This Service will act only on items passed as input via the Finder, another Action, or a script.
To use it via the Finder: Select the discs you'd like to copy and run the service. Only the selected items will be processed.
To use it via another script: Pipe the input folders as a list with each source on its own line. Here's an example:
Customizing your Batch Rip Workflow
Using Batch Rip Dispatcher
Batch Rip Dispatcher is a LaunchAgent that monitors your /Volumes directory for BD-ROM or DVD-ROM discs. It will automatically activate the "Batch Rip • Batch Rip (Finder).workflow" when a disc is detected. To control Batch Rip Dispatcher, Click the status display in the Workflow Editor toolbar to turn it On or Off.
Testing your Batch Rip Workflow
A Few Words on Source Folder and File Naming
Many applications use the file or folder name to get content info and cover art from sites like tagchimp.com, themoviedb.org and thetvdb.com. It is considered good practice to rename your files and folders, BEFORE encoding your final files. Your source files will then be named correctly making them easier to manage later. In addition, your output files will also be named correctly, allowing for a script or application to associate the correct metadata for your content.
For TV Show sources the naming convention is: <Show Name - S#D#> or Veronica Mars - S1D1. The "D#" represents the disc number. If your using MakeMKV (which creates separate files for each episode), it will add -1, -2, etc. to the end of the filename. Example: Veronica Mars - S1D1-1.mkv. More information on tagging and renaming your final TV show files will be discussed in later chapter.
For movies the naming convention is: <Movie Name (year)>. Example: X-Men Origins - Wolverine (2009). Note that titles that contain a colon [:] are replaced with a space and a dash [ -], as filenames cannot contain this character.
To make this process easier and more reliable, I've provided Automator Services that will search themoviedb.org or thetvdb.com for the correct Movie or Show Title, and automatically rename your file or folder. Just select the files or folders you want to rename and run the Service. A dialog box will appear, enter the title to search. Select the name and year that matches your content and the Service will then rename your item. The Service will loop through each item incrementally. This process has also been added as an option to Batch Rip.action which will prompt a search before copying the discs.
Additionally, there are Rename & Tag Services provided for both TV and Movies; that will rename and tag selected items with iTunes metadata.
Note: themoviedb.org and thetvdb.com are free online services. Periodic outages are not uncommon. If data is not returned, the service may be down.
Using the "Rename Movie Items" and "Rename TV Items" services
Using Batch Encode to Automate HandBrake Encoding
This Automator Action incorporates many of the tasks commonly used for processing files and includes growl support. The input sources can be files or folders located in your "Batch Rip TV" and "Batch Rip Movies" folders, or optical discs mounted on your system.
If the input source resides in your Batch Rip TV folder or its Spotlight comment is set to "TV Show" the script will select each track that's between the min/max duration set in the script. If the input source resides in your Batch Rip Movies folder, or its Spotlight comment is set to "Movie", only one track is selected, provided it's between the min/max duration you set in the script for movies. The encode script will then encode and output the selected titles to your Batch Encode folder.
The input types supported: Blu-Ray Disc, BDMV, DVD-VIDEO Disc, VIDEO_TS, avi, mp4, m4v, mkv, m2ts, mov and mpg.
The output types supported: m4v (mp4) and mkv.
Encode Targets: The action will output up to four encoded files for each source. Each encode target will be processed using its selected preset.
Presets: Different encode settings can be selected for each encode target. All preset encode settings are based on HandBrake's presets for compatibility with Apple devices.
Custom Presets: You can create up to four custom presets using standard HandBrakeCLI arguments. A custom preset can be selected for each encode target.
Audio Selection: Batch Encode will set the default audio track using the option selected in the workflow. "Default Audio" sets the default audio track to the source's "default" audio track. If set to "Native Language", Batch Encode will select an audio track (if available) that matches the native language preference set in the workflow. If an audio track is not available in your native language, it will try to find one that matches the alternate language preference set in the workflow. If neither are available, it will fallback to the title's default audio track.
Additional Audio Tracks: Batch Encode will include additional audio tracks if selected in the workflow. Options include: all Native Language tracks, all Alternate Language tracks, all Native & Alternate language tracks, and All Tracks (regardless of language). There is also an option to mixdown these additional tracks to 2-channel DPL2 for a smaller file size. If disabled, any selected multi-channel tracks will be passed-through as AC3.
Subtitle Selection: There are two basic options for subtitles, Burn-In and Pass-Thru. Burned in subtitles are written on top of the image permanently. Pass-thru subtitles will appear as separate selectable tracks in your output file. With the correct playback software, you’ll be able to enable / disable these subtitles as required. The Burn-In "Auto Detect" option will burn in forced-only subtitles (if available) in your native language; or all subtitles, if the default audio track language is not in the native language set in the action. Burn-In "Native Language" will burn in subtitles in your native language (if available) regardless of the default audio track language. The Pass-Thru option will pass-thru "text-based" subtitle tracks that match the language preference set in the action. Due to mp4 file limititations and HandBrake capabilities, picture-based subtitles cannot be passed-through. They can however be burned-in, but only 1 track can be burned-in to the video. See the HandBrake wiki for more info.
Multi-Channel Audio: The Batch Encode action includes a sub-routine that will set the audio output settings differently depending on the audio source and encoding preset selected. If an HB preset has multi-channel capability, the sub-routine will favor multi-channel audio (DTS or AC-3) over 2-channel tracks. If the audio codec is DTS, HandBrake will convert DTS to AC-3 since DTS pass-thru is not an option for most devices. All multi-channel tracks will also include a secondary stereo aac track for compatability. Presets that do not natively support multi-channel include: iPod, iPad, iPhone and Android devices.
iTunes Tagging: Once a m4v file is encoded, movies are then optionally embedded with iTunes XML style metadata, cover art and chapter names via theMovieDB.org and tagchimp.com API's. If a 720p or higher m4v file is encoded, the HD flag is set to allow the HD or HD/SD logo to appear in iTunes and the AppleTV. If an HD and SD m4v is created from the same source, they will both be set with the same cnid number. Having the same cnid number will allow the SD and HD versions to show up as one entry in iTunes.
Other Options: There are "Override" settings in the script to allow you to ignore the optical drive and set the video kind for optical sources.
Batch Encode Services
There are two Automator Services provided to use with Batch Encode.
Batch Rip • Batch Encode.workflow
This service receives no input and will act on all files or folders located in your "Batch Rip TV" and "Batch Rip Movies" folders, or optical discs mounted on your system (if Ignore Optical is not selected).
To use it: Open the application menu (to the right of the Apple menu), choose Services > "Batch Rip • Batch Encode".
Batch Rip • Batch Encode (Finder).workflow
This Service will act only on items passed as input via the Finder, another Action, or a script.
To use it via the Finder: Select the files, folders or discs you'd like to encode and run the service. Only the selected items will be processed.
To use it via another script: Pipe the input files or folders as a list with each source on its own line. Here's an example:
Customizing your Batch Encode Workflow
Testing your Batch Encode Workflow
Setting Batch Encode to Run Automatically
How to Automate Movie File Tagging with iTunes Style Metadata
There are three services provided to add iTunes metadata and cover art using the Add Movie Tags Action:
Using Batch Rip • Add Movie Tags (Search)
This service will display a list of possible matches from themoviedb.org database based on your search criteria. The service will then tag the file with metadata for the title selected.
Using Batch Rip • Add Movie Tags (Filename)
This service will tag each file based on its filename with metadata from themoviedb.org database.
IMPORTANT: Your input files must be named properly with the following naming convention: Movie Name (year).m4v ( example: X-Men Origins - Wolverine (2009).m4v ). Titles that contain a colon [:] are replaced with a space and a dash [ -], as filenames cannot contain this character (see the section on file and folder renaming for more information). There is also a Rename & Tag Movie Items Service included in the Services menu if you also need to rename and tag your finished files.
Using Batch Rip • Rename & Tag Movie Items
This service works like Add Movie Tags (Search) but will rename the file after tagging. See the section on Using the Add Movie Tags (Search) Service for more information.
Changing options for Add Movie Tags Services
Each Service is designed to perform a certain function, however there are options available in the Add Movie Tags Action panel that you may want to tailor to fit your needs.
How to Automate TV Show File Tagging with iTunes Style Metadata
There are three services provided to add iTunes metadata and cover art using the Add TV Tags Action:
Using Batch Rip • Add TV Tags (Search)
This service will display a list of possible matches from thetvdb.com database based on your search criteria, then tag the files with the cover art and iTunes metadata for the show, season and episode.
Using Batch Rip • Add TV Tags (Filename)
This service will tag each file based on its filename with metadata from thetvdb.com database.
IMPORTANT: Your input files must be named properly with the following naming convention: <Show Name - S##E##> (ex. Veronica Mars - S01E02.m4v). The "S##" signifies the season number and the "E##" represents the episode number. There is also a Rename & Tag TV Items Service included in the Services menu if you also need to rename and tag your finished files.
Rename & Tag TV Items Service
This service works like Add TV Tags (Search) but will rename the file before tagging. See the section on Using the Add TV Tags (Search) Service for more information. The files will be renamed with the following naming convention: <Show Name - S##E##> (ex. Veronica Mars - S01E02.m4v). If multiple files are selected, the service will rename each file with the same show title and season number. The episode number will be assigned sequentially, starting with the episode number you specify when prompted.
IMPORTANT: If you are batch renaming files, they must be pruned and in episodic order BEFORE running this service: I recommend appending each file name with a number. This number does not have to represent the episode number, just a number to keep them in numerical order.
If your are using the Batch Encode Action to encode your TV files, the action will automatically include the title number at the end of the name (example: Veronica Mars - S1D1-1). The files will most likely already be in order with the disc number and title number, but this isn't always the case. You should always verify that all the episodes are present, any extras that may have been encoded are removed, and the files are in the correct order before running this service. Visit thetvdb.com to check your show and season to verify the number of episodes and check your files.
Note, that some discs may present two-part episodes as one title. In this case, these files should be processed in sets (example: if the season starts with a two-parter, process episode …E01. Process your next set with your number sequence starting at …E03, skipping …E02).
IMPORTANT: Thetvdb.com database has different options for episode ordering, Date Aired and DVD Order. Be sure to check the website to verify the correct order for your files. In most cases it will be DVD. However, some blu-ray discs have been released with a different sort order than the DVD versions. So, it’s good practice to check before renaming or tagging your files and select the appropriate "Sort Order" option in your workflow.
Using the Rename & Tag TV Items Service
Customizing your Add TV Tags Services
Each Service is designed to perform a certain function, however there are options available in the Add TV Tags Action panel that you may want to tailor to fit your needs.
-
Managing your Media with Hazel
Moving files around can be a chore, especially if you have an elaborate Mac media setup. Rather than going into each step in detail, I'll just touch on a few concepts that might peak some interest in how automation can help manage files on a multi-Mac setup.
The Batch Rip and Batch Encode workflow provide a few elements that will allow you to easily automate and organize your media. The key components are "Finder Label Index" (File/Folder Color) and "Spotlight Comments" (Finder Comments).
Spotlight Comments used in Batch Rip Actions for Automator:
Hazel http://www.noodlesoft.com is a preference pane that allows you to set up Rules based on a file's Spotlight data and specify actions to take when an item matches the Rules. This is similar to the way Smart Playlists function in iTunes and Smart Albums in iPhoto.
For example: If a file or folder located in our "Batch Rip TV" or "Batch Rip Movies" has a gray Label color we can assume it has already been encoded since the Batch Encode Script will change its color to gray after it has been encoded. We can set a rule in Hazel that will move any file/folder that's gray to a "Backup" drive. One nice thing about Hazel is that it will move the source file to the target location, not just copy it. It has some intelligence and safeguards built in to know if a file has been moved successfully and then deletes the source file, freeing up more space on our Batch Rip volume.
We can also have Hazel monitor our Batch Encode folder for files that have the extension ".m4v", have a Spotlight comment set to Movie, and have a "Finder Label" that is green. If a file has a green label, we can assume it has already been tagged with metadata so it should be considered a finished file. If all these criteria match, we can have Hazel then automatically move the file to our Movie library folder, then add the file to our local iTunes library, then change its color label to purple. You can even set up Hazel on a remote Mac to monitor the Movie folder via file sharing and add and movie file that's color label is purple and add it to its iTunes libraries as well, then change its color. You can repeat this with every Mac on your network to easily sync every added file. You can also duplicate this workflow for TV Shows as well keeping the files in separate folders and automatically creating subfolders based on the show name and season.
In addition to m4v files, we can have a similar Rule for our Batch Encode folder that looks for ".mkv" files with a Spotlight Comment of Movies or TV Shows and move them to a Plex depository on a local or network drive.
Hazel also allows for scripts to run when an item matches our rules. For example, with the "Move existing file to retired folder" option in the Batch Encode action enabled, you can have Hazel run an AppleScript that will remove the existing movie or TV show from iTunes when its file is added to the retired folder set in the action, helping to prevent duplicates in your library.
Hazel is a do-it-as-it-happens approach. The disc rips, the file encodes, the file is tagged, the source is backed up, the 1080p mkv is sent to a Plex folder, the m4v file is moved to my library, the file is then added to all my iTunes libraries and is sync'd to my Apple TV's. Simple and done.
The point is with a few triggers, you can easily automate the process of moving, organizing and syncing your media. I prefer Hazel for it's versatility and ease of use, but a lot of what Hazel provides can also be done with Folder Actions … but with a lot more work.
Conclusion
I hope you enjoyed this tutorial. If you've made it to the end, kudos to you. This process has been a great learning experience for me and hope it is for you as well. The elements of this workflow really demonstrate the power Mac OS X has with Unix, AppleScript, Automator and a brilliant developer community. Though this tutorial is a bit more involved than I had anticipated, I can attest that once you've got it going, you will spend less time managing your content and more time enjoying it. If you’d like to dig a little deeper, there are additional resources listed below. Happy Encoding!
Additional Resources:
Batch Rip Help: In the app under the Help menu or via Mac's Help Center.
How To: Rip, Encode and Combine Using Fairmount & DTOX
Native Blu-ray ripping for OS X
Blu-Ray to Apple TV
Advanced Bluray/HDDVD Workflow & Features
Subler
Older automation thread
How-To: Automate DVD Backup w/ FairMount & HandBrake
How-to Automate DVD & Blu-Ray (Backup, Encoding & Tagging) for Mac OS X 10.9 Mavericks
Introduction
Backing up a DVD or Blu-Ray library can be an arduous, time consuming task. Using a GUI tool is a simple task if you do one occasionally, but a lot of us have amassed large collections that would take days, weeks, months or even years to complete.
And, if you’ve ever tried to encode an entire season of TV episodes you know how laborious a project this can be as well: Insert a DVD, rip the disc, choose your encode settings, select and add each title to the queue, process the file, add iTunes metadata; rinse and repeat for each of the discs in the season … and don't even get me started on manually doing this with Blu-ray.
The good news is that most of these tasks can be easily automated to remove the manual intervention required. Just insert a disc and it will rip automagically. When done, pop in another. If you’ve got Mac with two or three optical drives connected, fill em' up and you’ll save yourself some trips. Set a repeating encode schedule, and at midnight HandBrakeCLI will encode each track within the min/max duration you set in your workflow. You can even set it do multiple encodes if you'd like an iPad version, Android version, though you owe it to yourself to get an iPhone , and an Apple TV 1080p version. All you need to do now is the tagging, but why should you do it? It's a computer after all … why not automate that as well! If you want to get really fancy, you can take your workflow to the next level by using folder actions or Noodlesoft's Hazel to backup your rips, add the finished files to all the iTunes Libraries on your network and stream em' to an Apple TV. Virtually anything is possible with automation.
This tutorial is broken up into components that can be used individually or together to create one, simple, automated batch workflow.
Workflow Components
- Getting Started
- Using Batch Rip to Automate DVD & Blu-Ray Backup
- Renaming Source Files & Folders
- Using Batch Encode to Automate HandBrake Encoding
- Auto-tagging Movie Files with iTunes Metadata
- Auto-tagging TV Show Files with iTunes Metadata
- Using Hazel to manage your media
Note: This tutorial assumes you have some familiarity with Mac OS X and the ripping/encoding process. The focus of this tutorial is how to AUTOMATE your workflow. It is NOT intended to be A BEGINNERS GUIDE to DVD/BD encoding. If you are new to any of the concepts presented in this tutorial, I highly recommend engaging in some of the fantastic forum threads on the macrumors and handbrake forums to help get you started. Then, return to this tutorial after you have become comfortable with the process and have been successful doing it manually. See the section "Additional Resources" for more info.
About Batch Rip Actions for Automator
Batch Rip Actions for Automator is an application that provides Actions and Workflows to automate the rip and encode process.
These actions began as a series of scripts that made up my batch rip workflow. When I started writing this tutorial, the focus was to illustrate how to create these scripts and tie them together. However, with the introduction of Snow Leopard, it became clear to me that offering pre-compiled Automator actions and Service workflows would make this a much simpler process.
An Automator workflow consists of a sequence of discrete tasks called actions. An Automator action is a kind of functional building block. Each action performs an individual step you might currently do manually‚ such as ripping a disc, changing filenames, encoding files with HandBrake, or tagging files with iTunes metadata. Some actions like Batch Encode, go a step further and perform many operations in one process. For example, with each Blu-ray source it finds … it will create an mkv file, select the main video, audio, and subtitle tracks. Then, send them to HandBrake which will encode it to mp4, then download all the iTunes tags for your title and tag the file. Imagine doing this manually!
Batch Rip Actions for Automator follows the recommended approach of ripping the complete folder structure of your optical media to your hard drive. For DVD media, this is done with FairMount. For BD media, we use MakeMKV. MakeMKV is still in beta and doesn't fully support BD+ titles and may not work with every disc or drive. If MakeMKV doesn't work for you manually, it's not gonna work with Batch Rip Actions for Automator.
Note: MakeMKV and HandBrake do not support every type of copy-protection and may not work with every disc or drive. The rule is, if it doesn't work for you manually, it's not gonna work with Batch Rip Actions for Automator.
If you encounter a disc that MakeMKV or HandBrake can't copy, I highly recommend trying AnyDVDHD. AnyDVDHD is developed by SlySoft.com and is considered the gold standard for disc backup. The upside to AnyDVDHD is that it fully supports Blu-Ray copying and creates a true backup of the entire disc. The downside is that it is Windows only. AnyDVDHD can be used with the free, open source VirtualBox for Mac, VMware Fusion (recommended) and Parallels.
Once the disc's contents have been ripped to the hard drive, the movies or TV episodes are encoded to an iTunes compatible MP4 format and tagged with metadata iTunes, AppleTV or other devices can manage.
The actions provided in this bundle include:
Batch Rip
This action copies video DVD and BD discs to a chosen folder correctly named for automatic tagging.
Batch Encode
This action encodes DVD/BD content to m4v/mkv and tags them with iTunes metadata. This action receives input from the Finder, other actions, or batch folders specified in the action panel. Input types: DVD-ROM, BD-ROM, VIDEO_TS, BDMV, m2ts, mkv, mp4, m4v, avi, mpg, and mov. Other options include: Growl notification, multiple encodes, and custom HandBrake settings.
Add TV Tags
This action searches thetvdb.com database and adds iTunes metadata for the specified TV episode mp4/m4v files. Other options include: renaming, removing tags and optimizing.
Add Movie Tags
This action searches themoviedb.org and tagchimp.com databases and adds iTunes metadata for the specified mp4/m4v files. Other options include: renaming files and folders, removing tags, optimizing, and managing chapter information.
Add Movie Poster
This action will add cover art to selected files.
Add Genre to Movie File
This action tags mp4 files with a selected iTunes genre.
Tag Inspector
This action displays the iTunes metadata for the input file.
Get Source Info from HandBrake
This action scans each source with HandBrakeCLI and saves the info to a text file.
Rename TV Items
This action searches thetvdb.com for shows matching the query and renames items to the selected search result and user specified series, season and episode or disc number.
This tutorial will focus on how to use these actions and their related Automator workflows. But before we get started, we need to install our applications and set up our batch folders.
Getting Started
To complete this tutorial you will need to download and install the following:
Batch Rip Actions for Automator v1.1.1
Installing Batch Rip Actions for Automator
- Download the Batch Rip Actions for Automator installer.
- Open the dmg file and Drag the app to your Applications folder.
- Navigate to your Applications folder.
- Double-click the icon to Launch the app.
- Follow the installation instructions to install the related workflow files and create your Batch Rip folders.
What you need to get started
Batch Rip Actions for Automator requires the following applications be installed in your Applications Folder. For convenience, I've provided links to these applications via the Download menu in the menu bar.
MANDATORY
FairMount v1.1
FairMount is a free tool that allows decryption of DVD content on the fly for a convenient access. FairMount does not perform the actual decryption, it simply forwards the data to libdvdcss which is used for decryption - thus, libdvdcss must be installed for FairMount to work.
Note: Fairmount is included in the application bundle.
HandBrakeCLI v0.9.9
HandBrake is an open-source, GPL-licensed, multiplatform, multithreaded DVD to MPEG-4 converter, available for MacOS X, Linux and Windows. The Command Line Interface version of HandBrake is a lot faster and more flexible than the MacGui. Using scripting you can automate HandBrakeCLI to encode your files as a background process using the same parameters you'd set in the GUI. Install in /Applications.
Note: DVD disc input is only supported if libdvdcss is installed.
libdvdcss v1.2.12
libdvdcss is a simple library designed for accessing DVDs like a block device without having to bother about the decryption. libdvdcss must be installed for Fairmount & HandBrake to work with encrypted DVDs. Run the installer and libdvdcss will be installed in your /usr/lib directory.
FOR BLU-RAY/HD ENCODING, YOU'LL NEED THE FOLLOWING:
MakeMKV v1.6.12
MakeMKV is the only mac native app for ripping Blu-ray discs. However, at this time it may not work with every disc or drive. It converts DVDs and BDs into a set of MKV files. MakeMKV has a GUI and a command-line (makemkvcon) interface that's located in the application's bundle. Install in /Applications.
About Growl Support
Growl v1.3
Growl is a notification system for Mac OS X: it allows applications and scripts that support Growl to send you notifications.
Batch Rip and Batch Encode both contain Growl support. The GrowlNotify command-line tool is needed by these actions to notify the Growl application. GrowlNotify is available from the growl website's general downloads page: Growl's download page.
- Download and install Growl from the Mac App Store.
- Download GrowlNotify
- Double-click the GrowlNotify.pkg to install GrowlNotify.
- Enter your administrator password and growlNotify will then be installed in a hidden directory used for command line tools: /usr/local/bin
- To activate notification by email or speech, navigate to the Growl Preferences and click enable in the GrowlNotify application notification settings.
Managing Your Batch Rip Files and Folders
A well planned folder structure will make your workflow much easier to manage. Most of these workflows rely on consistent paths to the source and destination folders, as well as the paths to the actions and applications themselves. For most users, your files should be processed on your local hard disk. External drives can be used, but in some cases they may slow down the speed of your encoding.
For this tutorial, we'll use your ~/Movies folder as the container for your workflow files and folders. Keeping your workflow under this one directory will make this process much easier. You can then have Hazel or Automator move the finished rips and encoded files to another drive or remote volume after they are done.
IMPORTANT: These workflows rely on one important piece of information that needs to be set for each disc, Video Kind. Video Kind is a variable we use in the actions to identify whether a disc contains a Movie or TV Show. The easiest way I've found to do this is to simply rip TV Shows to one folder and Movies to another. A script can then determine a disc's "kind" based on its location. The Batch Rip action allows you to set the video kind for each disc inserted. Also included are two Services located in your Services folder that will add the “video kind” as a Spotlight comment to selected files or folders.
With the video kind set, the Batch Encode action will know whether to encode every episode for TV Shows or only the main feature for Movies. You can also set unique min/max durations for each video kind. Video kind also helps for auto-tagging. Auto-tagging during the encoding process only works reliably for movies. TV Shows need to be done as a separate process after the files have been encoded to ensure that all the episodes have been verified, and sorted in order.
Creating Your Batch Folders
If you chose to have the installer create your Batch Folders during the workflow installation process, they will be located in your ~/Movies directory. If not, follow the steps below to create your Batch Folders:
- Navigate to your ~/Movies folder.
- Create two folders and rename them Batch Rip TV and Batch Rip Movies. These folders will be used as the destination folders for your ripped files when copied from DVDs and BDs using the Batch Rip action. These folders will also be the source folders for the Batch Encode action.
- Create another folder named Batch Encode. This folder will be the destination folder for your final encoded m4v/mkv files when using the Batch Encode action.
Using the Workflow Editor
Batch Rip Actions for Automator includes a series of Automator "Service" workflow files pre-built to work with the actions.
The Actions contained in a workflow can have fields, pop-up menus, checkboxes, and other user-interface elements for configuring the action. Batch Rip Actions for Automator features a Workflow Editor to help you quickly edit and save your workflow options.
To edit a workflow:
- Choose a workflow from the source list on the left side of the Workflow Editor.
- The workflow will open in the layout view on the right side of the window.
- Configure the action as desired.
- To save your changes, Open the File menu and Choose Save.
Using Batch Rip Service Workflows
A Service is a special type of Automator workflow that can be used from another application or the Finder via contextual menus throughout the OS. Some services require input such as movie files. These types of services can be context sensitive, and only appear in the correct application or if the correct type of input is selected.
In this tutorial, there are two ways we run Services:
- Open the application menu (to the right of the Apple menu), choose Services, and then choose the service you want to use.
- Open a contextual menu by Control-clicking on an item (or a group of items), choose Services, and then choose the service you want to use.
Using Batch Rip to Automate DVD/BD Ripping
Batch Rip uses several technologies to automate the ripping process. For DVDs, FairMount and libdvdcss (installed separately) are used to decrypt the DVDs on your system. A subroutine within the Action will then copy the entire DVD to your hard drive. Also, if your have more than one DVD drive, this Action will allow multiple DVDs to copy at the same time. The Action also includes Growl notification support, option to search for show/movie titles for the copy, and an option to eject the discs when finished.
For Blu-Ray, the process is essentially the same, except we use MakeMKV which extracts each title that's between the min/max duration you set in the action. The action also includes an option to do a full BD backup. BD discs are processed sequentially.
Using the Batch Rip Services
There are two Automator Services that can be used with the Batch Rip action.
Batch Rip • Batch Rip.workflow
This service receives no input and will act on all mounted video discs. If a BD-ROM or DVD-ROM is mounted, this Service displays a prompt that will cancel after 30 seconds, if no action is received from the user. The prompt will ask if you'd like to copy the disc. Choosing Movie or TV Show will set the video kind for that disc; and repeat for each disc mounted. The action will then copy each disc to your Batch Rip TV or Batch Rip Movies folder. There is also an option to search and select the correct "title" for your source disc which will help for auto-tagging later. You can also set the action to run automatically which disables the dialogs and uses the default video kind set in the action panel.
To use it: Open the application menu (to the right of the Apple menu), choose Services > "Batch Rip • Batch Rip".
Batch Rip • Batch Rip (Finder).workflow
This Service will act only on items passed as input via the Finder, another Action, or a script.
To use it via the Finder: Select the discs you'd like to copy and run the service. Only the selected items will be processed.
To use it via another script: Pipe the input folders as a list with each source on its own line. Here's an example:
Code: Select all
echo -e "/Volumes/IRON_MAN_D1\n/Volumes/DVD_VIDEO" | automator -i - "/Users/username/Library/Services/Batch Rip • Batch Rip (Finder).workflow"
Customizing your Batch Rip Workflow
- In the Workflow Editor, Select the "Batch Rip • Batch Rip" workflow.
- Set the options in the action panel.
- Run Automatically (disables dialog boxes and runs without user intervention). Not recommended for new users.
- BD-ROM & DVD-ROM check-boxes (the workflow will act only on the disc types selected).
- Default video kind (when Run Automatically is set, this selection will copy all discs to either Batch Rip Movies or TV Folder).
- Skip Duplicates prevents copying a disc if it already exists. If unchecked, it will copy the disc and append a number to the name of the new copy (useful in situations where a series of discs have the same name).
- Search for show/movie titles will add an additional prompt to search themoviedb/thetvdb for the correct title and release year. Your copy will be named with the selected search result. This is useful for auto-tagging with the Batch Encode action.
- The path to the Fairmount application include in the app bundle is already set. Note: libdvdcss is required in order for Fairmount to run.
- Set the time in seconds for the action to skip processing a disc if Fairmount fails to remount it as a disk image (default is 120 secs).
- Set the path to the MakeMKV application.
- Set your output directories (see section on Folder Setup for more info).
- Set the minimum and maximum duration for TV and Movies sources (MakeMKV will only extract tracks between these min/max durations).
- Choose additional options: Enable Growl, Eject disc when done, Use MakeMKV for DVD (instead of Fairmount), Full BD Backup.
- To save your changes, Open the File menu and Choose Save.
Using Batch Rip Dispatcher
Batch Rip Dispatcher is a LaunchAgent that monitors your /Volumes directory for BD-ROM or DVD-ROM discs. It will automatically activate the "Batch Rip • Batch Rip (Finder).workflow" when a disc is detected. To control Batch Rip Dispatcher, Click the status display in the Workflow Editor toolbar to turn it On or Off.
- When activated (Green), Batch Rip Dispatcher will start watching for discs. It will then launch "Batch Rip • Batch Rip.workflow" whenever a BD-ROM or DVD-ROM is mounted.
-
- - When disabled (Clear), Batch Rip Dispatcher will deactivate and no action will be taken when a disc is inserted.
-
- - You can enable or disable Batch Rip Dispatcher at any time by clicking the status display in the Workflow Editor toolbar.
Testing your Batch Rip Workflow
- Make sure Batch Rip Dispatcher's status indicator is Green, indicating that it's enabled.
- Insert a BD or DVD. Wait for the disc to mount.
- If you have more than one optical drive, a prompt will appear asking if you'd like to Continue. Click Continue when all discs are mounted.
- Next, a dialog box to appear asking if you’d like to copy the disc. Choose either TV Show (if the disc contains TV shows) or Movies (if disc contains movies). Choosing Ignore will ignore the disc and cancel the action. Note: no dialog will appear if you have set the action to "Run automatically".
- If "Search for Show/Movie Titles" is enabled, you'll get additional prompts to name each disc.
IMPORTANT: If DVD Player.app is set to launch when a Video DVD is mounted, set "Video DVD" to "Ignore" in the CD & DVDs Preference Pane.
-
- - The action will launch Terminal and display the basic setup info. If you have any errors they will be presented here, such as missing apps or incorrect paths. It will also display the options you set in the action.
- The action will copy each disc to the selected TV or Movie output folder.
- For DVDs, FairMount will launch automatically, then you'll see a graphic of cream cheese being spread on a bagel.
- The DVD will unmount and re-mount as a disk image.
- After a short delay, the DVD will start copying.
-
- - FairMount will display the progress as well as any bad sectors it encounters.
Note: Some DVD's may contain copy protection measures that will result in bad sectors and a failed rip using FairMount. For these situations, it may be necessary to rip the DVD with other software such as DVD2One where you can adjust the settings manually. - For BDs, makemkvcon will extract the titles in the background, but the Terminal window will display the progress.
- If you've set up growl support, you will be notified by display, speech or email when completed.
-
A Few Words on Source Folder and File Naming
Many applications use the file or folder name to get content info and cover art from sites like tagchimp.com, themoviedb.org and thetvdb.com. It is considered good practice to rename your files and folders, BEFORE encoding your final files. Your source files will then be named correctly making them easier to manage later. In addition, your output files will also be named correctly, allowing for a script or application to associate the correct metadata for your content.
For TV Show sources the naming convention is: <Show Name - S#D#> or Veronica Mars - S1D1. The "D#" represents the disc number. If your using MakeMKV (which creates separate files for each episode), it will add -1, -2, etc. to the end of the filename. Example: Veronica Mars - S1D1-1.mkv. More information on tagging and renaming your final TV show files will be discussed in later chapter.
For movies the naming convention is: <Movie Name (year)>. Example: X-Men Origins - Wolverine (2009). Note that titles that contain a colon [:] are replaced with a space and a dash [ -], as filenames cannot contain this character.
To make this process easier and more reliable, I've provided Automator Services that will search themoviedb.org or thetvdb.com for the correct Movie or Show Title, and automatically rename your file or folder. Just select the files or folders you want to rename and run the Service. A dialog box will appear, enter the title to search. Select the name and year that matches your content and the Service will then rename your item. The Service will loop through each item incrementally. This process has also been added as an option to Batch Rip.action which will prompt a search before copying the discs.
Additionally, there are Rename & Tag Services provided for both TV and Movies; that will rename and tag selected items with iTunes metadata.
Note: themoviedb.org and thetvdb.com are free online services. Periodic outages are not uncommon. If data is not returned, the service may be down.
Using the "Rename Movie Items" and "Rename TV Items" services
- Select a movie file or folder, choose Services, and then choose > "Batch Rip • Rename Movie Items" - or - "Batch Rip • Rename TV Items"
-
- - A dialog box will appear listing the active item. Enter the title in the search field for this item and Choose OK.
-
- - The action will search the database and return a list of possible matches. Choose the title and year that matches your file or folder.
-
- - Choose OK, and the action will rename your item to the selection. The action will repeat for each selected item.
-
Using Batch Encode to Automate HandBrake Encoding
This Automator Action incorporates many of the tasks commonly used for processing files and includes growl support. The input sources can be files or folders located in your "Batch Rip TV" and "Batch Rip Movies" folders, or optical discs mounted on your system.
If the input source resides in your Batch Rip TV folder or its Spotlight comment is set to "TV Show" the script will select each track that's between the min/max duration set in the script. If the input source resides in your Batch Rip Movies folder, or its Spotlight comment is set to "Movie", only one track is selected, provided it's between the min/max duration you set in the script for movies. The encode script will then encode and output the selected titles to your Batch Encode folder.
The input types supported: Blu-Ray Disc, BDMV, DVD-VIDEO Disc, VIDEO_TS, avi, mp4, m4v, mkv, m2ts, mov and mpg.
The output types supported: m4v (mp4) and mkv.
Encode Targets: The action will output up to four encoded files for each source. Each encode target will be processed using its selected preset.
Presets: Different encode settings can be selected for each encode target. All preset encode settings are based on HandBrake's presets for compatibility with Apple devices.
Custom Presets: You can create up to four custom presets using standard HandBrakeCLI arguments. A custom preset can be selected for each encode target.
Audio Selection: Batch Encode will set the default audio track using the option selected in the workflow. "Default Audio" sets the default audio track to the source's "default" audio track. If set to "Native Language", Batch Encode will select an audio track (if available) that matches the native language preference set in the workflow. If an audio track is not available in your native language, it will try to find one that matches the alternate language preference set in the workflow. If neither are available, it will fallback to the title's default audio track.
Additional Audio Tracks: Batch Encode will include additional audio tracks if selected in the workflow. Options include: all Native Language tracks, all Alternate Language tracks, all Native & Alternate language tracks, and All Tracks (regardless of language). There is also an option to mixdown these additional tracks to 2-channel DPL2 for a smaller file size. If disabled, any selected multi-channel tracks will be passed-through as AC3.
Subtitle Selection: There are two basic options for subtitles, Burn-In and Pass-Thru. Burned in subtitles are written on top of the image permanently. Pass-thru subtitles will appear as separate selectable tracks in your output file. With the correct playback software, you’ll be able to enable / disable these subtitles as required. The Burn-In "Auto Detect" option will burn in forced-only subtitles (if available) in your native language; or all subtitles, if the default audio track language is not in the native language set in the action. Burn-In "Native Language" will burn in subtitles in your native language (if available) regardless of the default audio track language. The Pass-Thru option will pass-thru "text-based" subtitle tracks that match the language preference set in the action. Due to mp4 file limititations and HandBrake capabilities, picture-based subtitles cannot be passed-through. They can however be burned-in, but only 1 track can be burned-in to the video. See the HandBrake wiki for more info.
Multi-Channel Audio: The Batch Encode action includes a sub-routine that will set the audio output settings differently depending on the audio source and encoding preset selected. If an HB preset has multi-channel capability, the sub-routine will favor multi-channel audio (DTS or AC-3) over 2-channel tracks. If the audio codec is DTS, HandBrake will convert DTS to AC-3 since DTS pass-thru is not an option for most devices. All multi-channel tracks will also include a secondary stereo aac track for compatability. Presets that do not natively support multi-channel include: iPod, iPad, iPhone and Android devices.
iTunes Tagging: Once a m4v file is encoded, movies are then optionally embedded with iTunes XML style metadata, cover art and chapter names via theMovieDB.org and tagchimp.com API's. If a 720p or higher m4v file is encoded, the HD flag is set to allow the HD or HD/SD logo to appear in iTunes and the AppleTV. If an HD and SD m4v is created from the same source, they will both be set with the same cnid number. Having the same cnid number will allow the SD and HD versions to show up as one entry in iTunes.
Other Options: There are "Override" settings in the script to allow you to ignore the optical drive and set the video kind for optical sources.
Batch Encode Services
There are two Automator Services provided to use with Batch Encode.
Batch Rip • Batch Encode.workflow
This service receives no input and will act on all files or folders located in your "Batch Rip TV" and "Batch Rip Movies" folders, or optical discs mounted on your system (if Ignore Optical is not selected).
To use it: Open the application menu (to the right of the Apple menu), choose Services > "Batch Rip • Batch Encode".
Batch Rip • Batch Encode (Finder).workflow
This Service will act only on items passed as input via the Finder, another Action, or a script.
To use it via the Finder: Select the files, folders or discs you'd like to encode and run the service. Only the selected items will be processed.
To use it via another script: Pipe the input files or folders as a list with each source on its own line. Here's an example:
Code: Select all
echo -e "/Users/username/Movies/Batch Rip Movies/Toy Story (1995)\n/Users/username/Movies/Batch Rip TV/The Office (US) - S1D1" | automator -i - "/Users/username/Library/Services/Batch Rip • Batch Encode (Finder).workflow"
Customizing your Batch Encode Workflow
- In the Workflow Editor, Select the "Batch Rip • Batch Encode" workflow.
- Set the options in the action panel.
- Select "Other…" from the HandBrakeCLI pull-down menus. Navigate and Select the HandBrakeCLI application. Click Choose.
- Select "Other…" from the MakeMKV pull-down menus. Navigate and Select the MakeMKV application. Click Choose.
- Select your Batch Rip TV and Batch Rip Movies folders from the Source pull-down menus
- Set the minimum and maximum duration for TV and Movies sources (HandBrake will only encode tracks between these min/max durations).
- Select your Batch Encode folder from the output pull-down menu.
- Select your Default video kind from the pull-down menu (the source will be encoded based on this selection if there is no Spotlight comment or the source is located somewhere other than your Batch Rip TV or Batch Rip Movies folder (like an optical drive).
- Enter your Native Language as a 3-character ISO-639-2 code. This setting will be used to select the audio and subtitle tracks based on your language preference.
- Enter your Alternate Language as a 3-character ISO-639-2 code. This setting will be used to select the audio and subtitle tracks based on your secondary language preference. (optional)
- Choose Default Audio Preference:
- Default Audio: sets the default audio track to the source's "default" audio track. Useful for films where the main audio differs from your native language. Like if the main audio is Japanese and you want English subtitles.
- Native Language: selects an audio track (if available) that matches the native language preference set in the workflow. If an audio track is not available in your native language, it will try to find one that matches the alternate language preference set in the workflow. If neither are available, it will fallback to the title's default audio track.
- Choose Additional Audio Tracks:
Batch Encode will include additional audio tracks if selected.- Native Language: Selects all audio tracks in your native language.
- Alternate Language: Selects all audio tracks in your alternate language.
- Native & Alternate: Selects all audio tracks in your native and alternate language.
- All Tracks: Selects all audio tracks audio available regardless of language.
- Mixdown: Will mixdown additional tracks to 2-channel DPL2 for a smaller file size. If disabled, any selected multi-channel tracks will be passed-through as AC3.
- Choose Burn-in Subtitle Track Option:
The Burn-in option will burn-in subtitle tracks that match the language preference set in the action. Burned in subtitles are written on top of the image permanently.- None: Will not burn any subtitle track.
- Auto Detect: Burns in forced-only subtitles (if available) in your native language for short foreign language segments. Additionally, if the default audio track language is different from your native language, will burn in subtitles in your native language (if available).
- Forced Only (Native): Burns in forced-only subtitles (if available) in your native language.
- Native Language: Burns in subtitles in your native language (if available) regardless of the default audio track language.
- Choose Pass-thru Subtitle Tracks:
The Pass-Thru option will pass-thru "text-based" subtitle tracks that match the language preference set in the action.- Native Language: Selects all audio tracks in your native language.
- Alternate Language: Selects all audio tracks in your alternate language.
- Native & Alternate: Selects all audio tracks in your native and alternate language.
- All Tracks: Selects all audio tracks audio available regardless of language.
- Choose additional options:
- Run in the background (if enabled, the service will run as a background process with no Terminal output).
- Verbose logging (if enabled, will display a verbose activity log for each encode).
- Add iTunes tags (if enabled, will automatically add iTunes style metadata, cover art and chapter titles to Movie files, TV Shows need to be done as a separate process).
- Growl when done (if enabled, will send a notification via Growl, see the Growl section in this tutorial for more info).
- Encode Targets:
- Encode 1: This item is on by default, will output a file using the selected preset. Use for your main encoded file.
- Encode 2: If enabled, will output a second file using the selected preset. Use for your secondary encode.
- Encode 3: If enabled, will output a third file using the selected preset.
- Encode 4: If enabled, will output a fourth file using the selected preset.
- Presets:
- Choose a device or custom preset for each Encode Target enabled. For device presets, Handbrake will use it's built-in settings to encode a compatible m4v file based on the capabilities of the chosen device.
- Note: Encode 1 includes a unique preset called MakeMKV that will create an MKV file from optical and folder sources using MakeMKV. The resulting MKV file will be used as the source for Encode Targets 2-4. Useful if you'd like an uncompressed MKV file that includes all audio and subtitle tracks.
- Custom Presets:
- Enter custom encode settings for each Encode Target (Not recommended for new users).
- To enable a custom preset: Select a custom preset for your encode target.
- To enter a custom preset: Select a custom preset tab and enter your HandBrakeCLI arguments in the text field.
- Batch Encode allows the use of two variables to auto-select the audio and subtitle settings:
- To allow Batch Encode to auto select the audio settings use: \$audioSearch
- To allow Batch Encode to auto select the subtitle settings use: \$subtitleSearch
- Example:
Code: Select all
-e x264 -q 21.0 \$audioSearch -f mp4 -X 480 \$subtitleSearch -m -x b-adapt=2:rc-lookahead=50
- See the HandBrakeCLI wiki for more info on setting your arguments.
- To check for existing files in an existing movie library, Check the Move existing files check-box.
- Select your movie library folder from the pull-down menu.
- Select your retired folder from the retired folder pull-down menu. Existing movies with the same title will be moved to this folder.
- Choose Save from the File menu, to save your changes.
- You can also set up a keyboard shortcut to execute your workflow by selecting the Application Menu > Services > Services Preferences.
Testing your Batch Encode Workflow
- Choose Application Menu > Services > "Batch Rip • Batch Encode" to run the service.
- Terminal will launch and display some basic setup info. If you have any errors they will be presented here, such as missing apps or incorrect paths. It will also display the options you set in the action.
-
- - Terminal will display a list of the input sources found and detail the progress of each item/process.
-
-
Note: If “Run in background” is selected in the action, Terminal will not launch, the action will “run in background”.
- - If you've set up growl support, you will be notified by display, speech or email when completed.
-
Setting Batch Encode to Run Automatically
- In the Workflow Editor toolbar, click the timer icon to open event panel.
-
. - Set the time you'd like your encodes to begin (ex. 12:00AM)
- Click "Click to activate", to create the schedule.
- When activated (Green), the Batch Encode service will execute daily at the time specified.
- You can enable or disable this service at any time by clicking the status display in the event panel..
- To deactivate, click the timer icon to open event panel and Click "Click to deactivate"
- When disabled (Clear), the schedule will be removed.
- To change the time, deactivate and repeat the steps above to create a new Batch Encode schedule.
How to Automate Movie File Tagging with iTunes Style Metadata
There are three services provided to add iTunes metadata and cover art using the Add Movie Tags Action:
- Batch Rip • Add Movie Tags (Search).workflow
- Batch Rip • Add Movie Tags (Filename).workflow
- Batch Rip • Rename & Tag Movie Items.workflow
Using Batch Rip • Add Movie Tags (Search)
This service will display a list of possible matches from themoviedb.org database based on your search criteria. The service will then tag the file with metadata for the title selected.
- Select the files you want to tag.
- Right-Click and Select the "Batch Rip • Add Movie Tags (Search)" Service.
- A dialog box will appear listing the active item. Enter the movie name in the search field for this item and Choose OK.
-
- - The action will search the themoviedb.org database and return a list of possible matches. Choose the movie title and year that matches your file.
-
- - Choose OK, and the action will tag the file with metadata for the selected title. The action will repeat for each selected movie file.
Note: themoviedb.org is a free online service. Periodic outages are not uncommon. If data is not returned, the service may be down.
Using Batch Rip • Add Movie Tags (Filename)
This service will tag each file based on its filename with metadata from themoviedb.org database.
IMPORTANT: Your input files must be named properly with the following naming convention: Movie Name (year).m4v ( example: X-Men Origins - Wolverine (2009).m4v ). Titles that contain a colon [:] are replaced with a space and a dash [ -], as filenames cannot contain this character (see the section on file and folder renaming for more information). There is also a Rename & Tag Movie Items Service included in the Services menu if you also need to rename and tag your finished files.
- Visually check to verify that all the files have been named properly (ex. X-Men Origins - Wolverine (2009).m4v).
- Select the files you want to tag.
- Right-Click and Select the "Batch Rip • Add Movie Tags (Filename)" Service.
-
- - Each file will then be tagged with the cover art and iTunes metadata for the movie.
-
Using Batch Rip • Rename & Tag Movie Items
This service works like Add Movie Tags (Search) but will rename the file after tagging. See the section on Using the Add Movie Tags (Search) Service for more information.
Changing options for Add Movie Tags Services
Each Service is designed to perform a certain function, however there are options available in the Add Movie Tags Action panel that you may want to tailor to fit your needs.
- In the Workflow Editor, Select a "Batch Rip • Add Movie Tags" workflow.
- Choose action options:
- Disable dialog and search using filename (if checked will auto-tag using the filename for the search criteria).
- Add tags (if enabled, will tag selected files)
- Backup original file (if enabled, will make a backup copy of the input file before tagging)
- Remove existing tags (if enabled, will remove existing tags if present)
- Optimize file after tagging (interleaves audio and video, and restores QuickTime's "fast-start" ability, takes longer to tag)
- Rename file with title & year (if enabled, will rename the tagged file)
- Choose Save from the File menu, to save your changes.
How to Automate TV Show File Tagging with iTunes Style Metadata
There are three services provided to add iTunes metadata and cover art using the Add TV Tags Action:
- Batch Rip • Add TV Tags (Search).workflow
- Batch Rip • Add TV Tags (Filename).workflow
- Batch Rip • Rename & Tag TV Items.workflow
Using Batch Rip • Add TV Tags (Search)
This service will display a list of possible matches from thetvdb.com database based on your search criteria, then tag the files with the cover art and iTunes metadata for the show, season and episode.
- Select the files you want to tag.
- Right-Click and Select the "Batch Rip • Add TV Tags (Search)" Service.
- Enter the show title in the search field for this item and Choose OK.
- The action will search the thetvdb.com database and return a list of possible matches. Choose the series title and date first-aired that matches your file and Click OK.
- Enter the Season and Episode Number for the file.
- Choose OK, and the action will tag the file with metadata for the selected episode. The action will repeat for each selected episode file.
Using Batch Rip • Add TV Tags (Filename)
This service will tag each file based on its filename with metadata from thetvdb.com database.
IMPORTANT: Your input files must be named properly with the following naming convention: <Show Name - S##E##> (ex. Veronica Mars - S01E02.m4v). The "S##" signifies the season number and the "E##" represents the episode number. There is also a Rename & Tag TV Items Service included in the Services menu if you also need to rename and tag your finished files.
- Visually check to verify that all the files have been named properly (ex. Veronica Mars - S01E02.m4v).
- Select the files you want to tag.
- Right-Click and Select the "Batch Rip • Add TV Tags (Filename)" Service.
- Each file will then be tagged with the cover art and iTunes metadata for the show, season and episode.
Rename & Tag TV Items Service
This service works like Add TV Tags (Search) but will rename the file before tagging. See the section on Using the Add TV Tags (Search) Service for more information. The files will be renamed with the following naming convention: <Show Name - S##E##> (ex. Veronica Mars - S01E02.m4v). If multiple files are selected, the service will rename each file with the same show title and season number. The episode number will be assigned sequentially, starting with the episode number you specify when prompted.
IMPORTANT: If you are batch renaming files, they must be pruned and in episodic order BEFORE running this service: I recommend appending each file name with a number. This number does not have to represent the episode number, just a number to keep them in numerical order.
If your are using the Batch Encode Action to encode your TV files, the action will automatically include the title number at the end of the name (example: Veronica Mars - S1D1-1). The files will most likely already be in order with the disc number and title number, but this isn't always the case. You should always verify that all the episodes are present, any extras that may have been encoded are removed, and the files are in the correct order before running this service. Visit thetvdb.com to check your show and season to verify the number of episodes and check your files.
Note, that some discs may present two-part episodes as one title. In this case, these files should be processed in sets (example: if the season starts with a two-parter, process episode …E01. Process your next set with your number sequence starting at …E03, skipping …E02).
IMPORTANT: Thetvdb.com database has different options for episode ordering, Date Aired and DVD Order. Be sure to check the website to verify the correct order for your files. In most cases it will be DVD. However, some blu-ray discs have been released with a different sort order than the DVD versions. So, it’s good practice to check before renaming or tagging your files and select the appropriate "Sort Order" option in your workflow.
Using the Rename & Tag TV Items Service
- Visually check to make sure all the episodes have been encoded properly and in the right order.
- Select the sequence of files you want to rename and tag.
-
- - Select the "Batch Rip • Rename & Tag TV Items" Service.
-
- - A dialog box will appear listing the first item. Enter the Show Title in the search field and Choose OK.
-
- - The action will search the thetvdb.com database and return a list of possible matches. Choose the Show Title that matches your files.
-
- - Enter the Season number and episode start number in the text field and Choose OK.
-
Note: Some seasons may start at an episode number other than 1 (0 for Pilots). If you're unsure, visit thetvdb.com to verify the episodes for your show and season.
- - The files will then be renamed in sequential order and tagged based on their new file name.
-
-
Note: thetvdb.com is a free online service. Periodic outages are not uncommon. If data is not returned, the service may be down.
Customizing your Add TV Tags Services
Each Service is designed to perform a certain function, however there are options available in the Add TV Tags Action panel that you may want to tailor to fit your needs.
-
- In the Workflow Editor, Select a "Batch Rip • Add TV Tags" workflow.
- Choose action options:
- Disable dialog and search using filename (if checked will auto-tag using the filename for the search criteria).
IMPORTANT: Choosing this option requires the files be named with the following naming convention: <Show Name - S##E##> (ex. Veronica Mars - S01E02). The "S##" signifies the season number and the "E##" represents the episode number. - Add TV Tags (if enabled, will tag selected files)
- Backup original file (if enabled, will make a backup copy of the input file before tagging)
- Remove Existing Tags (if enabled, will remove existing tags if present)
- Optimize file after tagging (interleaves audio and video, and restores QuickTime's "fast-start" ability, takes longer to tag)
- Rename file (if enabled, will rename the tagged file to: Show Name - S##E##)
- Sort Order: DVD or Date Aired (will add episode data based on the selected sort order. Check the thetvdb.com database to determine whether your files are ordered by Date Aired or DVD)
- Disable dialog and search using filename (if checked will auto-tag using the filename for the search criteria).
- Choose Save from the File menu, to save your changes.
Managing your Media with Hazel
Moving files around can be a chore, especially if you have an elaborate Mac media setup. Rather than going into each step in detail, I'll just touch on a few concepts that might peak some interest in how automation can help manage files on a multi-Mac setup.
The Batch Rip and Batch Encode workflow provide a few elements that will allow you to easily automate and organize your media. The key components are "Finder Label Index" (File/Folder Color) and "Spotlight Comments" (Finder Comments).
Spotlight Comments used in Batch Rip Actions for Automator:
- The Batch Rip action will set the output files/folders Spotlight comment to the video kind set in the action.
- The Batch Encode action will take the source file's Spotlight comment and use it as the video kind, as well as derive it from the source file's location if the Batch Rip action was not used.
- After a source has been encoded, the Batch Encode action will set the Spotlight comment of the resulting output file to the source's video kind.
- Batch Rip
- Changes the Finder Color Labels of the disc folders to Yellow if copied successfully.
- Red if the Action encounters an error. Useful for Hazel or other scripting apps.
- Batch Encode
- Source folders change to Green while processing; Red if the Action encounters an error; Gray if it's done.
- Output files (m4v or mkv) change to Green if they're done, and Red if the action sees an error with the file.
- Output files (m4v) change to Orange if:
- Tmdb couldn't find any metadata for the movie (also changes the source folder to orange)
- Cover art failed integrity test (also changes the source folder to orange)
- Tagchimp couldn't find chapter names
Hazel http://www.noodlesoft.com is a preference pane that allows you to set up Rules based on a file's Spotlight data and specify actions to take when an item matches the Rules. This is similar to the way Smart Playlists function in iTunes and Smart Albums in iPhoto.
For example: If a file or folder located in our "Batch Rip TV" or "Batch Rip Movies" has a gray Label color we can assume it has already been encoded since the Batch Encode Script will change its color to gray after it has been encoded. We can set a rule in Hazel that will move any file/folder that's gray to a "Backup" drive. One nice thing about Hazel is that it will move the source file to the target location, not just copy it. It has some intelligence and safeguards built in to know if a file has been moved successfully and then deletes the source file, freeing up more space on our Batch Rip volume.
We can also have Hazel monitor our Batch Encode folder for files that have the extension ".m4v", have a Spotlight comment set to Movie, and have a "Finder Label" that is green. If a file has a green label, we can assume it has already been tagged with metadata so it should be considered a finished file. If all these criteria match, we can have Hazel then automatically move the file to our Movie library folder, then add the file to our local iTunes library, then change its color label to purple. You can even set up Hazel on a remote Mac to monitor the Movie folder via file sharing and add and movie file that's color label is purple and add it to its iTunes libraries as well, then change its color. You can repeat this with every Mac on your network to easily sync every added file. You can also duplicate this workflow for TV Shows as well keeping the files in separate folders and automatically creating subfolders based on the show name and season.
In addition to m4v files, we can have a similar Rule for our Batch Encode folder that looks for ".mkv" files with a Spotlight Comment of Movies or TV Shows and move them to a Plex depository on a local or network drive.
Hazel also allows for scripts to run when an item matches our rules. For example, with the "Move existing file to retired folder" option in the Batch Encode action enabled, you can have Hazel run an AppleScript that will remove the existing movie or TV show from iTunes when its file is added to the retired folder set in the action, helping to prevent duplicates in your library.
Hazel is a do-it-as-it-happens approach. The disc rips, the file encodes, the file is tagged, the source is backed up, the 1080p mkv is sent to a Plex folder, the m4v file is moved to my library, the file is then added to all my iTunes libraries and is sync'd to my Apple TV's. Simple and done.
The point is with a few triggers, you can easily automate the process of moving, organizing and syncing your media. I prefer Hazel for it's versatility and ease of use, but a lot of what Hazel provides can also be done with Folder Actions … but with a lot more work.
Conclusion
I hope you enjoyed this tutorial. If you've made it to the end, kudos to you. This process has been a great learning experience for me and hope it is for you as well. The elements of this workflow really demonstrate the power Mac OS X has with Unix, AppleScript, Automator and a brilliant developer community. Though this tutorial is a bit more involved than I had anticipated, I can attest that once you've got it going, you will spend less time managing your content and more time enjoying it. If you’d like to dig a little deeper, there are additional resources listed below. Happy Encoding!
Additional Resources:
Batch Rip Help: In the app under the Help menu or via Mac's Help Center.
How To: Rip, Encode and Combine Using Fairmount & DTOX
Native Blu-ray ripping for OS X
Blu-Ray to Apple TV
Advanced Bluray/HDDVD Workflow & Features
Subler
Older automation thread
How-To: Automate DVD Backup w/ FairMount & HandBrake