Skip to content

OCTO-11531 - #392

Merged
OlteanuRares merged 1 commit into
mainfrom
OCTO-11531
Jul 23, 2026
Merged

OCTO-11531 #392
OlteanuRares merged 1 commit into
mainfrom
OCTO-11531

Conversation

@OlteanuRares

Copy link
Copy Markdown
Contributor

Summary

  • Hardened detect()** — uses regex <tt[\s>] + </tt> instead of naive "</tt>" in content, eliminating false positives on non-TTML content that happens to contain the closing tag.
  • Tick time support** — implements the TTML tick metric (Nt) using ttp:tickRate from <tt>, defaulting to frameRate × subFrameRate per TTML spec §8.2.12 (previously raised NotImplementedError).
  • Dynamic frame rate — reads ttp:frameRate and ttp:frameRateMultiplier from <tt> instead of hardcoding 30fps. Raises CaptionReadSyntaxError on malformed or zero values. Incorporates the approach from PR Dynamic FPS selection on DFXPReader #292 by @Marcelpv96.

Backwards compatibility

Default values (frameRate=30, multiplier="1 1", subFrameRate=1, tickRate=30) preserve existing behavior for documents without these attributes. The only behavioral change is that tick timestamps (Nt) now parse successfully instead of raising NotImplementedError.

Test plan

  • Custom framerate with multiplier (24 × 1000/1001) — verify clock-time frame conversion
  • Custom tickRate — verify offset-time tick conversion
  • Framerate without multiplier defaults to "1 1"
  • Default tickRate derived from subFrameRate
  • Invalid multiplier (single value) → CaptionReadSyntaxError
  • Invalid multiplier (zero denominator) → CaptionReadSyntaxError
  • Invalid tickRate (zero) → CaptionReadSyntaxError
  • detect() rejects content with only </tt> (no opening tag)
  • Unit timestamps with custom framerate/tickrate
  • Existing frame-timing test (30fps default) still passes
  • Full suite: 489 passed, 0 failures

    dynamic frame rate.

  - detect() now requires both <tt[\s>] and </tt> (regex) instead of
    naive substring check, eliminating false positives on non-TTML content.
  - Implement TTML tick metric (Nt): read ttp:tickRate from <tt>,
    default to frameRate × subFrameRate per spec §8.2.12.
  - Read ttp:frameRate and ttp:frameRateMultiplier from <tt> instead of
    hardcoding 30fps. Raise CaptionReadSyntaxError on malformed or zero
    values.
  - Add constants DFXP_DEFAULT_FRAMERATE, DFXP_DEFAULT_FRAMERATE_MULTIPLIER,
    DFXP_DEFAULT_SUBFRAMERATE, DFXP_DEFAULT_TICKRATE.

  Based on the dynamic framerate approach from PR #292 by Marcel Porta Vallés.

  Co-Authored-By: Marcel Porta Vallés <Marcelpv96@users.noreply.github.com>
@OlteanuRares
OlteanuRares requested a review from a team as a code owner July 23, 2026 11:42
@github-actions

Copy link
Copy Markdown

🟡 PR Compliance Review

Risk Level: MEDIUM

  • Compliance Issues: 0 (0 critical)
  • Regressions: 1

REVIEW REQUIRED - Address issues before merging

Full report available in workflow artifacts

@OlteanuRares
OlteanuRares merged commit b9fa2c8 into main Jul 23, 2026
4 checks passed
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.

4 participants