Skip to content

fix: correctly initialize frame type for tx3g and mov_text subtitles - #2321

Open
shubhrai23 wants to merge 1 commit into
CCExtractor:masterfrom
shubhrai23:fix/issue-2105-tx3g-timestamps
Open

fix: correctly initialize frame type for tx3g and mov_text subtitles#2321
shubhrai23 wants to merge 1 commit into
CCExtractor:masterfrom
shubhrai23:fix/issue-2105-tx3g-timestamps

Conversation

@shubhrai23

Copy link
Copy Markdown

Resolves #2105

What changed: Added \GF_ISOM_MEDIA_TEXT\ and \GF_ISOM_MEDIA_SUBT\ alongside \GF_ISOM_MEDIA_CLOSED_CAPTION\ to properly initialize the picture coding type to \CCX_FRAME_TYPE_I_FRAME\ for subtitle tracks in \mp4.c.

Why: Because \mov_text\ / \ x3g\ subtitles are parsed as text/subt media types rather than closed captions, they previously bypassed the I-frame initialization. Without this, \min_pts\ is never set from the first sample, causing all subsequent timestamps calculated via \set_fts()\ to be offset or incorrectly computed.

Copilot AI lite review requested due to automatic review settings August 12, 2026 21:23

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

This PR fixes MP4 subtitle timestamp initialization by ensuring subtitle-only tracks (including mov_text/tx3g) get an I-frame picture type so set_fts() can set min_pts from the first sample.

Changes:

  • Expand the media-type check so GF_ISOM_MEDIA_TEXT and GF_ISOM_MEDIA_SUBT tracks also force current_picture_coding_type = CCX_FRAME_TYPE_I_FRAME before calling set_fts().
  • Align MP4 subtitle handling with how tx3g tracks are already dispatched later in the same loop.

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

Comment thread src/lib_ccx/mp4.c
Comment on lines 1124 to +1128
// For caption-only tracks (c608/c708), set frame type to I-frame
// so that set_fts() will set min_pts from the first sample.
// Without video frames, frame type would stay Unknown and
// min_pts would never be set, causing broken timestamps.
if (type == GF_ISOM_MEDIA_CLOSED_CAPTION)
if (type == GF_ISOM_MEDIA_CLOSED_CAPTION || type == GF_ISOM_MEDIA_TEXT || type == GF_ISOM_MEDIA_SUBT)
Comment thread src/lib_ccx/mp4.c
// Without video frames, frame type would stay Unknown and
// min_pts would never be set, causing broken timestamps.
if (type == GF_ISOM_MEDIA_CLOSED_CAPTION)
if (type == GF_ISOM_MEDIA_CLOSED_CAPTION || type == GF_ISOM_MEDIA_TEXT || type == GF_ISOM_MEDIA_SUBT)
@ccextractor-bot

Copy link
Copy Markdown
Collaborator
CCExtractor CI platform finished running the test files on windows. Below is a summary of the test results, when compared to test for commit c328108...:
Report Name Tests Passed
Broken 9/13
CEA-708 2/14
DVB 0/7
DVD 3/3
DVR-MS 2/2
General 22/27
Hardsubx 1/1
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 69/86
Teletext 0/21
WTV 12/13
XDS 31/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.

@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 6077cf5...:
Report Name Tests Passed
Broken 9/13
CEA-708 2/14
DVB 0/7
DVD 3/3
DVR-MS 2/2
General 22/27
Hardsubx 1/1
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 69/86
Teletext 0/21
WTV 12/13
XDS 31/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.

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.

3 participants