Skip to content

Fix crash on VTT timestamps at or past 24:00:00 - #9

Open
abhishekKokadwar wants to merge 1 commit into
RedHenLab:mainfrom
abhishekKokadwar:fix/vtt-timestamp-24h-overflow
Open

abhishekKokadwar wants to merge 1 commit into
RedHenLab:mainfrom
abhishekKokadwar:fix/vtt-timestamp-24h-overflow

Conversation

@abhishekKokadwar

Copy link
Copy Markdown

Bug

english/vtt_auto_to_conll-u.py computes each token's end timestamp with:

endtime_iso = datetime(2000, 1, 1, int(match1.group(2)), int(match1.group(3)), int(match1.group(4)), int(match1.group(5))*1000)

datetime() raises ValueError: hour must be in 0..23 whenever the VTT timestamp's hour is 24 or higher. This is a real case for long-form YouTube auto-captions (multi-hour streams, lectures, etc.), where cue timestamps like 24:xx:xx.xxx or higher are valid. Since convert_vtt_to_conll-u.sh loops over every *en.vtt file in a corpus directory, a single long file crashes that iteration of the pipeline with an unhandled exception.

Fix

Replaced the datetime-based +10ms calculation with plain integer arithmetic in milliseconds (add_10ms()), which has no upper bound on the hour component. Behavior for all timestamps under 24 hours is unchanged.

Testing

Added english/test_vtt_auto_to_conll_u.py, a small standalone self-check (no external deps, since the main script requires somajo which isn't installed outside the pipeline's HPC environment). It verifies normal rollover cases plus the regression case (23:59:59.995 -> 24:00:00.005) that used to crash.

$ python test_vtt_auto_to_conll_u.py
all tests passed

I'm a prospective GSoC 2027 contributor exploring this pipeline — happy to help with anything else that would be useful here.

datetime(2000, 1, 1, hour, ...) raises ValueError when hour >= 24, which
happens for long-form YouTube auto-captions (multi-hour streams/lectures)
that use timestamps like 24:xx:xx or higher. Replaced the datetime-based
+10ms calculation with plain integer arithmetic on total milliseconds,
which has no upper bound on hours.
Copilot AI lite review requested due to automatic review settings September 1, 2026 11:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a crash in the English VTT→CoNLL-U conversion script when processing long-form WebVTT cues whose timestamps reach or exceed 24:00:00, ensuring the pipeline can continue over large corpora without aborting on multi-hour caption files.

Changes:

  • Replaced datetime/timedelta timestamp math with an unbounded millisecond arithmetic helper (add_10ms()).
  • Updated end-time computation to use add_10ms() for cue end timestamps.
  • Added a small standalone self-check script to validate rollover and the >=24h regression case.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
english/vtt_auto_to_conll-u.py Removes datetime-based time arithmetic and uses add_10ms() to avoid hour=24+ crashes.
english/test_vtt_auto_to_conll_u.py Adds a lightweight, dependency-free self-check for the new timestamp rollover logic.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +5 to +7
# Plain seconds arithmetic instead of datetime() -- datetime's hour field
# is capped at 23, but long VTT files (multi-hour streams/lectures) can
# have timestamps at or past 24:00:00.
Comment on lines +9 to +13
def add_10ms(timestamp):
h, m, s_ms = timestamp.split(":")
s, ms = s_ms.split(".")
total_ms = ((int(h) * 3600 + int(m) * 60 + int(s)) * 1000 + int(ms)) + 10
h, rem_ms = divmod(total_ms, 3600000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants