Skip to main content

pysubs2 build master branch pysubs2 test code coverage Static Badge PyPI - Version PyPI - Status PyPI - Python Version PyPI - License GitHub Repo stars

pysubs2

pysubs2 is a Python library for editing subtitle files. It’s based on SubStation Alpha, the native format of Aegisub; it also supports SubRip (SRT), MicroDVD, MPL2, TMP, WebVTT, TTML and SAMI formats and OpenAI Whisper captions.

Goal of this library is to provide practical, robust handling for subtitle files found in the wild (with all their questionable syntax). Internally, everything is converted to a representation based on ASS, which is relevant if you want to process formatting. Support for production/broadcast subtitle formats (or subtitle features beyond what ASS can express) is not really a goal of the library; however, please open an issue if you have a use-case where using this library would make sense to you.

Based on code originally created in 2011, in development ever since. Thanks to all users and contributors over the years!


Quick links: Documentation · Issues · Contributing · Source code


Usage

For more information, please see the tutorial and API reference in the Documentation.

import pysubs2
subs = pysubs2.load("my_subtitles.ass", encoding="utf-8")
subs.shift(s=2.5)
for line in subs:
    line.text = "{\\be1}" + line.text
subs.save("my_subtitles_edited.ass")

There is also a small CLI tool for batch conversion and retiming.

pip install pysubs2
pysubs2 --shift 0.3s *.srt
pysubs2 --to srt *.ass

Installation

Simply uv add pysubs2 or pip install pysubs2.

The library itself is pure Python, with no additional dependencies.

Contributing

If you'd like to contribute code to the library, see CONTRIBUTING.md.

License

pysubs2 is licensed under the MIT license (see LICENSE.txt).

Metadata

Release files for pysubs2 1.9.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pysubs2 1.9.1
File Size Uploaded Provenance Actions
pysubs2-1.9.1.tar.gz 1.1 MB With provenance Details for pysubs2-1.9.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pysubs2 1.9.1
File Interpreter ABI Platform Actions
pysubs2-1.9.1-py3-none-any.whl Python 3 none any Details for pysubs2-1.9.1-py3-none-any.whl

Total release size: 1.2 MB

Release files / pysubs2-1.9.1.tar.gz

Download URL pysubs2-1.9.1.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
7c2956780d50e543d261f57417bed067249272e939da10dbd449a2446b9993af
BLAKE2b-256 checksum
How to use checksums
c7bc3c90851b917956efbc316ac70bd699adb91722918c90a49003e8e9892489
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / pysubs2-1.9.1-py3-none-any.whl

Download URL pysubs2-1.9.1-py3-none-any.whl
Size 48.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4210ebedc54e8272e741fc5888a1721f74056bbd91b7aac7cc90b6559cd055b4
BLAKE2b-256 checksum
How to use checksums
fa8ba56185534f68857ab90c0f2f7642940e6a249c9e782a258a59c31c743c70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Security for pysubs2 1.9.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pysubs2-1.9.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page