https://github.com/tkarabela/pysubs2
A Python library for editing subtitle files
https://github.com/tkarabela/pysubs2
closed-captions microdvd mpl2 openai-whisper python sami srt substation-alpha subtitles subtitles-parsing ttml webvtt
Last synced: 28 days ago
JSON representation
A Python library for editing subtitle files
- Host: GitHub
- URL: https://github.com/tkarabela/pysubs2
- Owner: tkarabela
- License: mit
- Created: 2014-08-06T00:01:40.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2025-02-15T20:07:26.000Z (4 months ago)
- Last Synced: 2025-04-20T10:41:43.591Z (about 2 months ago)
- Topics: closed-captions, microdvd, mpl2, openai-whisper, python, sami, srt, substation-alpha, subtitles, subtitles-parsing, ttml, webvtt
- Language: Python
- Homepage: http://pysubs2.readthedocs.io
- Size: 2.6 MB
- Stars: 361
- Watchers: 10
- Forks: 45
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
- Support: docs/supported-formats.rst
Awesome Lists containing this project
README
pysubs2
=======[](https://github.com/tkarabela/pysubs2/actions)
[](https://app.codecov.io/github/tkarabela/pysubs2)
[](https://github.com/tkarabela/pysubs2/actions)
[](https://pypi.org/project/pysubs2/)
[](https://pypi.org/project/pysubs2/)
[](https://pypi.org/project/pysubs2/)
[](LICENSE.txt)
[](https://github.com/tkarabela/pysubs2)pysubs2 is a Python library for editing subtitle files.
It’s based on *SubStation Alpha*, the native format of
[Aegisub](http://www.aegisub.org/); it also supports *SubRip (SRT)*,
*MicroDVD*, *MPL2*, *TMP* and *WebVTT* formats and *OpenAI Whisper* captions.There is a small CLI tool for batch conversion and retiming.
```bash
pip install pysubs2
pysubs2 --shift 0.3s *.srt
pysubs2 --to srt *.ass
``````python
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")
```To learn more, please [see the documentation](http://pysubs2.readthedocs.io).
If you'd like to contribute, see [CONTRIBUTING.md](CONTRIBUTING.md).pysubs2 is licensed under the MIT license (see [LICENSE.txt](LICENSE.txt)).