Lab 4.3: Subtitle Parsing & Timing Validation
Act as a media localization engineer diagnosing broken subtitle streams.
Objective
In this hands-on lab, you will act as a media localization engineer diagnosing broken subtitle streams. You will convert and repair corrupted SubRip Text (.srt) and WebVTT (.vtt) files, resolve millisecond delimiter errors, fix missing cue boundary separators, and repair unclosed inline formatting tags using Visual Studio Code and Regular Expressions.
Required Setup & Prerequisites
Editor: Visual Studio Code installed.
Working Directory: Open your
loc_labworking directory in VS Code.
Step-by-Step Instructions
Step 1: Create Corrupted Subtitle Assets
Open VS Code and navigate to
assets/loc/media/.Create
broken_subtitles.srtand paste:Code snippet
broken_subtitles.srt1 00:00:01.500 --> 00:00:04.200 Welcome to the <i>Global Release event! 2 00:00:04,200 --> 00:00:08,000 ¡Hola! ¿Cómo estás?(Notice line 2 uses periods instead of commas, and line 3 has an unclosed
<i>tag).In the same directory, create
broken_captions.vttand paste:Code snippet
broken_captions.vttWEBVTT cue-01 00:00:01,500 --> 00:00:04,200 <v Narrator>Welcome back to the dashboard! cue-02 00:00:04.500 --> 00:00:08.000 <v Alex>¡Bienvenido a la plataforma!(Notice line 4 uses commas instead of periods, and there is no blank line between cue-01 and cue-02).
Save both files (
Cmd + Son macOS /Ctrl + Son Windows).
Step 2: Remediate the SRT Asset (broken_subtitles.srt)
Open
broken_subtitles.srtin VS Code.Fix Millisecond Delimiters:
Line 2 uses periods (
00:00:01.500 --> 00:00:04.200), which violates the SRT specification.Change periods to commas on line 2:
00:00:01,500 --> 00:00:04,200.
Fix Unclosed Inline Tags:
Line 3 contains
<i>Global Release event!.Add the closing tag
</i>:<i>Global Release event!</i>.
Save the file as
clean_subtitles.srt:Code snippet
clean_subtitles.srt1 00:00:01,500 --> 00:00:04,200 Welcome to the <i>Global Release event!</i> 2 00:00:04,200 --> 00:00:08,000 ¡Hola! ¿Cómo estás?
Step 3: Remediate the WebVTT Asset (broken_captions.vtt)
Open
broken_captions.vttin VS Code.Fix WebVTT Millisecond Delimiters:
Line 4 uses commas (
00:00:01,500 --> 00:00:04,200). WebVTT strictly requires periods.Change commas to periods:
00:00:01.500 --> 00:00:04.200.
Fix Missing Cue Boundary Separators:
Notice line 6 (
cue-02) directly follows line 5 without an empty line separating them. Media engines will fail to parsecue-02.Insert a blank line after line 5.
Save the file as
clean_captions.vtt:Code snippet
clean_captions.vttWEBVTT cue-01 00:00:01.500 --> 00:00:04.200 <v Narrator>Welcome back to the dashboard! cue-02 00:00:04.500 --> 00:00:08.000 <v Alex>¡Bienvenido a la plataforma!
Step 4: Validate Subtitle Assets with Regex Search in VS Code
Use Regular Expressions in VS Code to ensure no timestamp delimiter errors remain across your workspace:
Open the Find in Files search pane (
Cmd + Shift + F/Ctrl + Shift + F).Enable the Use Regular Expression option (
Alt + R/Option + R).Search for WebVTT timestamp errors (commas instead of periods):
\d{2}:\d{2}:\d{2}\,\d{3}Verify 0 matches found in
.vttfiles.Search for SRT timestamp errors (periods instead of commas):
\d{2}:\d{2}:\d{2}\.\d{3}Verify 0 matches found in
.srtfiles.
Self-Verification Checklist
Check your subtitle assets against these production specifications:
[ ]
clean_subtitles.srtuses commas for millisecond delimiters and has balanced HTML inline tags (<i>...</i>).[ ]
clean_captions.vttbegins with theWEBVTTheader line and uses periods for millisecond delimiters.[ ] Every cue block in both files is separated by at least one empty line.
[ ] Workspace Regex search returns 0 timestamp syntax errors.
Ready to move on?
Mark this lesson complete when you’re ready.