Repository navigation
[FIX] Use packet timestamps for tx3g subtitle times on the FFmpeg MP4 path - #2378
Merged
cfsmp3 merged 1 commit intoOct 18, 2026
Merged
Conversation
… path The tx3g start/end times came from the global timing pointer, which every track shares: it can already be past the subtitle being processed, and on the very first subtitle it is still at zero. Result on a tx3g MP4 with subtitles at 1s-3s and 4s-6s: 1: 00:00:00,000 --> 00:00:03,999 2: 00:00:04,000 --> 00:00:09,959 Take the times from the packet timestamps directly instead: the start is the packet PTS in milliseconds and the end is the sample duration when present, with the previous behaviour as fallback (next subtitle's start, or the usual 5 second default for the last sample). The timing pointer is still set from the explicit start, it is just no longer used to derive the output times. Output now matches the GPAC path exactly: 1: 00:00:01,000 --> 00:00:02,999 2: 00:00:04,000 --> 00:00:05,999
Contributor
Author
|
CI note: the two red jobs are infra-only — the Windows build failed in 21s because Chocolatey returned a 503 fetching the |
5 of 7 tasks
5 of 7 tasks
cfsmp3
added a commit
that referenced
this pull request
Oct 18, 2026
#2378 derives the end of a tx3g cue as start_ms + duration * 1000 / timescale. Both terms are truncated separately, so the end can land 1 ms before the GPAC path's, which converts pts + duration at once. On a real m4v with 797 cues, 99 ended 1 ms early (e.g. timescale 600, pts 135725, duration 2725: 230749 instead of 230750).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2198.
Problem
On current master (97a0d24) the FFmpeg MP4 demuxer (
ENABLE_FFMPEG_MP4/cmake -DWITH_FFMPEG=ON) extracts tx3g subtitles with wrong times. A tx3g MP4with subtitles at 1s-3s and 4s-6s produces:
The first subtitle starts at zero and ends at the next subtitle's start; the
last subtitle ends at the end of the video. The GPAC path extracts the same
file correctly.
Root cause
ccx_mp4_process_tx3g_packetderivedsub->start_timefromdec_ctx->timing->fts_now, andccx_mp4_flush_tx3gderivedsub->end_timethe same way. That timing pointer is shared by every track: when a tx3g packet
comes around it can already point past that subtitle (packets from all tracks
are interleaved), and for the very first subtitle the first
set_fts()callleaves it at zero. Empty lead-in tx3g samples (16-bit length 0) also move the
pointer without producing a subtitle.
Fix
Take the times from the packet timestamps directly:
previous behaviour applies (end at the next subtitle's start, or the usual
5 second default for the last sample).
The bridge functions now take/return explicit millisecond values, the same
convention the VobSub bridge (
ccx_mp4_vobsub_process) already uses. Thetiming pointer is still set from the explicit start, it is just no longer used
to derive the output times.
Verification
Same file after the fix — and
diff-identical to the GPAC path output acrosssubtitle layouts (plain, gapped, overlapping, contiguous) and output formats
(srt, ass, webvtt):
Sample — small and deterministic; generate with:
Then:
(The GPAC path and the default build are not touched by this change; happy to
attach the generated 14 KB sample file if that helps.)