Skip to content

muinyc/srt-processor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

> srt-processor

Two CLI tools that fix SRT subtitle timing problems automatically and flag overlong lines, with sensible broadcast/streaming defaults out of the box.

Requirements

  • Python 3.12+
  • uv

Quick start

git clone https://gitlab.com/cynium/srt-processor.git
cd srt-processor
uv pip install .

Or run directly without installing:

uv run srt_fixer.py input.srt output.srt

The only dependency is pysrt.

How it works

input.srt ──> Pass 1 (structural fixes) ──> Pass 2 (readability) ──> output.srt

srt_fixer reads an SRT file, applies timing corrections in two passes, and writes the result. Pass 1 handles structural issues: extending subtitles shorter than the minimum duration, trimming those exceeding the maximum, and widening gaps that are too small. Pass 2 extends subtitles where the characters-per-second exceeds the reading speed limit.

find_long_lines scans an SRT file and reports which captions have lines exceeding a character limit. HTML tags (like <i>) are stripped before measuring.

Usage

srt_fixer

# Fix timing and write to a new file
python srt_fixer.py input.srt output.srt

# Preview changes without writing
python srt_fixer.py input.srt output.srt --dry-run

# Custom thresholds
python srt_fixer.py input.srt output.srt --gap 80 --cps 20 --min-duration 800 --max-duration 7000
Flag Default Description
--gap 66 Minimum gap between subtitles (ms)
--cps 25.0 Maximum characters per second
--min-duration 600 Minimum subtitle duration (ms)
--max-duration 8000 Maximum subtitle duration (ms)
--dry-run off Show what would change without writing

find_long_lines

# Default limit of 43 characters per line
python find_long_lines.py subtitles.srt

# Custom limit
python find_long_lines.py subtitles.srt --max-length 37

Defaults

The defaults are based on common broadcast/streaming standards:

  • 66 ms gap — two frames at 30 fps, ensures subtitle transitions are visible.
  • 25 CPS — Netflix's guideline for adult content; comfortable reading speed for most viewers.
  • 600 ms minimum — subtitles shorter than this flash too quickly to register.
  • 8000 ms maximum — subtitles longer than this tend to be re-read unnecessarily.
  • 43 characters per line — common standard for TV and streaming subtitles, ensures text fits on screen without wrapping at standard font sizes.

License

MIT


© 2026 Stefan Kubicki • a CYNIUM release • shipped from the Atoll


Canonical URL: https://forge.cynium.com/cynium/srt-processor

About

Utility scripts to fix SRT timing problems for delivery.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors

Languages