Skip to main content

Subtitle Toolkit - A collection of utilities for working with subtitle files

Project description

Subtitle Toolkit 🍿

Your Swiss Army knife for everything subtitle-related.

Python Version License

Subtitle Toolkit is a collection of tools for working with subtitle files. Whether you're a translator, video editor, accessibility advocate, or just someone who needs to fix out-of-sync subtitles, this toolkit has you covered.

What Can It Do?

  • Translate subtitles using AI (supports any LLM via LiteLLM)
  • Fix timing with uniform shifts or drift correction for frame-rate issues
  • Convert between formats: SRT, VTT, ASS, TTML, and many more
  • Extract subtitle tracks from MKV/MP4 video files
  • Merge multiple subtitle tracks into one

Installation

For end users:

pip install subtitle-toolkit

For the web interface:

pip install subtitle-toolkit[web]

For developers (all dependencies including testing tools):

pip install subtitle-toolkit[all]

Or install in editable mode for development:

pip install -e subtitle-toolkit[all]

Quick Start

Web interface (recommended for most users):

subtitle-tk web
# Then open http://localhost:8000 in your browser

Command line:

# Shift every timestamp 2.5 seconds later (positive = later)
subtitle-tk timeshift --shift-seconds 2.5 < input.srt > output.srt

Web Interface

The web interface is the easiest way to use Subtitle Toolkit. No command line needed—just upload your file, adjust settings, and download the result.

Getting Started

  1. Start the server:

    subtitle-tk web
    
  2. Open your browser to http://localhost:8000

  3. Choose a tool from the menu and follow the on-screen instructions

Available Tools

Tool What It Does
Translate Translate subtitles using AI. Supports any LLM provider (OpenAI, Anthropic, local models, etc.).
Timeshift Shift all timestamps by a fixed amount (e.g., "subtitles are 2 seconds late").
Autosync Fix drift issues where subtitles slowly get more out of sync over time (common with frame-rate conversion).
Subtitle Tracks List, extract, or merge subtitle tracks from video files.
Convert Convert between subtitle formats (SRT, VTT, ASS, TTML, and more).

Multi-Language Support

The web interface is available in 17 languages: English, Arabic, German, Spanish, Persian, French, Indonesian, Italian, Japanese, Korean, Dutch, Polish, Portuguese, Turkish, Ukrainian, Vietnamese, and Chinese.


Command-Line Interface

For scripting, automation, or if you prefer the terminal, the CLI provides the same functionality.

Commands

Command Description
translate Translate subtitles using AI
timeshift Uniform timestamp adjustment
autosync Drift correction (time-varying offset)
subtitle-tracks List, extract, merge subtitle tracks
convert Convert between subtitle formats
web Start the web interface

Examples

Translate subtitles (requires API key or local LLM):

subtitle-tk translate input.srt --instructions "Translate to Spanish"

Shift timestamps (move subtitles to 3 seconds later):

subtitle-tk timeshift --shift-seconds 3 < input.srt > output.srt

Fix drift (at 10:00, subtitles are 5 seconds late):

subtitle-tk autosync --correct-at 00:00:00 --offset-at 00:10:00 --offset 5 < input.srt > output.srt

Or specify multiple sync points:

subtitle-tk autosync --point 00:00:00:0 00:05:00:2.5 00:10:00:5 < input.srt > output.srt

List subtitle tracks in a video:

subtitle-tk subtitle-tracks list video.mkv

Extract all subtitle tracks as a zip file:

subtitle-tk subtitle-tracks extract video.mkv --all --as-zip

Convert to VTT format:

subtitle-tk convert input.srt --output-format vtt -o output.vtt

Get help for any command:

subtitle-tk <command> --help

Common Use Cases

"My subtitles are 2 seconds late"

Use Timeshift with a positive shift value.

"My subtitles start fine but drift out of sync over time"

Use Autosync with one or more sync points.

"I need subtitles in another language"

Use Translate with your preferred AI provider.

"I have a video file and need the subtitle tracks"

Use Subtitle Tracks to extract them.

"My video editor needs a different subtitle format"

Use Convert to change the format.


Docker (Optional)

Skip this section if Docker isn't your thing. The pip installation works great for most users.

docker build -t subtitle-toolkit .
docker run -p 8000:8000 subtitle-toolkit

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests. The codebase is Python 3.8+ and uses FastAPI for the web interface.


License

GPL-3.0 — See LICENSE for details.


Happy subtitling! 🎬

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

subtitle_toolkit-0.9.7.5.tar.gz (154.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

subtitle_toolkit-0.9.7.5-py3-none-any.whl (182.2 kB view details)

Uploaded Python 3

File details

Details for the file subtitle_toolkit-0.9.7.5.tar.gz.

File metadata

  • Download URL: subtitle_toolkit-0.9.7.5.tar.gz
  • Upload date:
  • Size: 154.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for subtitle_toolkit-0.9.7.5.tar.gz
Algorithm Hash digest
SHA256 9354db5ae993a040379e37c1ed1c439840fe0a13b3e2e4d782cfc04c3ef9315a
MD5 a0c6aa74afcd19b55f80bb8547891ff9
BLAKE2b-256 7d2494bc4b6ba5eb04545fcd57314614d00f2d1132900f5fc36e0a51bac510b4

See more details on using hashes here.

File details

Details for the file subtitle_toolkit-0.9.7.5-py3-none-any.whl.

File metadata

File hashes

Hashes for subtitle_toolkit-0.9.7.5-py3-none-any.whl
Algorithm Hash digest
SHA256 640af938418eaf779e79c184ad019534c6ebcd80f9b7df0f92791db9aea77a4d
MD5 76643d9be6c1f3d07a9013a0bee58822
BLAKE2b-256 4f6f72b07db584f39e617d36d76f8fa015c53cb80f2a8057cfdbafbe52c11b48

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page