Zovo Subtitle Fix

v1.0.0
io.github.theluckystrike/subtitle-fix Checked 4 days ago Published 28 days ago

Fix subtitles that are out of sync, right in the chat.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

fix_subtitles Fix subtitles

Use this when the user wants to fix subtitle timing or convert subtitles: shift an SRT or VTT file earlier or later, convert it from one frame rate to another (23.976, 24, 25, 29.97, 30, 50, 59.94, 60), sync it on two cues, trim overlapping cues, give short cues a minimum duration, strip formatting tags, renumber, or convert SRT to WebVTT and back. Takes one attached .srt or .vtt file (or the subtitle text) and returns the fixed file and a CSV change log with old and new times per cue. Times are whole milliseconds, rounded half up. Does not listen to audio or find the right offset by itself, d…

ParameterTypeDescription
fileobjectThe subtitle file: one .srt or .vtt file in UTF-8 or UTF-16 with a byte order mark, e.g. movie.srt.
fix_overlapsbooleantrue: when a cue ends after the next cue starts, or less than gap_ms before it, its end moves to gap_ms before that start. Default false.
from_fpsFrame rate the subtitles were timed for, e.g. 25. One of 23.976, 24, 25, 29.97, 30, 50, 59.94 or 60. Use with to_fps.
gap_msintegerGap kept before the next cue when fixing overlaps or extending cues, 0 to 1000 ms, e.g. 1 (default).
line_endingsstringLine endings of the output, e.g. crlf. Default same as the input (CRLF, LF, or CR for old Mac files).
min_duration_msintegerMake short cues last at least this long, up to gap_ms before the next cue, e.g. 1000. 0 (default) = off. Limit 10000.
output_formatstringOutput format, e.g. vtt to convert SRT to WebVTT. Default same as the input.
renumberbooleanSRT output: true (default) numbers cues 1, 2, 3 in output order; false keeps the numbers as written.
shift_msintegerMove all cues by this many milliseconds: positive = later, negative = earlier, e.g. 2500 (2.5 s later) or -1200. Limit 24 hours.
sort_by_startbooleantrue writes cues in start-time order (stable). Default false keeps the file order.
strip_tagsbooleantrue removes formatting tags such as <i>, <b>, <u>, <font>, WebVTT <c>/<v> tags and {\an8} codes from the text. Default false.
subtitle_textstringInstead of a file: the subtitle text itself, e.g. "1\n00:00:01,000 --> 00:00:03,000\nHello". Use either file or subtitle_text.
syncobjectTwo-point sync: cue_a should start at time_a and cue_b at time_b; all times are mapped on that straight line. Do not combine with shift_ms or frame rates.
to_fpsFrame rate of the video they should match, e.g. 23.976. One of 23.976, 24, 25, 29.97, 30, 50, 59.94 or 60. new time = old time x from_fps / to_fps.

check_subtitles Check subtitles

Use this when the user asks whether an SRT or VTT subtitle file has problems, or wants a report before fixing it: overlapping cues, zero or negative durations, cues out of order, SRT numbering gaps, empty cues, cues too fast to read (characters per second above max_cps, default 20) and lines longer than max_line_chars (default 42). Takes one attached .srt or .vtt file or the subtitle text. Does not make a file and does not change the subtitles; fix_subtitles does that. Does not check spelling, translation or sync with the audio.

ParameterTypeDescription
fileobjectThe subtitle file: one .srt or .vtt file in UTF-8 or UTF-16 with a byte order mark, e.g. movie.srt.
max_cpsnumberReading speed limit in characters per second, 5 to 60, e.g. 17. Default 20.
max_line_charsintegerLongest line in characters, 20 to 100, e.g. 42 (default).
subtitle_textstringInstead of a file: the subtitle text itself, e.g. "1\n00:00:01,000 --> 00:00:03,000\nHello". Use either file or subtitle_text.