fix_common_problems
Repair common SRT/WebVTT issues like out-of-order, overlapping, empty or misindexed cues, long lines, and encoding problems. It reports fixes by default; set apply=true to write the corrected file.
Instructions
Repair the usual damage in SRT/WebVTT files. DRY RUN BY DEFAULT: it lists every fix it would make (with cue numbers and before/after times) and writes nothing until you call again with apply=true.
Fixes: out-of-order cues are re-sorted; cues with end <= start get a readable duration (never past the next cue); overlapping cues are trimmed to the next cue's start; empty cues and blank lines inside cues are removed; missing/duplicate/wrong SRT index numbers are renumbered; lines longer than max_line_length are re-wrapped (balanced; dialogue dashes keep one speaker per line); the BOM and mixed CR/LF line endings are normalised. With strip_tags=true, HTML/font/WebVTT/ASS tags are removed from the text.
Flagged but never changed: reading-speed outliers (more than max_cps characters per second) and cues on screen for over 10 seconds; overlapping cues that start together.
Args: path: .srt or .vtt file. apply: false (default) = report only; true = write the repaired file. strip_tags: also remove , , <font ...>, <v ...>, {\an8} etc. (default false). max_line_length: wrap lines longer than this many visible characters (default 42). max_cps: reading-speed flag threshold in characters per second (default 25). output: where to write when apply=true (default: .fixed.). overwrite: allow replacing an existing output file (default false). encoding: force the input text encoding. output_encoding: encoding of the written file (default utf-8).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| apply | No | ||
| output | No | ||
| max_cps | No | ||
| encoding | No | ||
| overwrite | No | ||
| strip_tags | No | ||
| max_line_length | No | ||
| output_encoding | No | utf-8 |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |