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).
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pysubs2-1.9.0.tar.gz.
File metadata
- Download URL: pysubs2-1.9.0.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4592405e5d961e23cd39c81e2875fb85c30346ae37d100f144cd7fd8ec560e42
|
|
| MD5 |
3c81821d4622894eda1f4e601ab63d77
|
|
| BLAKE2b-256 |
f2209071b8b0012d9102e90292c71fe3f1181c33e772e28cbabb4779c0087603
|
Provenance
The following attestation bundles were made for pysubs2-1.9.0.tar.gz:
Publisher:
release.yml on tkarabela/pysubs2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pysubs2-1.9.0.tar.gz -
Subject digest:
4592405e5d961e23cd39c81e2875fb85c30346ae37d100f144cd7fd8ec560e42 - Sigstore transparency entry: 2492113720
- Sigstore integration time:
-
Permalink:
tkarabela/pysubs2@34d6ca5534ffd46cfa460d73aff79521eded2055 -
Branch / Tag:
refs/tags/1.9.0 - Owner: https://github.com/tkarabela
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@34d6ca5534ffd46cfa460d73aff79521eded2055 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file pysubs2-1.9.0-py3-none-any.whl.
File metadata
- Download URL: pysubs2-1.9.0-py3-none-any.whl
- Upload date:
- Size: 48.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83f1979cb7e064294f0c8473ef672ca2e5c0a7172bbf8ae9b4337899d5cdf01f
|
|
| MD5 |
fdf47969bfeec2cd0850b4888ee77b4c
|
|
| BLAKE2b-256 |
4f436b89c84f5a6753b1dbc43b8d010443b8f2314a2b94f34e448975d115c962
|
Provenance
The following attestation bundles were made for pysubs2-1.9.0-py3-none-any.whl:
Publisher:
release.yml on tkarabela/pysubs2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pysubs2-1.9.0-py3-none-any.whl -
Subject digest:
83f1979cb7e064294f0c8473ef672ca2e5c0a7172bbf8ae9b4337899d5cdf01f - Sigstore transparency entry: 2492113833
- Sigstore integration time:
-
Permalink:
tkarabela/pysubs2@34d6ca5534ffd46cfa460d73aff79521eded2055 -
Branch / Tag:
refs/tags/1.9.0 - Owner: https://github.com/tkarabela
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@34d6ca5534ffd46cfa460d73aff79521eded2055 -
Trigger Event:
workflow_dispatch
-
Statement type: