arcusmaximus / YTSubConverter

A tool for creating styled YouTube subtitles
MIT License
800 stars 54 forks source link

YTSubConverter

A tool for creating styled YouTube subtitles.

Sample image

About this tool

YouTube's built-in subtitle editor doesn't support styling of any kind. If you want formatting such as bold, italic and coloring, you need to upload a subtitle file instead. The site accepts a number of file formats such as RealText, WebVTT and TTML, but all of these come with their own limitations - and most importantly, none of them give access to the full array of features offered by the YouTube player. For that, you need to use a YouTube-specific format called SRV3 (also referred to as YTT for "YouTube Timed Text"). It supports the following:

YTSubConverter can produce this file format for you.

The current version is 1.6.3 and is available for Windows, macOS and Linux (the Linux version requires Mono).

Download

Usage

YTSubConverter is primarily an .ass → .ytt converter. You can create .ass subtitles using Aegisub.

Conversion is straightforward: launch the program, open your .ass file and click Convert. Alternatively, drag the .ass straight onto the .exe (Windows only). In both cases, you'll get a .ytt file that's ready for upload.

The program tries to approximate the look of the Aegisub subtitles as closely as possible on YouTube:

Outlines

You'll notice that each .ass shadow can turn into one of four different YouTube shadow types: glow (same as outline), bevel, soft shadow and hard shadow. You can even combine multiple shadow types if you want - just choose from the checkboxes in the conversion UI. This is also where you can configure current word highlighting for karaoke.

Style options

Apart from converting from .ass to .ytt, the tool can also convert from .sbv (the format you get when downloading subs from YouTube's built-in editor) to .srt. This allows you to download existing, unstyled subs and add styling to them. Simply open the .sbv file, click Convert, and open the resulting .srt file in Aegisub.

Conversion between .ttml and .ytt is also possible. YouTube already supports uploading TTML files directly, but this support is rather limited - if you convert to .ytt and upload that instead, you get access to more features, not to mention workarounds for YouTube bugs. That being said, certain features like karaoke and transitions are still only available through .ass.

ASS feature support

YTSubConverter supports the following .ass style features:

Fonts

(Roboto is the YouTube default; the tool will automatically pick this if the specified font is not allowed)

It also supports the following override tags:

Tags that are not in the above list are not supported. You can use them, but they won't do anything.

Examples

The repository contains two sample .ass files:

Testing on PC

After you upload a subtitle file, YouTube gives you a preview so you can try it out before submitting. This is nice, except that the preview only shows the file's text; it doesn't show the styling. This complicates testing: each time you make a change and want to see the result, you'd have to actually publish the subtitles so you can see them in the "real" player. This is especially bothersome if you're contributing to someone else's channel, as you'd have to get the subtitles approved each time (or make a copy of the video on your own channel).

Fortunately, there's an easier way to test your subtitles - one that doesn't require you to upload them at all. It works by using Fiddler, a program that can intercept web requests from your browser and send back a file from your hard drive (rather than one from YouTube's servers). By redirecting your browser's request for subtitles to your local .ytt file, you can see those local subtitles in your browser as though you uploaded them. Since you're not actually uploading them, you can test your changes much more quickly.

While this approach can save you a lot of time, it does require some initial setup:

Once this initial setup is done, you only need to do the following whenever you want to test subtitles:

As long as Fiddler is running (and the rule is enabled), any YouTube video you view will have the specified .ytt file as its subtitles. If you make a change to the file, you don't even need to refresh the page in your browser to see it: simply disable and re-enable CCs in the video to make the YouTube player "redownload" them.

To save even more time while testing and tweaking, you can click the "Autoconvert" button in the converter GUI. As long as this button is enabled, YTSubConverter will automatically convert the currently selected .ass file whenever it detects a change. This means you can make a change in Aegisub, save the .ass, and reload the subtitles in YouTube to see the result without ever having to pass by the converter.

Uploading to the video

For your own videos, you can add styled subtitles as follows:

Note that after uploading the file, you won't see the styling in the editor's preview pane. This is normal; as long as you don't change anything in the editor, the styling will show up in the "real" video player afterwards. If you make any change, no matter how small, all styling information will be lost and you'll have to upload the file again.

For videos on someone else's channel, things are a bit trickier. YouTube used to have a community subtitling feature that allowed anyone to submit captions for videos; channel owners could then review the submission and publish it with the click of a button. On September 28 2020, however, the feature was deprecated and later removed. This means users have to follow the more primitive route of contacting the channel owner, sending them the subtitle file, and asking them to upload it on their behalf.

Limitations

YouTube has some bugs and limitations when it comes to styled subtitles. Please be aware of the following:

Mobile limitation

Command line

YTSubConverter can be run from the command line. There are two ways of calling it:

In addition, you can specify the --visual option for visually accurate .ytt/.srv3 → .ass conversion (see following section).

On macOS, you can run YTSubConverter.app/Contents/MacOS/YTSubConverter from the terminal. While it's also possible to run YTSubConverter.app itself using the open command, you won't get any console output in this case.

Reverse conversion

Apart from the usual .ass → .ytt, YTSubConverter can also convert in the opposite direction: from .ytt (or .srv3, which is the same) to .ass. What's more, it can do this for two different purposes: editing and archiving.

You can download a video along with its published .ytt/.srv3 subtitles by using youtube-dl with the following options: --write-sub --all-subs --sub-format=srv3

Alternatively, you can download just the subtitles by browsing to https://www.youtube.com/api/timedtext?v=<video ID>&lang=<language code>&fmt=srv3 (you can refer to this language code table).

Example workflow for quick style assignment

Subtitles for a certain channel will often have recurring looks. For example, Kizuna AI's gaming channel has pink subtitles for talking, red for screaming and yellow for explanations. To avoid having to put tags everywhere, you should of course define these recurring looks as Aegisub styles. Assigning these styles to the individual subtitles can be quite a hassle, however. This section offers a quicker way.

First do some initial setup:

Then do the following for each video:

Credits

Thanks to the following people for providing the UI translations: