Convert ASS subtitle to SRT format
Project description
pyasstosrt
pyasstosrt – this tool will help you convert Advanced SubStation Alpha (ASS/SSA) subtitle files to SubRip (SRT) files.
Support for str path:
from pyasstosrt import Subtitle
sub = Subtitle('sub.ass')
sub.export()
Support for all Path-like objects, instead of only pathlib's Path:
from pathlib import Path
from pyasstosrt import Subtitle
path = Path('sub.ass')
sub = Subtitle(path)
sub.export()
You can get a sheet with dialogue by specifying output_dialogues.
from pathlib import Path
from pyasstosrt import Subtitle
path = Path('sub.ass')
sub = Subtitle(path)
sub.export(output_dialogues=True)
If you want to remove effects from text, you can use the removing_effects.
from pyasstosrt import Subtitle
sub = Subtitle('sub.ass', removing_effects=True)
sub.export()
You can enable the deletion of duplicate lines with the rearrangement of start and end times.
from pyasstosrt import Subtitle
sub = Subtitle('sub.ass', remove_duplicates=True)
sub.export()
You can get a list of all styles in the file and filter subtitles by style names.
from pyasstosrt import Subtitle
# Get list of all styles in the file
sub = Subtitle('sub.ass')
styles = sub.get_styles()
print(styles) # ['Default', 'Alt', 'Signs', 'Credits']
# Export only styles with "Default" in name (e.g., Default, Default_dvd)
sub = Subtitle('sub.ass', only_default_style=True)
sub.export()
# Export only Default style
sub = Subtitle('sub.ass', include_styles=['Default'])
sub.export()
# Export only Default and Alt styles
sub = Subtitle('sub.ass', include_styles=['Default', 'Alt'])
sub.export()
# Exclude Signs and Credits styles
sub = Subtitle('sub.ass', exclude_styles=['Signs', 'Credits'])
sub.export()
CLI
🎬 Export Command
Convert ASS/SSA subtitle files to SRT format with various options.
Basic usage:
pyasstosrt export subtitle.ass
Specify output directory:
pyasstosrt export subtitle.ass --output-dir /path/to/output
# or use short form
pyasstosrt export subtitle.ass -o /path/to/output
Remove effects and duplicates:
pyasstosrt export subtitle.ass --remove-effects --remove-duplicates
# or use short form
pyasstosrt export subtitle.ass -r -d
Process multiple files at once:
pyasstosrt export subtitle1.ass subtitle2.ass subtitle3.ass
Style filtering options:
# Export only styles with "Default" in name (e.g., Default, Default_dvd)
pyasstosrt export subtitle.ass --only-default
# Export only specific styles
pyasstosrt export subtitle.ass --include-styles "Default,Signs"
# Exclude specific styles
pyasstosrt export subtitle.ass --exclude-styles "Signs,Credits"
Custom encoding:
pyasstosrt export subtitle.ass --encoding utf-16
Print dialogues to console:
pyasstosrt export subtitle.ass --output-dialogues
🎨 Styles Command
List all unique styles found in an ASS subtitle file.
Basic usage:
pyasstosrt styles subtitle.ass
Display in table format:
pyasstosrt styles subtitle.ass --table
# or use short form
pyasstosrt styles subtitle.ass -t
🔧 General Options
Show version:
pyasstosrt --version
# or
pyasstosrt -v
Show help:
pyasstosrt --help
pyasstosrt export --help
pyasstosrt styles --help
Enable shell completion:
# For bash
pyasstosrt --install-completion bash
# For zsh
pyasstosrt --install-completion zsh
# For fish
pyasstosrt --install-completion fish
Installation
Most users will want to simply install the latest version, hosted on PyPI:
$ pip install 'pyasstosrt[cli]'
If you just want to use it as a library and don't need the CLI, you can omit the [cli] extra.
Project details
Release history Release notifications | RSS feed
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 pyasstosrt-1.5.0.tar.gz.
File metadata
- Download URL: pyasstosrt-1.5.0.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
122f676a185c3951ff89a165f2ad402f9f1ffa6fd53474a65496bdb83b6198dd
|
|
| MD5 |
5194e95b7c547bbf5670f1be898767f1
|
|
| BLAKE2b-256 |
108d9936fba19366c3a9274f7c1f1092d4d04312cf475505e9b5c91316032442
|
File details
Details for the file pyasstosrt-1.5.0-py3-none-any.whl.
File metadata
- Download URL: pyasstosrt-1.5.0-py3-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d178f9ceb269fb329ad3b1973bad5abf68dd5141e88282a44257ddf3e0ce115e
|
|
| MD5 |
df76fd7f6c42c41bb7755cb7fccedd5c
|
|
| BLAKE2b-256 |
d726f6a618fe8cd5da96399b9ad598dbad8f95a537b054162cd1cc969d5bde12
|