API Reference
Python implementation
You can find a full featured reference implementation with validation support in Python at the STJLib repo.
Tools
stj_validator.py
Description: Validates an STJ file against the STJ schema.
Usage:
python stj_validator.py <stj_file>
Arguments:
<stj_file>: Path to the STJ file to validate.
Example:
python stj_validator.py examples/latest/multilingual.stj.json
stj_to_srt.py
Description: Converts an STJ file to an SRT subtitle file.
Usage:
python stj_to_srt.py <stj_file> <output_srt>
Arguments:
<stj_file>: Path to the STJ file.<output_srt>: Path to the output SRT file.
Example:
python stj_to_srt.py examples/latest/multilingual.stj.json output.srt
stj_to_vtt.py
Description: Converts an STJ file to a WebVTT subtitle file.
Usage:
python stj_to_vtt.py <stj_file> <output_vtt>
Arguments:
<stj_file>: Path to the STJ file.<output_vtt>: Path to the output VTT file.
Example:
python stj_to_vtt.py examples/latest/multilingual.stj.json output.vtt
stj_to_ass.py
Description: Converts an STJ file to an ASS (Advanced SubStation Alpha) subtitle file.
Usage:
python stj_to_ass.py <stj_file> <output_ass>
Arguments:
<stj_file>: Path to the STJ file.<output_ass>: Path to the output ASS file.
Example:
python stj_to_ass.py examples/latest/multilingual.stj.json output.ass
stj-validator.js
Description: Validates an STJ file against the STJ schema using Node.js.
Usage:
node stj-validator.js <stj_file> <schema_file>
Arguments:
<stj_file>: Path to the STJ file to validate.<schema_file>: Path to the JSON schema file.
Example:
node stj-validator.js examples/latest/multilingual.stj.json spec/schema/latest/stj-schema.json
stj-to-srt.js
Description: Converts an STJ file to an SRT subtitle file using Node.js.
Usage:
node stj-to-srt.js <stj_file> <output_srt>
Arguments:
<stj_file>: Path to the STJ file.<output_srt>: Path to the output SRT file.
Example:
node stj-to-srt.js examples/latest/multilingual.stj.json output.srt
stj-to-vtt.js
Description: Converts an STJ file to a WebVTT subtitle file using Node.js.
Usage:
node stj-to-vtt.js <stj_file> <output_vtt>
Arguments:
<stj_file>: Path to the STJ file.<output_vtt>: Path to the output VTT file.
Example:
node stj-to-vtt.js examples/latest/multilingual.stj.json output.vtt
stj-to-ass.js
Description: Converts an STJ file to an ASS (Advanced SubStation Alpha) subtitle file using Node.js.
Usage:
node stj-to-ass.js <stj_file> <output_ass>
Arguments:
<stj_file>: Path to the STJ file.<output_ass>: Path to the output ASS file.
Example:
node stj-to-ass.js examples/latest/multilingual.stj.json output.ass
Modules
Python
stj_validator.py
- Function:
main() - Validates the STJ file using stjlib
- Dependencies:
stjlibargparse
stj_to_srt.py
- Function:
generate_srt(stj_file_path, output_srt_path) - Converts STJ file to SRT format
- Dependencies:
stjlibsrtargparsedatetime.timedelta
stj_to_vtt.py
- Function:
generate_vtt(stj_file_path, output_vtt_path) - Converts STJ file to WebVTT format
- Dependencies:
stjlibwebvttargparse
stj_to_ass.py
- Function:
generate_ass(stj_file_path, output_ass_path) - Converts STJ file to ASS format
- Dependencies:
stjlibargparse
JavaScript
stj-validator.js
- Function:
validateSTJ(stjFilePath, schemaFilePath) - Validates the STJ file against the schema.
- Dependencies:
fsajv
stj-to-srt.js
- Function:
generateSRT(stjData, outputSrtPath) - Converts STJ data to SRT format.
- Dependencies:
fssrt-parser-2moment
stj-to-vtt.js
- Function:
generateVTT(stjData, outputVttPath) - Converts STJ data to WebVTT format.
- Dependencies:
fsnode-webvttmoment
stj-to-ass.js
- Function:
generateASS(stjData, outputAssPath) - Converts STJ data to ASS format.
- Dependencies:
fsprocess