Skip to content

Conversation

@DhanushVarma-2
Copy link
Contributor

@DhanushVarma-2 DhanushVarma-2 commented Dec 15, 2025

In raising this pull request, I confirm the following (please check boxes):

  • I have read and understood the contributors guide.
  • I have checked that another pull request for this purpose does not exist.
  • I have considered, and confirmed that this submission will be valuable to others.
  • I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  • I give this submission freely, and claim no ownership to its content.
  • I have mentioned this change in the changelog.

My familiarity with the project is as follows (check one):

  • I have never used CCExtractor.
  • I have used CCExtractor just a couple of times.
  • I absolutely love CCExtractor, but have not contributed previously.
  • I am an active contributor to CCExtractor.

This PR fixes inaccurate SCC timing by accounting for the 2-bytes-per-frame
EIA-608 transmission limit (29.97 fps).

Changes:

  • Compute SCC byte cost per caption
  • Pre-roll SCC transmission so EOC lands at display time
  • Prevent overlapping SCC transmissions between captions

This makes SCC output compliant with broadcast rules and fixes #1221.

@DhanushVarma-2 DhanushVarma-2 force-pushed the fix/scc-accurate-timing branch 2 times, most recently from e242dbc to 703c579 Compare December 15, 2025 11:39
@ccextractor-bot
Copy link
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 b728dda...:
Report Name Tests Passed
Broken 4/13
CEA-708 13/14
DVB 6/7
DVD 0/3
DVR-MS 2/2
General 5/27
Hardsubx 0/1
Hauppage 0/3
MP4 3/3
NoCC 10/10
Options 72/86
Teletext 20/21
WTV 0/13
XDS 25/34

Your PR breaks these cases:

NOTE: The following tests have been failing on the master branch as well as the PR:

Congratulations: Merging this PR would fix the following tests:


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
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 b728dda...:
Report Name Tests Passed
Broken 4/13
CEA-708 13/14
DVB 6/7
DVD 0/3
DVR-MS 2/2
General 5/27
Hardsubx 0/1
Hauppage 0/3
MP4 3/3
NoCC 10/10
Options 72/86
Teletext 21/21
WTV 0/13
XDS 25/34

Your PR breaks these cases:

NOTE: The following tests have been failing on the master branch as well as the PR:

Congratulations: Merging this PR would fix the following tests:

  • ccextractor --autoprogram --out=srt --latin1 f1422b8bfe..., Last passed: Never
  • ccextractor --datapid 5603 --autoprogram --out=srt --latin1 --teletext 85c7fc1ad7..., Last passed: Never
  • ccextractor --out=txt c83f765c66..., Last passed: Never
  • ccextractor --out=spupng c83f765c66..., Last passed: Never
  • ccextractor --unixts 5 --out=txt c83f765c66..., Last passed: Never
  • ccextractor --out=txt --datets c83f765c66..., Last passed: Never
  • ccextractor --out=txt --sects c83f765c66..., Last passed: Never
  • ccextractor --out=txt --lf c83f765c66..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 c0d2fba8c0..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 006fdc391a..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 e92a1d4d2a..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 7e4ebf7fd7..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 9256a60e4b..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 27d7a43dd6..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 297a44921a..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 efbe129086..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 eae0077731..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 e2e2b501e0..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 c6407fb294..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --datets dcada745de..., Last passed: Never
  • ccextractor --autoprogram --out=srt --latin1 --tpage 398 5d5838bde9..., Last passed: Never
  • ccextractor --autoprogram --out=srt --latin1 --teletext --tpage 398 3b276ad8bf..., Last passed: Never

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.

Copy link
Contributor

@cfsmp3 cfsmp3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this timing fix! I did a deep review with actual testing.

The Good

The byte budgeting calculation is correct - you're correctly counting:

  • Control codes (RCL, ENM, EOC = 6 bytes)
  • Text bytes per row
  • Padding to even bytes
  • Frame duration at 29.97fps

The collision detection logic also looks correct.

Critical Issue: Timing Never Applied

However, the calculated tx_start_ms is never actually used to modify the SCC output. After the calculation block:

encoder->last_scc_tx_end_ms = tx_start_ms + tx_duration_ms;
// tx_start_ms is never used after this line!

The rest of the function still uses time_show.time_in_ms for all print_scc_time() calls. I verified this by:

  1. Building both master and this PR
  2. Running them on the same test file
  3. Comparing output: byte-for-byte identical

Example from test file:

  • First caption: 92 bytes, needs 46 frames (~1535ms) to transmit
  • Display time: 00:00:10:02 (~10066ms)
  • For broadcast compliance should start at: ~00:00:08:17
  • Actual SCC output: Still uses 00:00:10:02

What Needs to Change

You need to use tx_start_ms for the actual timestamp output, something like:

struct ccx_boundary_time tx_start_time = get_time(tx_start_ms);
// Use tx_start_time instead of time_show for print_scc_time()

Also

  • Please remove the unrelated formatting changes in ccx_decoders_isdb.c
  • Run clang-format on the modified files

Happy to review again once the timing is actually applied to the output!

- Add last_scc_tx_end_ms field to encoder_ctx
- Initialize it to -1 in init_encoder
- Use encoder->last_scc_tx_end_ms instead of static variable
- This ensures SCC timing only affects SCC output format
- Other formats (SRT, TXT, TTXT) are unaffected

Fixes CCExtractor#1221
@DhanushVarma-2 DhanushVarma-2 force-pushed the fix/scc-accurate-timing branch from 74c98ec to 399b939 Compare December 17, 2025 19:36
The transmission end should be the original display time (when caption
becomes visible), not the pre-rolled transmission start time.
@cfsmp3
Copy link
Contributor

cfsmp3 commented Dec 20, 2025

PR Review - Testing Results

I tested this PR against the sample files from issue #1120 (Broadcast Source.ts) and compared the output between master, this PR, and the reference SCC file generated by scc_tools.

Issue Found

This PR doesn't fix the reported issue #1221 because it modifies the wrong code path:

Test Results

File First Caption Timestamp
Reference (scc_tools) 00:00:04:22 (load) → 00:00:06:10 (display)
Master .scc 00:00:06:12
PR #1827 .scc 00:00:06:12

The main SCC output is identical between master and this PR - no timing improvement for 608 captions.

What This PR Actually Does

  • Adds byte budgeting and pre-roll timing to 708 service SCC files (.p1.svc01.scc)
  • Creates 708 service-specific SCC files that master doesn't generate
  • The timing logic itself looks correct for the 708 path

Requested Changes

To fix issue #1221, the same byte budgeting and pre-roll timing logic needs to be applied to the EIA-608 SCC output path. This would likely involve changes to:

  • src/lib_ccx/ccx_encoders_scc.c or related encoder files

The 708 timing changes in this PR may be independently useful, but they don't solve the reported 608 timing problem. Consider either:

  1. Extending this PR to also fix 608 SCC timing
  2. Splitting this into two separate PRs (one for 708, one for 608)

Dhanush Varma added 2 commits December 22, 2025 23:41
- Add byte budgeting calculation for 608 captions
- Pre-roll transmission start time by transmission duration
- Prevent collision with previous caption transmissions
- Track transmission end time for collision detection

This applies the same timing logic from the 708 path to fix
issue CCExtractor#1221 for EIA-608 SCC output.
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.

[BUG] SCC caption loading times are inaccurate

3 participants