Skip to content

[Backport][TTML] Fix clock-time fractional seconds parsing - #2126

Merged
CastagnaIT merged 1 commit into
xbmc:Omegafrom
mediaminister:ttmlomega
Oct 15, 2026
Merged

CastagnaIT merged 1 commit into
xbmc:Omegafrom
mediaminister:ttmlomega

Conversation

@mediaminister

@mediaminister mediaminister commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes parsing of clock-time expressions with fractional seconds (hh:mm:ss.fraction) in TTML2SRT::GetTime. The digits after the decimal point were added to the timestamp as a raw integer, without taking their count or m_timescale into account. The fraction is now parsed as digits, padded to 9 digits (nanosecond precision, longer fractions are truncated) and scaled by m_timescale. Plain hh:mm:ss without a fraction is handled by its own branch.

backport PR #2125

Motivation and context

The TTML2 clock-time grammar allows hh:mm:ss.fraction, where the fraction is a fraction of a second with any number of digits. The old code treated the digits as an integer count of timescale units:

  • 00:00:01.5 gave 1 s + 5 units instead of 1.5 s
  • .05 and .5 both parsed to 5, so leading zeros were lost
  • the result was only correct by accident for exactly 3 digits at a timescale of 1000

This resulted in wrong cue timings for TTML subtitles with fractional seconds, whenever the fraction did not have exactly 3 digits or the timescale was not 1000.

How has this been tested?

Checked the parsing by hand with m_timescale = 1000 and m_timescale = 90000:

Input m_timescale Before After
00:00:01.5 1000 1005 1500
00:00:01.05 1000 1005 1050
00:00:01.050 1000 1050 1050
00:00:01.5 90000 90005 135000
00:00:01 1000 1000 1000

Tested with real TTML Dash in VRT MAX Add-on: https://github.com/add-ons/plugin.video.vrt.nu

Screenshots (if appropriate):

Types of change

  • Bug fix (non-breaking change which fixes an issue)
  • Clean up (non-breaking change which removes non-working, unmaintained functionality)
  • Improvement (non-breaking change which improves existing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that will cause existing functionality to change)
  • Cosmetic change (non-breaking change that doesn't touch code)
  • None of the above (please explain below)

Checklist:

  • I have read the Contributing document
  • My code follows the Code Guidelines of this project
  • My change requires a change to the Wiki documentation
  • I have updated the documentation accordingly

Summary by CodeRabbit

  • Bug Fixes
    • Corrected subtitle timing for TTML clock times with fractional seconds, including fractions with fewer than nine digits.

@coderabbitai

coderabbitai Bot commented Oct 14, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f3bb7995-43a0-445c-b08a-88a1d266a1bf

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@CastagnaIT
CastagnaIT merged commit 42a2173 into xbmc:Omega Oct 15, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants