Supported File Formats

Tip

Every supported format has a unique format identifier string, eg. "srt". These can be used in the API to force input/output in a certain format, though this is usually unnecessary thanks to autodetection from content and file extension.

Native Format – SubStation Alpha

pysubs2 is built around SubStation Alpha, the native subtitle format of Aegisub. This format is popular in anime fansub community as it allows for rich text formatting and even animations and vector graphics.

SubStation Alpha — supported in two versions:

  • .ass files (Advanced SubStation Alpha v4.0+), format identifier is "ass".

  • .ssa files (SubStation Alpha v4.0), format identifier is "ssa".

Time-based Formats

SubRip — .srt files, format identifier is "srt". Widely used subtitle format, it uses HTML tags for formatting, though it is usually not heavily formatted (as opposed to SubStation).

MPL2 — Time-based format similar to MicroDVD, format identifier is "mpl2". To save subtitles in MPL2 format, use subs.save("subtitles.txt", format_="mpl2").

TMP — Time-based format, format identifier is "tmp". A very simple format which only specifies starting time for each subtitle, eg. 0:00:13:This is a subtitle. Subtitle length is calculated automatically based on character count. This older subtitle format is also referred to as “TMP Player” format.

WebVTT — Time-based format similar to SubRip, format identifier is "vtt". Currently implemented as a flavour of SubRip, with no extra support for WebVTT-specific features like styles or subtitle alignment. Link to WebVTT specification, official name is “Web Video Text Tracks Format”.

Frame-based Formats

MicroDVD — .sub files, format identifier is "microdvd". This format uses frames to describe start/end times, instead of hour/minute/second, which means it is dependent on framerate of the video. For proper retiming and conversion, you need to know the framerate (sometimes it is given in the first subtitle, which pysubs2 will autodetect and use).

Other

JSON-serialized internal representation, which amounts to ASS. Format identifier is "json".