From 94a43928ad43414ea130900996a54b03965b1bfa Mon Sep 17 00:00:00 2001 From: Carlos Fernandez Date: Sun, 21 Dec 2025 12:34:05 +0100 Subject: [PATCH] fix(timing): Fix --goptime producing compressed timestamps (Test 163) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When using --goptime, timestamps were compressed to 00:00:01-02 instead of actual GOP times (17:56:40-47). This was caused by conflicts between: - GOP timing set from GOP headers (wall-clock time, e.g., 17:56:40) - PES PTS timing (stream-relative time, e.g., 00:00:02) The sync detection saw these as 64,598-second "jumps" and kept resetting timing, corrupting the output. Fixes: 1. Guard video PES timing in general_loop.c - skip set_current_pts and set_fts when use_gop_as_pts == 1 to prevent PES PTS from overwriting GOP-based timing 2. Disable sync check in ccextractor.c when use_gop_as_pts == 1 since GOP time and PES PTS are in different time bases and sync detection is meaningless Test results: - Before: 00:00:01,231 --> 00:00:01,729 - After: 17:56:41,319 --> 17:56:43,084 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/ccextractor.c | 5 +++++ src/lib_ccx/general_loop.c | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/ccextractor.c b/src/ccextractor.c index da9d5c36..71378849 100644 --- a/src/ccextractor.c +++ b/src/ccextractor.c @@ -186,6 +186,11 @@ int start_ccx() ccx_options.use_gop_as_pts = 0; if (ccx_options.ignore_pts_jumps) ccx_common_timing_settings.disable_sync_check = 1; + // When using GOP timing (--goptime), disable sync check because + // GOP time (wall-clock) and PES PTS (stream-relative) are in + // different time bases and will always appear as huge jumps. + if (ccx_options.use_gop_as_pts == 1) + ccx_common_timing_settings.disable_sync_check = 1; mprint("\rAnalyzing data in general mode\n"); tmp = general_loop(ctx); if (!ret) diff --git a/src/lib_ccx/general_loop.c b/src/lib_ccx/general_loop.c index 65cb77f2..807d1a5c 100644 --- a/src/lib_ccx/general_loop.c +++ b/src/lib_ccx/general_loop.c @@ -1018,8 +1018,15 @@ int process_non_multiprogram_general_loop(struct lib_ccx_ctx *ctx, pts = data_node_video->pts; } - set_current_pts(dec_ctx_video->timing, pts); - set_fts(dec_ctx_video->timing); + // When using GOP timing (--goptime), timing is set from GOP headers + // in gop_header(), not from PES PTS. Skip PTS-based timing here + // to avoid conflicts between GOP time (absolute time-of-day) and + // PTS (relative stream time) that cause sync detection failures. + if (ccx_options.use_gop_as_pts != 1) + { + set_current_pts(dec_ctx_video->timing, pts); + set_fts(dec_ctx_video->timing); + } } size_t got = process_m2v(*enc_ctx, dec_ctx_video, data_node_video->buffer, data_node_video->len, dec_sub_video); if (got > 0)