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

📦 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

⚙️ 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
--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-end-max, pulls next one back by --extend-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.

💡 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.3.tar.gz (4.7 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.3-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for subgapfix-0.0.3.tar.gz
Algorithm Hash digest
SHA256 7cb19b82b6a1c675cc6f15835bc9cf814c5f81264f417717a353ca5c3f7a3a52
MD5 d6295f32686f83091f5d630b24dd22a9
BLAKE2b-256 9e46258139ae4621e37e9b5a0e824852e6614ee12ceeb2989ee0f2ae9554d4ed

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for subgapfix-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 af4abc88d9aba41c24d7739ac570e846d7c687f86107ffcab9dbd5fd067b52f7
MD5 38e2f3953d1015c69bfa90f7cdbbdc36
BLAKE2b-256 6fa2cceb9dac95892e3dcbba6db9d82fbb754fcce9e569c00857760d2dd9bb57

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