Skip to content

[FIX] Compute FFmpeg tx3g end time in one step - #2387

Merged
cfsmp3 merged 1 commit into
masterfrom
fix/ffmpeg-tx3g-end-rounding
Oct 18, 2026
Merged

cfsmp3 merged 1 commit into
masterfrom
fix/ffmpeg-tx3g-end-rounding

Conversation

@cfsmp3

@cfsmp3 cfsmp3 commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

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.

Repro instructions:

Build with -DWITH_FFMPEG=ON and extract the tx3g track of sample 162 on the sample platform (Yomeddine_1080p_HD, m4v, 797 cues) with --out=srt; compare against the default (GPAC) build.


Follow-up to #2378. It derives a cue's end as start_ms + pkt.duration * 1000 / timescale; both terms are truncated separately, so the end can land 1 ms before the GPAC path, which converts pts + duration in one step. On sample 162, 99 of 797 cues ended 1 ms early (e.g. timescale 600, pts 135725, duration 2725 → 230749 instead of 230750). This computes (pts + pkt.duration) * 1000 / timescale.

Verified: on the FFmpeg build, --out=srt output is now byte-identical to the GPAC build on sample 162 and on five synthetic tx3g files (video + subtitle, subtitle-only, text handler, #2378's own sample, and one with a cue at 0 plus contiguous and overlapping cues). cargo fmt --check and cargo clippy --features enable_mp4_ffmpeg -- -D warnings are clean.

#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).
@cfsmp3
cfsmp3 merged commit fb5c160 into master Oct 18, 2026
47 of 49 checks passed
@cfsmp3
cfsmp3 deleted the fix/ffmpeg-tx3g-end-rounding branch October 18, 2026 01:57
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.

1 participant