- C# 97.9%
- PowerShell 1.1%
- Shell 0.9%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .nuke | ||
| build | ||
| src | ||
| .gitignore | ||
| build.cmd | ||
| build.ps1 | ||
| build.sh | ||
| global.json | ||
| LICENSE.md | ||
| README.md | ||
| SubConv.slnx | ||
| THIRD-PARTY-NOTICES.md | ||
SubConv
A simple CLI subtitle converter.
Dependencies
- MKVToolNix is required for
subconv infoandsubconv extractto function.- The program will attempt to find it itself through common install folders and PATH, but if it cannot be found, you can use the
--mkvtoolnixargument to specify its path.
- The program will attempt to find it itself through common install folders and PATH, but if it cannot be found, you can use the
Supported Formats
Input Formats
| Extension | Format |
|---|---|
.srt |
SubRip |
.ass / .ssa |
SubStation Alpha |
.vtt |
WebVTT |
.lrc |
Lyrics |
.sup |
PGS |
.idx / .sub |
VobSub |
Output Formats
| Extension | Format |
|---|---|
.srt |
SubRip |
.ass |
SubStation Alpha |
.vtt |
WebVTT |
.lrc |
Lyrics |
.sup |
PGS |
.idx / .sub |
VobSub |
Conversion Data Info
SRT / LRC / WebVTT → PGS / ASS / VobSub
- SRT, LRC, and WebVTT do not contain color, position, or font data.
- Uses white text in the standard subtitle placement.
ASS / PGS / VobSub → SRT / LRC / WebVTT
- Color and position data is lost because SRT, LRC, and WebVTT do not support them.
- Text appearance depends on the subtitle renderer.
PGS / VobSub → ASS
- Color and position data approximated where possible.
- Does not match font, Arial is used.
ASS → PGS / VobSub
- Color and position data rendered into output.
- Does not match font, Arial is used.
VobSub → PGS
- The original bitmap and position data are passed through.
PGS → VobSub
- The original bitmap and position data are passed through, but you'll have to specify a DVD-compatible size with
-s / --size
Commands
Convert Command
The convert command converts subtitle files between supported formats. It is the default command, so specifying convert is optional.
subconv <input> [output] [options]
Arguments
| Argument | Description |
|---|---|
<input> |
Required. Path to the input subtitle file. |
[output] |
Path to the output subtitle file. The output format is determined by the file extension. |
Options
| Option | Default | Description |
|---|---|---|
-l, --lang <language> |
eng |
Tesseract language code(s) to use when performing OCR. Accepts language codes supported by Tesseract. |
-e, --engine <engine> |
Tesseract |
Selects the OCR engine to use when recognizing text in image-based subtitles. |
-s, --size <width>x<height> |
Input size, or 1920x1080 |
Specifies the subtitle frame resolution. This sets the frame size for PGS output and the PlayRes values for ASS output. If omitted, SubConv uses the input resolution when available, otherwise defaults to 1920×1080. |
-c, --ocr-report |
false |
Enables an OCR report, logging low-confidence OCR results to a text file alongside the output file. |
-m, --multithread |
false |
Enables multithreaded OCR processing, allowing multiple subtitle frames to be processed concurrently. |
-t, --max-threads <count> |
CPU thread count | Sets the maximum number of threads available for OCR processing. Specifying this option automatically enables multithreading. |
--save-pngs |
Nothing | Path to export the processed bitmaps for PGS/VobSub OCR processing |
Examples
Converting with no special settings:
subconv input.sup output.ass
Converting a bitmap format with OCR that's in another language:
subconv input.sup output.ass -l jpn
Converting a bitmap format with OCR using multiple threads:
subconv input.sup output.ass -m
Limiting OCR processing to 4 threads:
subconv input.sup output.ass -t 4
Generating an OCR report:
subconv input.sup output.ass -c
Specifying a custom frame resolution:
subconv input.sup output.sub -s 720x480
Using multiple options:
subconv input.sup output.ass -l jpn -t 8 --ocr-report
Info Command
The info command displays information about subtitle tracks in an MKV file, or details about a supported subtitle file.
subconv info <input> [options]
Arguments
| Argument | Description |
|---|---|
<input> |
Required. Path to an MKV file or subtitle file. |
Options
| Option | Default | Description |
|---|---|---|
--mkvtoolnix <folder> |
PATH |
Specifies the folder containing mkvmerge and mkvextract if they aren't available in the system PATH. Only used when inspecting MKV files. |
Examples
Displaying information about an MKV file:
subconv info input.mkv
Displaying information about a subtitle file:
subconv info subtitles.sup
Specifying a custom MKVToolNix folder:
subconv info input.mkv --mkvtoolnix "C:\Program Files\MKVToolNix"
Extract Command
The extract command extracts subtitle tracks from an MKV file using MKVToolNix.
subconv extract <input> [output] [options]
Arguments
| Argument | Description |
|---|---|
<input> |
Required. Path to the MKV file to extract subtitle tracks from. |
[output] |
Output file for a single track, or output folder when extracting multiple tracks. Defaults to a folder alongside the input file. |
Options
| Option | Default | Description |
|---|---|---|
-i, --id <id> |
All subtitle tracks | Specifies the ID of the track to extract. Accepts multiple track IDs separated by commas. See the info command for track IDs. |
--mkvtoolnix <folder> |
PATH |
Specifies the folder containing mkvmerge and mkvextract if they aren't available in the system PATH. |
Examples
Extracting all subtitle tracks:
subconv extract input.mkv
Extracting all subtitle tracks to a specific folder:
subconv extract input.mkv ./subtitles
Extracting a single subtitle track:
subconv extract input.mkv output.sup -i 3
Extracting multiple specific subtitle tracks:
subconv extract input.mkv ./subtitles -i 2,3,5
Specifying a custom MKVToolNix folder:
subconv extract input.mkv ./subtitles --mkvtoolnix "C:\Program Files\MKVToolNix"
Additional Options
| Option | Description |
|---|---|
--help |
Displays help information. |
--version |
Displays the current version. |
--no-config |
Ignores the configuration file and uses command-line arguments and built-in defaults instead. |
Config File
A config file is optionally supported, named subconv.conf and placed in the same directory as the executable.
The config file allows you to specify default CLI arguments, each argument being placed on its own line.
For example:
--mulithread
-t 16
-c
The config file is optional.
It can also be skipped with --no-config.
PGS/VobSub Note
In order to convert PGS and VobSub to anything, they must be put through OCR, because these formats don't use text for the subtitles but rather bitmaps.
Because of this, the output isn't always perfect. OCR isn't always completely accurate. With TessData_Best, it gets really close, but you might have to fix some things yourself still.
Most commonly, I l 1 | get mixed up with each other.
You will have to download a training database for Tesseract, from tesseract-ocr/tessdata_best or tesseract-ocr/tessdata_fast then put it in a tessdata folder next to the executable in order to read VobSub and PGS.
And why did I write PGS/VobSub output support? Why the hell not! It was fun :)