SRT, VTT and timestamp validation
SRT, VTT and timestamp validation — Automatic subtitles from local ASR. A minimal file a player can read; Time in milliseconds; A negative syntax test set. Practical assignment: SRT, VTT and timestamp validation.
Demo edition. The materials are undergoing editorial review.
Topics covered
- A minimal file a player can read
- Time in milliseconds
- A negative syntax test set
A minimal file a player can read
SRT consists of numbered blocks containing start/end times, text and a blank separator. Conventional SRT uses a comma before milliseconds. WebVTT begins with WEBVTT, a blank line and cue blocks using a decimal point in timestamps; cue identifiers are optional. The snippets show the same teaching phrase in both formats, not a transcript of your video. Save separate UTF-8 files so Cyrillic and Italian accents display correctly. Do not paste Markdown fences into the actual subtitle file; they only display code in this lesson. A WEBVTT header does not validate the remaining blocks. If captions do not appear, inspect the text for missing separators, wrong decimal punctuation or an accidental .txt extension. Make the minimal example work before adding styling, separating syntax errors from presentation or player issues.
1
00:00:01,000 --> 00:00:03,000
Save a copy.
2
00:00:03,200 --> 00:00:05,400
Check the filename.
WEBVTT
00:00:01.000 --> 00:00:03.000
Save a copy.
00:00:03.200 --> 00:00:05.400
Check the filename.
Time in milliseconds
Convert timestamps to numbers for validation. 00:01:02.500 equals 60,000+2,000+500=62,500 ms. Cue duration is end−start; the first example lasts 3,000−1,000=2,000 ms. Check start≥0, end>start and an end within the intended timeline. These are our project checks, not a claim that every overlap violates WebVTT. Simultaneous cues can be valid, for example at different positions. For this single-speaker exercise adopt a no-overlap editorial policy to prevent accidental stacking. If cues overlap by 100 ms, listen and deliberately adjust that boundary rather than shifting every following cue automatically. A global shift could damage otherwise correct synchronization. Preserve original times so you can distinguish ASR segmentation from later editing changes and explain the correction.
A negative syntax test set
Create four small copies: valid VTT, missing header, end=start and damaged character encoding. Open them in the target editor or parser and record behavior rather than expecting identical errors from every player. One may silently skip a cue while another rejects the file. For FFmpeg conversion, inspect diagnostics and cue count afterward: successful execution does not guarantee all text and styling survived. Do not “repair” encoding by deleting difficult characters, which damages the language. Save UTF-8 in a text editor and verify specific words. In validation.md record input, expected behavior, observed reaction and status; use not_run for unexecuted checks. Learn to separate syntax errors from empty or wrong-language transcription. Use tiny teaching copies rather than corrupting the only copy of real subtitles.
Practical assignment
SRT, VTT and timestamp validation
Continue to learning