lyger / Aegisub_automation_scripts

MIT License
96 stars 37 forks source link

== Introduction ==

This is the page where I'll be uploading and updating the various automation scripts I write for Aegisub. These are primarily typesetting-oriented, but there are a few scripts related to karaoke timing, and I might write editing- or QC-related scripts in the future.

I take requests (if you can convince me you have a task that would be useful automated). Also, if you find a bug in any of these scripts, by all means tell me so I can fix it. You can find me as lyger on irc.rizon.net.

== Required Modules ==

=== DependencyControl === My scripts require DependencyControl (https://github.com/TypesettingCartel/DependencyControl) for versioning and dependency management. Update feeds are provided, so all scripts can be installed using the DependencyControl Toolbox and will automatically update whenever new versions are released.

=== LibLyger === This module is required for most of my advanced scripts. I noticed I was reusing a lot of code in multiple automations, and it was getting to be a pain to update the same function in every script whenever somebody found a bug. From now on, functions that I frequently use will be collected in this library, so that I only need to update one file when somebody finds a bug in one of the functions.

== Typesetting Scripts ==

=== BorderSplit ===

The first and probably the most useful automation script I wrote. Now that I have a lot more experience writing these automations, I realize how messy the code is, but it works and is remarkably bug-free.

This takes a single bordered line and splits it into two lines. For a single bordered line, applying a \blur tag will only blur the outer edge. This automatically splits the line in two so that the \blur will apply to both edges. There are a handful of other options that let you customize the behavior of the automation. Read the readme at the top of the script for full instructions.

Compared to my other scripts, the behavior is a bit odd. Instead of applying to the selected lines, the script applies to lines with "bord" in the actor field. This is mostly an artifact of my days working with karaoke templates, but I honestly rather like the workflow.

=== TemplateManager ===

This one gets a spot up here because of its usefulness. This automation is built around typesetting efficiency. The idea is you do all the hard work once, and everything afterwards becomes super easy.

This is actually a macro that creates other macros which will be added to the automation menu. The main "Template manager" automation doesn't change anything about your subtitles. Instead, it lets you create and modify templates for repeated typesets. The templates are very customizable and allow variables and simple arithmetic.

Once you've finished creating and modifying your template group, reload your automations and the newly created macro will appear on the automations menu, allowing you to hotkey it. Most aspects of the script remember your last action.

=== FbfTransform ===

The first "advanced" automation I wrote since writing border-split. This script is very powerful and versatile, but it expects a certain amount out of the typesetter. Read the instructions at the top of the script file for full details.

This allows you to animate nearly all of the parameters of a typeset frame-by-frame. You start with an existing frame-by-frame typeset (possibly generated using Mocha data, or just by pressing ctrl-d a lot). Then you visually typeset "keyframes" until they look the way you want them to. This script will fill in all the frames in between the keyframes so that they transform smoothly.

Note that as a typesetter, you will need to typeset the keyframes by hand. In essence, instead of punching in all your options into a popup window, you can work on the appearance of the line the way you normally typeset. I personally find this to be more intuitive, but again, it requires more work out of the typesetter than a simple click-on-buttons interface.

Also note that there is no requirement that the lines you select actually represent a frame-by-frame typeset that is sorted by time. This script transforms parameters across the lines you select; that's all. How you use it is up to you.

=== GradientEverything ===

This was written based on the code of FbfTransform. Instead of creating frame-by-frame animations, GradientEveryting will "gradient" the parameters. Put another way, FbfTransform will transform parameters in time, while GradientEveryting can transform parameters in space.

Again, you define "key" lines, but unlike FbfTransform you don't need to have all the lines in between already; the script will generate them for you. These "key" lines will be smoothly merged together by the script, based on the options you enter from the popup menu.

The Bounding box for the gradient will be determined using SubInspector when the module is available on your system. If it isn't, you must provide it as a rectangular clip (on any of the input lines).

==== ClipShifter ====

This is primarily a helper script to go with GradientEveryting. If you want to apply GradientEveryting to many lines without having to redraw the bounding box each time, ClipShifter will move and add the bounding box for you.

=== GradientByChar ===

A by-character version of GradientEveryting. It has the most of the features of GradientEveryting, but its resolution is only by-character, and for obvious reasons vertical gradients are not possible.

That being said, I will recommend that typesetters use this script instead of GradientEveryting in the vast majority of cases, simply because GradientEveryting will generate dozens of lines and result in lots of lag if you're not careful. In most cases, gradient-by-char will be sufficient. Not to mention, working with a single-line typeset is usually easier.

This automation has no popup interface (unlike GradientEveryting). It's locked to transform any different parameters that it detects. It's also locked to "rotations less than 180 degrees" mode (you can read more about this in the readme at the top of the script).

=== LuaInterpret ===

It seems I never wrote a description for this, so here goes.

This was one of my most ambitious projects, and despite a plethora of bugs and user-unfriendliness, today it's one of my most-used scripts. I noticed I was repeating a lot of code in my automations, and many tasks kept popping up over and over again, so I thought to myself, "Why don't I create a script that does all the grunt work for you, so you only have to code the important part?"

Well, it sort of worked. In most cases nowadays, when a typesetter asks me for a specific task automated, I'm able to accomplish it in under fifty lines using LuaInterpret. If you ever come to me with a request for automation, I'll either direct you to existing scripts that can do what you want, or give you some code to use with this script.

It's also a super handy tool for adjusting massive multi-line typesets or doing arithmetic on tag parameters. Need to double the font size? mod("fs",mul(2)). Add 5 degrees to all the rotations in a line? mod("frz",add(5)). One line of code will apply to all the tags in all the selected lines.

=== ClipBlur ===

The \clip tag naturally generates a very sharp edge. For a typesetter who wants his signs to blend in, that sharp edge can stick out like a sore thumb.

This script serves the much-needed function of blurring the edge of a \clip by duplicating the line, drawing more \clips, and decreasing the alpha. Due to the nature of \clip, the appearance will not always be perfect, even if all the numbers match. Nonetheless, it's better than nothing.

The "precision" option can improve the appearance, but note that it scales exponentially. A precision of 4 generates 8 times as many lines as a precision of 1.

=== ClipGrad ===

This script is not as versatile as I'd have liked, due to limitations caused by the way anti-aliasing works. Nonetheless, it should be useful in plenty of situations.

This works the same as ClipBlur, but instead of blurring the edge of the \clip, it gradients from one color to another (unlike GradientEveryting, it does not gradient any other parameters. Sorry). To correct for anti-aliasing artifacts, there is a forced one-pixel overlap for each stripe of the gradient. As a result, this script does not work on semitransparent typesets at all.

Nonetheless, it provides the ability to create a gradient of more or less any arbitrary shape.

=== VecClipGradient ===

Intersects a lines-only vector clip with a rectangular clip. Less awesome than it sounds, since I found out after writing this script that you can have two \clip tags in the same line, so long as one is vector and one is rectangular. Welp.

=== Image2ASS ===

This script started as a standalone Lua script that I eventually wrapped in an Aegisub macro to make it easier to use. It's probably the worst lag machine in this entire repo, though it can also be an incredibly powerful tool.

It basically does what the title says. Input a 24-bit or 32-bit Windows-format bitmap image, and this macro will convert it pixel-by-pixel into .ass drawings. Also supports alpha masks, which are black-and-white bitmaps loaded separately.

To mitigate the obvious lag implications of this, a basic color similarity compression is run to merge adjacent pixels of similar color, and the user is notified after running the script of the approximate amount of data added, so they can adjust the compression factor accordingly. To get an idea of how different compression levels look, see [http://i.imgur.com/ol6tfZu.png this comparison].

It's worth noting that no compression is performed on the alpha mask. It's the user's responsibility to avoid needless alpha variations in their mask.

The latest version supports non-bitmap images, which are converted to bitmap automatically with the convert tool from ImageMagick. Download the executable [http://www.mediafire.com/download/zdxn75nte1n6cq6/convert.exe here] and save it to your automation\autoload directory.

=== ModifyMocha ===

I wrote this script when I had to deal with a Mocha-tracked typeset that appeared in a flashback in a later episode. Obviously, I didn't want to re-typeset the sign, and instead copy-pasted the sign from the earlier episode. Unfortunately, the colors were all grayed out in the flashback, and the sign itself was a couple layers, with borders and shadows and whatnot. Fixing all those colors would have been a find-and-replace nightmare.

This automation allows you to duplicate the first frame of the typeset, modify it until its appearance matches the new appearance that you want, and automatically apply these changes to the rest of the lines. Detailed instructions are at the top of the script.

=== split-tags.lua ===

Some effects only work if each section of a typeset is split onto a different line. For example, if you want the letters to zoom in one-by-one. But once you've split all the letters onto different lines, positioning them correctly is a huge hassle.

This will split a single line into multiple lines while preserving the appearance of the original single-line typeset. In theory, after running this, your typeset will look exactly the same as it did before, but on multiple lines. The script splits every time it sees an {override block}. You can put blank {} blocks to force a split, and it should still work.

=== CircleText ===

Puts text onto a circle, on a single line. This is accomplished using \fsp and \frz trickery. The curve of the circle is defined by placing the origin. If you select the z rotation tool in Aegisub, it will display a circle that is roughly the same as the circle your text will end up on after applying this automation. Detailed instructions are at the top of the script, but it's pretty straightforward.

=== LayerIncrement ===

Makes selected lines have layers that count up or down (e.g. 1,2,3,4,5...). The minimum layer number will be the highest layer within the selection. This is a predecessor to a possible GradientEveryting clone based around creating outline gradients.

=== MoveClip ===

Turns lines with \pos and a rectangular \clip into lines with \move and a \t transformed \clip, based on the user-input delta-x and delta-y values. This is primarily intended to allow rectangular-clipped gradients to move using \move statements.

== Karaoke Scripts ==

=== KaraHelper ===

Certain karaoke effects require blank syllables at the beginning and end of the k-timed line, in order to leave room for transition-in and transition-out effects. This automation primarily takes care of making those sorts of timing adjustments automatically.

If any k-timers have tasks they'd like to see added to this script, just contact me.

=== KaraReplacer ===

Ever had to k-time a song and encountered a verse with the same tune and rhythm as a previous verse, but different lyrics? This automation allows you to reuse that timing, and quickly and efficiently replace the lyrics. Highlight the lines you wish to apply this to, run the automation, and click "help" for full instructions.