Import Chapters With Handbrake GUI

July 14th, 2010 | Tags: , , , , , ,

Between using [Handbrake]( on Windows and on OSX, I have found the UI differences to be maddening. (For the most part, I like the OSX GUI better, except when it comes to extracting more than four audio tracks and when it comes to importing chapter titles.)

To (sort of) automate the process of importing chapter titles into Handbrake, I created the following workflow (for OSX):

1. Find the movie on [Barnes and Noble](
2. Copy the chapter listing (that looks similar to this):

1. Main Title [5:56]
2. “Happiness Hotel” [11:25]
3. Lady Holiday’s Office [8:13]

3. Paste into TextMate.
4. Find `^[0-9]*\\. (.*) \\[.*\\]$` and replace with `$1` (be sure regular expressions are enabled)
5. Copy the resulting chapter titles (which have had the number and time stripped off)
6. In Handbrake, start editing the first chapter name
7. Run the “Paste Chapter Titles” script and watch as all of the chapter titles are pasted in the correct location.

-- Get the chapter titles from the clipboard
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {return}
set chapterTitles to every text item of (the clipboard)
set AppleScript's text item delimiters to oldDelims

tell application "HandBrake" to activate
repeat with ct in chapterTitles
  tell application "System Events" to tell process "Handbrake" to keystroke (ct & return)
  delay 0.04 * (length of ct)
end repeat

Yes, I realize that the [MetaX][] tool would work well–if I was using a M4V wrapper. But I’m not. The [WDTV Live][3] I have doesn’t support chapters in the M4V container.


No comments yet.
You must be logged in to post a comment.