Command Line Interface¶
PyAssToSrt provides a command-line interface (CLI) for easy batch conversion of ASS subtitle files. The CLI is available when you install the package with the cli extra:
pip install 'pyasstosrt[cli]'
Basic Usage¶
The basic command syntax is:
pyasstosrt export [OPTIONS] FILEPATH...
Where FILEPATH… is one or more paths to ASS subtitle files.
Commands¶
exportConvert ASS/SSA subtitle file(s) to SRT format.
stylesList all unique styles found in an ASS subtitle file.
Export Options¶
The export command supports the following options:
--remove-effects, -rRemove effects from subtitles.
--remove-duplicates, -dRemove duplicate subtitles.
--only-default, -DExport only styles containing ‘Default’ in name (excludes Signs, Credits, etc.).
--include-styles, -i TEXTComma-separated list of style names to include (e.g., ‘Default,Signs’).
--exclude-styles, -x TEXTComma-separated list of style names to exclude (e.g., ‘Signs,Credits_dvd’).
--output-dir, -o PATHOutput directory for the SRT file(s).
--encoding, -e TEXTEncoding for the output file. Default is “utf8”.
--output-dialogues, -pPrint dialogues to console.
--version, -vShow version and exit.
Note
The style filtering options (--only-default, --include-styles, --exclude-styles)
are mutually exclusive. You can only use one at a time.
Styles Command Options¶
The styles command supports the following options:
--table, -tDisplay styles in a formatted table.
Examples¶
Basic Conversion¶
Convert a single ASS file to SRT:
pyasstosrt export subtitle.ass
Running Without Installation¶
You can run pyasstosrt without installing it using tools like uvx:
uvx --from 'pyasstosrt[cli]' pyasstosrt export * --remove-effects --remove-duplicates
This command will use all ASS files in the current directory, remove effects and duplicates, and convert them to SRT format.
Convert Multiple Files¶
Process multiple files at once:
pyasstosrt export file1.ass file2.ass file3.ass
Remove Effects¶
Convert and remove visual effects from the subtitle text:
pyasstosrt export subtitle.ass --remove-effects
Remove Duplicates¶
Convert and remove/merge consecutive duplicate dialogues:
pyasstosrt export subtitle.ass --remove-duplicates
Custom Output Directory¶
Save the converted file(s) to a specific directory:
pyasstosrt export subtitle.ass --output-dir ./output_folder
Custom Encoding¶
Specify the encoding for the output file:
pyasstosrt export subtitle.ass --encoding utf-16
Print Dialogues¶
Convert and print the dialogues to the console:
pyasstosrt export subtitle.ass --output-dialogues
Combine Options¶
You can combine multiple options:
pyasstosrt export subtitle.ass --remove-effects --remove-duplicates --output-dir ./output
Style Filtering¶
List Available Styles¶
Before filtering styles, you can list all available styles in a subtitle file:
pyasstosrt styles subtitle.ass
Display styles in a formatted table:
pyasstosrt styles subtitle.ass --table
Export Only Default Styles¶
Export only dialogue styles (excludes signs, credits, etc.):
pyasstosrt export subtitle.ass --only-default
Include Specific Styles¶
Export only specific styles by name:
pyasstosrt export subtitle.ass --include-styles "Default,Alt"
Include multiple styles:
pyasstosrt export subtitle.ass --include-styles "Default,Thoughts,Narration"
Exclude Specific Styles¶
Export all styles except specific ones:
pyasstosrt export subtitle.ass --exclude-styles "Signs,Credits"
Exclude multiple styles:
pyasstosrt export subtitle.ass --exclude-styles "Signs,Credits_dvd,Opening,Ending"
Combine Style Filtering with Other Options¶
You can combine style filtering with other conversion options:
pyasstosrt export subtitle.ass --only-default --remove-effects --remove-duplicates
pyasstosrt export subtitle.ass --include-styles "Default,Alt" --output-dir ./output