Code Lab
AutoClip: What an SRT Cue Can Tell You About Word Timing
CODE LAB · PROJECT SPOTLIGHT
AutoClip Python · MIT
Follow the editing workflow from an SRT cue to word timing.
Project preview · zhouxiaoka/autoclip
AutoClip can use an existing SRT file when you import a video. That gives it the cue intervals a producer has already checked. The word-level editor still needs to decide where each word falls inside a cue. The Python implementation can use matching word timings from a separate alignment file or estimate how to divide the original interval.

Where the cue becomes a list of words
An SRT cue generally specifies a start time, end time and text. AutoClip splits the text at whitespace and selected punctuation. It divides the cue duration by the number of resulting tokens and assigns each an equal interval. The segment retains the cue boundaries and labels this fallback as estimated. Elsewhere in the same file, aligned timings can replace that estimate when the sidecar matches the cue text and rounded time bounds.
Reproduce the estimate on a three-second cue
We isolated the constructor and word-timing method from the pinned module and supplied the interval 12.0–15.0 seconds and the text Mark the cut.. In an AutoClip development environment, import SubtitleProcessor from backend.utils.subtitle_processor and run the example below.
processor = SubtitleProcessor()
words = processor._split_text_to_words("Mark the cut.", 12.0, 15.0)
for word in words:
print(f"{word['text']}: {word['startTime']:.1f}–{word['endTime']:.1f} s")Observed output
Mark: 12.0–13.0 s the: 13.0–14.0 s cut.: 14.0–15.0 s
All three spans are one second long. The period stays attached to the last token because the split pattern in this revision omits the ASCII full stop. If the speaker pauses after the first word, the cue boundaries alone cannot locate that pause. This test exercised the upstream estimate on text. An end-to-end render or speech recognition run would measure different behavior.
Check the cue and the highlight separately
First compare the clip against the original SRT to check where each complete caption appears and disappears. Then replay the words around a pause. If the sentence is correctly placed but individual highlights lead or lag the speech, inspect the timing source before changing the SRT. Adjusting the cue boundaries may move a correctly placed caption without improving its internal timing.
Code excerpt © 2024 AutoClip Team. MIT license · Pinned source · Mindung’s project roundup · Related Code Lab article on frame boundaries.
