Skip to content

Commit 94a4392

Browse files
cfsmp3claude
andcommitted
fix(timing): Fix --goptime producing compressed timestamps (Test 163)
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 <[email protected]>
1 parent 25d68b7 commit 94a4392

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/ccextractor.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,11 @@ int start_ccx()
186186
ccx_options.use_gop_as_pts = 0;
187187
if (ccx_options.ignore_pts_jumps)
188188
ccx_common_timing_settings.disable_sync_check = 1;
189+
// When using GOP timing (--goptime), disable sync check because
190+
// GOP time (wall-clock) and PES PTS (stream-relative) are in
191+
// different time bases and will always appear as huge jumps.
192+
if (ccx_options.use_gop_as_pts == 1)
193+
ccx_common_timing_settings.disable_sync_check = 1;
189194
mprint("\rAnalyzing data in general mode\n");
190195
tmp = general_loop(ctx);
191196
if (!ret)

src/lib_ccx/general_loop.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,8 +1018,15 @@ int process_non_multiprogram_general_loop(struct lib_ccx_ctx *ctx,
10181018
pts = data_node_video->pts;
10191019
}
10201020

1021-
set_current_pts(dec_ctx_video->timing, pts);
1022-
set_fts(dec_ctx_video->timing);
1021+
// When using GOP timing (--goptime), timing is set from GOP headers
1022+
// in gop_header(), not from PES PTS. Skip PTS-based timing here
1023+
// to avoid conflicts between GOP time (absolute time-of-day) and
1024+
// PTS (relative stream time) that cause sync detection failures.
1025+
if (ccx_options.use_gop_as_pts != 1)
1026+
{
1027+
set_current_pts(dec_ctx_video->timing, pts);
1028+
set_fts(dec_ctx_video->timing);
1029+
}
10231030
}
10241031
size_t got = process_m2v(*enc_ctx, dec_ctx_video, data_node_video->buffer, data_node_video->len, dec_sub_video);
10251032
if (got > 0)

0 commit comments

Comments
 (0)