Skip to main content

A small CLI tool to extend subtitle durations in SRT files to make them more readable on a screen.

Project description

SubGapFix

PyPI version Python versions License: MIT

SubGapFix is a lightweight CLI tool that makes subtitles easier and more comfortable to read by intelligently extending their display duration — especially useful for auto-generated subtitles.

It works great with transcriptions from WhisperX.

✨ Features

  • Extends subtitle display time when there is a gap before the next line
  • Safely prevents overlaps and negative durations
  • Dry-run mode to preview changes without writing files
  • Creates output folders automatically if needed
  • Only processes valid .srt files
  • Option to merge subtitles when a sentence is spanning over multiple subtitles (supported languages: English, Dutch)

📦 Installation

pip install subgapfix

Requires Python 3.8+.

Dependencies:

  • typer — beautiful CLI interface
  • srt — reliable SRT parsing

🚀 Quick Start

# Basic usage — creates episode_fixed.srt in the same folder
subgapfix episode.srt

# Custom output file (creates folders if needed)
subgapfix podcast/episode.srt -o podcast/enhanced/episode_subtitles.srt

# Preview changes without modifying anything
subgapfix input.srt --dry-run

# Customize timings
subgapfix input.srt --extend-sub-start 0.8 --extend-sub-end 3.0 --min-gap 1.5 --extend-final-sub 4.5

# Merge sentences (default language: en)
subgapfix input.srt --submerge --lang nl

⚙️ All Options

Flag / Short Default Description
input_file (positional) Path to the input .srt file (must exist)
-o, --output <input>_fixed.srt Output file path (folders auto-created)
--extend-sub-start, -ess 0.5 Seconds to pull the next subtitle backward (tries to borrow from gap)
--extend-sub-end, -ese 2.0 Maximum seconds to extend current subtitle forward into the gap
--min-gap, -mg 1.0 Only apply extension if gap is at least this long (seconds)
--dry-run false Show how many pairs would change — no file written
--extend-final-sub, -efs 1.0 Number of seconds to add to the last subtitle
--submerge, -sm false Merge subtitles creating full sentences
--lang, -l en Set language in order to merge sentences correctly
--help, -help Show full help and exit

How It Works

  1. Reads and validates the .srt file
  2. For each pair of consecutive subtitles:
    • If gap < --min-gap → splits the gap evenly (closes small gaps)
    • If gap ≥ --min-gap → extends current subtitle up to --extend-sub-end, pulls next one back by --extend-sub-start
  3. Prevents any overlap by enforcing a tiny 10 ms safety gap
  4. Add --extend-final-sub to the last subtitle for a precise ending
  5. Writes the result (or just reports changes in dry-run)

Before (typical WhisperX-style tight timings):

1
00:00:01,837 --> 00:00:02,502
SubGapFix makes our lives

2
00:00:03,147 --> 00:00:03,571
much easier.

3
00:00:04,176 --> 00:00:04,518
Yes, I agree.

After (with defaults):

1
00:00:01,837 --> 00:00:02,824
SubGapFix makes our lives

2
00:00:02,834 --> 00:00:03,873
much easier.

3
00:00:03,883 --> 00:00:04,679
Yes, I agree.

After (merging sentences):

1
00:00:01,837 --> 00:00:03,873
SubGapFix makes our lives much easier.

2
00:00:03,883 --> 00:00:04,679
Yes, I agree.

💡 Why SubGapFix?

Modern speech-to-text tools often prioritize transcription accuracy over comfortable reading speed.
Subtitles flash by too quickly → viewers miss text or feel rushed.

SubGapFix does not shift timings or re-sync — it only lengthens display time using existing gaps.
This keeps perfect sync with the video while making subtitles far more readable.

Perfect for lectures, interviews, conversations, podcasts.

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

subgapfix-0.0.4.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

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

subgapfix-0.0.4-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file subgapfix-0.0.4.tar.gz.

File metadata

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

File hashes

Hashes for subgapfix-0.0.4.tar.gz
Algorithm Hash digest
SHA256 0424fcc4f2af971a63758fc98fc852a5982dff12fb7d5c4bac3a7b827882c85c
MD5 1c3132f78a8f1d5e2e80e644f3c6612f
BLAKE2b-256 3fe51c1b568d820d6c6e42556dcd4985abccf0608cd48e7ecef290d5a8a030b3

See more details on using hashes here.

File details

Details for the file subgapfix-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: subgapfix-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for subgapfix-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d5eff4fb5e237b4094e2cebb51c9cbc6c535ad6109980df44924e21ef775e142
MD5 91d6252c7318d04d9fbb5202defd6911
BLAKE2b-256 0f025ecf1ec0a78827fc7d1d09e2c5af4984301aee55565d82c83fd5e5c39473

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