Skip to content

Fix 40ms gap in rolling teletext subtitles#2292

Open
alaotach wants to merge 1 commit into
CCExtractor:masterfrom
alaotach:fix-teletext-webvtt-gap
Open

Fix 40ms gap in rolling teletext subtitles#2292
alaotach wants to merge 1 commit into
CCExtractor:masterfrom
alaotach:fix-teletext-webvtt-gap

Conversation

@alaotach

@alaotach alaotach commented Jul 8, 2026

Copy link
Copy Markdown

[FIX] Remove 40ms hide timestamp contraction in telxcc causing rolling subtitle blink


In raising this pull request, I confirm the following (please check boxes):

Reason for this PR:

  • This PR adds new functionality.
  • This PR fixes a bug that I have personally experienced or that a real user has reported and for which a sample exists.
  • This PR is porting code from C to Rust.

Sanity check:

  • I have read and understood the contributors guide.
  • I have checked that another pull request for this purpose does not exist.
  • If the PR adds new functionality, I've added it to the changelog. If it's just a bug fix, I have NOT added it to the changelog.
  • I am NOT adding new C code unless it's to fix an existing, reproducible bug.

Fixes

Closes #2288

Problem

When converting DVB teletext subtitles to WebVTT, rolling/scrolling subtitles that update every ~40ms produce a visible blink or flash between cues in players such as Infuse.

The root cause is in src/lib_ccx/telxcc.c. The telxcc component hardcodes a 40ms contraction on every subtitle hide timestamp:

// it would be nice, if subtitle hides on previous video frame, so we contract 40 ms (1 frame @25 fps)
ctx->page_buffer.hide_timestamp = timestamp - 40;

This was originally intended to hide a subtitle one video frame early on 25fps content. However, the WebVTT exporter independently subtracts 1ms from end timestamps to prevent adjacent cues from sharing the same boundary timestamp. The two reductions combine, producing a ~41ms gap between consecutive rolling teletext cues.

For rolling teletext that updates every ~40ms, this gap is effectively the same duration as a full cue, so compliant players interpret it as the subtitle completely disappearing before the next one appears causing the blink.

Two additional problems with the original approach:

  • The 40ms figure is only correct for 25fps. It is already wrong for 24fps (41.7ms/frame) and 30fps (33ms/frame).
  • Frame-timing logic does not belong in the teletext parser layer; it belongs in a frame-aware encoder.

Fix

Remove the 40ms contraction in telxcc.c and let the WebVTT exporter's existing 1ms gap handle overlap prevention on its own. The 1ms gap is spec-compliant and imperceptible.

// We no longer contract 40ms here. The WebVTT exporter already subtracts 1ms
// to prevent adjacent cues from sharing a boundary timestamp, which is sufficient.
// The previous 40ms contraction (1 frame @ 25fps) caused a visible ~41ms blink gap
// in rolling teletext subtitles on spec-compliant players (e.g. Infuse).
// It was also incorrect for non-25fps content.
ctx->page_buffer.hide_timestamp = timestamp;

Repro Instructions

  1. Take any DVB teletext stream containing rolling/scrolling subtitles (sample attached in issue DVB_TELETEXT to WEBVTT rolling issue. #2288).
  2. Convert to WebVTT using CCExtractor:
    ccextractor input.ts -o output.vtt
    
  3. Open the output in a player that renders WebVTT strictly.
  4. Before fix: a visible ~40ms blink is present between each rolling cue update.
  5. After fix: subtitle rolls smoothly with no blink.

The gap is also directly visible in the raw WebVTT output consecutive cues have a ~40ms hole between the end of one timestamp and the start of the next instead of being contiguous.

@ccextractor-bot

Copy link
Copy Markdown
Collaborator
CCExtractor CI platform finished running the test files on linux. Below is a summary of the test results, when compared to test for commit 2feb09a...:
Report Name Tests Passed
Broken 0/13
CEA-708 1/14
DVB 0/7
DVD 0/3
DVR-MS 0/2
General 0/27
Hardsubx 1/1
Hauppage 0/3
MP4 0/3
NoCC 10/10
Options 0/86
Teletext 0/21
WTV 0/13
XDS 0/34

Your PR breaks these cases:

NOTE: The following tests have been failing on the master branch as well as the PR:


It seems that not all tests were passed completely. This is an indication that the output of some files is not as expected (but might be according to you).

Check the result page for more info.

@alaotach

alaotach commented Jul 8, 2026

Copy link
Copy Markdown
Author

the test failure is a CI infra 504 timeout, not related to the change so can any maintainer re-trigger the test

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.

DVB_TELETEXT to WEBVTT rolling issue.

2 participants