Macro Scripts in Subtitling
When I'm assigned a project that involves a large number of repetitive actions to complete, the first thing I usually do is try to find a way to somehow automate it. Monotonous work to me is what garlic's to vampires, but when it is inevitable, I strive to minimize it. Over the years, I've found that macros are the best way to do that due to their simplicity and effectiveness, and in this blog post I'd like to share some of the uses I've found for them.
There are many tools for creating macros, but I prefer the one called AutoHotkey, because it's quite powerful yet lightweight and unintrusive. You need to download and install the program, and after that you'll be able to work with macro scripts. To create a new script,
Right-click on your desktop
Click "New" in the pop-up menu
Click "AutoHotkey Script"
Now you have your script file with the .ahk extension. To modify it, right-click on the file and click "Edit Script". This will open a text editor window in which you enter your code. Don't worry, though — you don't have to be a programming guru to be able to write simple scripts for your subtitling work.
If you open your file in Windows 10, an empty script will look like this:
The first paragraph is kind of a heading; don't mind it. Your macro script goes right after it. Here's an example of a basic script:
What it does is it pastes the text "My First Script" when you press Ctrl+J. To make the script active, you need to save it and double-click the file.
Now, there are quite many commands and attributes that can be used in your AHK scripts, and I can't possibly describe them all in this post; instead, let me refer you to the AutoHotkey web tutorial. It's well-written and easy to understand, so there shouldn't be any issues here.
Now, without further ado, let's take a look at some real-life examples of how and when using macros can be useful in subtitling.
1. Pasting Repetitive Text
Imagine a company asks you to review 50 test translations submitted by potential vendors, all for the same video clip. They send you 50 subtitle files along with the script and the proxy video, and your job is to create 50 Excel spreadsheets, each containing a list of translation and subtitling errors you find in each test. The Excel table should have 3 columns:
Something like this:
The company's style guide includes 12 error types to choose from. If the test video is 15 minutes long, you're looking at 15*50=750 minutes' worth of video material, which translates into more than 10,000 subtitles. It's pretty obvious there will be a lot of repetition in the second and third columns, and you'll have to type the same things over and over again. Or you can copy-and-paste cell contents, but it's still quite a headache.
What you can do instead is create a macro script that will paste these strings with a single keystroke. For example:
And all the way up to F12. Now you'll be able to paste the required error type by simply pressing the corresponding F-key.
You can do the same for the comment column, either by adding a Ctrl, Alt or Shift modifier to your F-keys or using the numpad keys:
This approach will save you quite a bit of time and wrist pain even in Excel, where you can rather quickly copy-and-paste from cell to cell, and if you have to work in a different text editor or web tool where copying requires more steps, you will save even more time and effort. The bottom line is, whenever you have a project that involves typing the same things over and over again, remember that you can use macros to make things easier.
2. Changing and creating hotkeys
In some subtitling programs hotkey customization is very limited. A good example here is WinCAPS Qu4ntum, which doesn't offer this functionality at all. You can configure just a handful of hotkeys in Qu4ntum, but most of them are set in stone.
So, what do you do if you're unhappy with some of them, if they feel awkward or unintuitive to you? You can remap these key combinations using an AutoHotkey script. For example, in WinCAPS, the hotkey Ctrl+U underlines subtitle text. If you want this key combination to toggle the text between lowercase and uppercase instead (because who in their right mind would want underlined subtitles?), you can use this code:
Now, when you press Ctrl+U, Ctrl+M is pressed instead, which toggles the case of the current subtitle's text in Qu4ntum.
You can also use macros for creating hotkeys that didn't exist in the first place. For instance, EZTitles 5 doesn't have hotkeys for copying the current subtitle's in-time and out-time to the clipboard. So, going back to our example with test translations, if the company asked you to add one more column containing the in-times of the problematic subtitles, you would have to either copy-and-paste them from the program or enter them by hand painstakingly. Or, instead, you could use this neat script:
Here's what it does:
Saves the current position of the mouse cursor
Moves the cursor to the in-time field in EZTitles
Double-clicks on the field to highlight it
Presses Ctrl+C to copy the in-time to the clipboard
Returns the mouse cursor to the initial saved position
Presses Tab four times to shift input focus from the field back to the program
Now, pressing Num0 quickly saves the current subtitle's in-time to the clipboard, and you can paste it with Ctrl+V into your Excel table or elsewhere. Note that the coordinates at which you double-click (500 and 80 in my case) depend on your interface layout in EZTitles and your monitor's screen resolution.
3. Altering or Adding Functionality
You can also streamline your work by changing the way your program works. For instance, generally speaking, Aegisub's approach to timecoding ("mouse swiping") has several advantages compared to the traditional methods used in professional subtitling:
Your timecoding pace is not dictated by the playback speed.
You don't have to rely on the consistency of your reaction time.
You can be frame-accurate on-the-fly without doing extra work.
You naturally skip speech-free segments.
That is not to say this approach doesn't have shortcomings, but it's a nice take on what's possible in subtitling, and, in my experience, it's better than the standard methods for videos with little to no background noise, low pace of speech and big gaps in-between utterances.
Interestingly, you can partially recreate it in EZTitles using this simple script:
(Note that I'm using the default hotkeys here, so if you've modified some of them, you'll need to change the script accordingly. If not, your Num Lock should be off.)
Now, to set timecodes, all you need to do is click-and-hold the right mouse button on the Audio Graph where you think the in-time should be, then swipe to the right and then release the right mouse button where you think the out-time should be. Rinse and repeat until you reach the end of file, and then press ScrollLock to exit the script and reset the right mouse button's behavior back to normal.
Here's a video demonstration: youtube.com/watch?v=BNRBoUWDR-4
Going into a bit more detail, here's what the script does:
When you press the right mouse button, it
Left-clicks on the Audio Graph, bringing the video position bar to your cursor
Sets both the in-time and out-time at that frame (the latter automatically goes one minimum duration to the right)
Moves your mouse cursor to the out-cue (180 pixels to the right for me)
Starts playback, so that you can use the audio track and the duration indicator
Holds your left mouse button down, so that you can drag the out-cue
When you release the right mouse button, the script
Releases your left mouse button, thus setting the out-cue
Jumps to the next subtitle
Bear in mind that the script only works in the Preview Mode, and you first need to uncheck "Jump to next subtitle on set out-cue" and check "No subtitles shorter than minimum duration" in Edit > Preferences > Cues. Plus, you need to adjust the mouse move pixel value, depending on your minimum subtitle duration, monitor resolution and Audio Graph zoom level.
And this concludes this blog post. As I've demonstrated, macro scripts can be quite useful in subtitling; all you have to do is get creative and think outside the box. If you have any questions or more ideas related to macro scripts and speeding up your work, please leave a comment below.