[PR #1971] [MERGED] [FEATURE] Add --scc-accurate-timing option for bandwidth-aware SCC output (fixes #1221) #2771

Open
opened 2026-01-29 17:23:49 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/CCExtractor/ccextractor/pull/1971
Author: @ujjwalr27
Created: 1/2/2026
Status: Merged
Merged: 1/3/2026
Merged by: @cfsmp3

Base: masterHead: scc-accurate-timing


📝 Commits (6)

  • 7166e48 Add --scc-accurate-timing option for bandwidth-aware SCC output (fixes #1120)
  • 946c585 Add --scc-accurate-timing option for bandwidth-aware SCC output (fixes #1120)
  • 317c66f Fix clang-format style issues
  • aaf937a Fix rustfmt style issues in lib_ccxr
  • 22d5d35 Fix SCC accurate timing: separate load/display timestamps, skip clear commands, pass YouTube validation
  • f40294c minor fix

📊 Changes

10 files changed (+270 additions, -15 deletions)

View changed files

📝 src/lib_ccx/ccx_common_option.c (+3 -2)
📝 src/lib_ccx/ccx_common_option.h (+2 -1)
📝 src/lib_ccx/ccx_encoders_common.c (+3 -0)
📝 src/lib_ccx/ccx_encoders_common.h (+8 -3)
📝 src/lib_ccx/ccx_encoders_scc.c (+234 -7)
📝 src/rust/lib_ccxr/src/common/options.rs (+4 -1)
📝 src/rust/src/args.rs (+7 -0)
📝 src/rust/src/common.rs (+3 -0)
📝 src/rust/src/parser.rs (+5 -0)
📝 windows/ccextractor.sln (+1 -1)

📄 Description

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.

Summary

This PR implements bandwidth-aware timing for SCC (Scenarist Closed Caption) output to ensure YouTube and broadcast compliance, addressing issue #1221.

Problem

SCC files generated by CCExtractor were being rejected by YouTube due to timing violations. The EIA-608 standard specifies a transmission bandwidth of 2 bytes per frame, but CCExtractor was not accounting for the time required to transmit captions before their display time, causing overlapping transmissions and compliance issues.

Solution

Added a new --scc-accurate-timing command-line option that implements:

  1. Byte counting: Calculates the exact byte size of each caption including control codes, preambles, mid-row codes, text, and padding
  2. Pre-roll calculation: Determines when caption transmission must start based on byte size and frame rate to ensure it completes before display time
  3. Collision detection & resolution: Detects overlapping caption transmissions and shifts captions forward to resolve conflicts
  4. Frame-perfect EOC timing: Ensures End-of-Caption codes are sent one frame before display time

Changes Made

C Code

  • ccx_common_option.h/c: Added scc_accurate_timing option (default: off)
  • ccx_encoders_common.h/c: Added timing state tracking (scc_last_transmission_end, scc_last_display_end)
  • [ccx_encoders_scc.c]: Implemented core timing logic:
    • [calculate_caption_bytes()]: Byte counting
    • [calculate_preroll_time()]: Pre-roll timing calculation
    • [resolve_collision()]: Collision detection and resolution
    • Modified [write_cc_buffer_as_scenarist()]: Integrated accurate timing when flag is enabled

Rust Code

  • [args.rs]: Added --scc-accurate-timing CLI argument
  • [parser.rs]: Added argument parsing logic
  • [options.rs]: Added field to Options struct
  • [common.rs]: Updated C/Rust FFI bindings

Usage

ccextractor input.ts -out=scc --scc-accurate-timing -o output.scc

---

<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
## 📋 Pull Request Information **Original PR:** https://github.com/CCExtractor/ccextractor/pull/1971 **Author:** [@ujjwalr27](https://github.com/ujjwalr27) **Created:** 1/2/2026 **Status:** ✅ Merged **Merged:** 1/3/2026 **Merged by:** [@cfsmp3](https://github.com/cfsmp3) **Base:** `master` ← **Head:** `scc-accurate-timing` --- ### 📝 Commits (6) - [`7166e48`](https://github.com/CCExtractor/ccextractor/commit/7166e48698af57f1fe12ba43a330d1476283e8de) Add --scc-accurate-timing option for bandwidth-aware SCC output (fixes #1120) - [`946c585`](https://github.com/CCExtractor/ccextractor/commit/946c5859d4eb76399935eb1f7a425deed4fdee08) Add --scc-accurate-timing option for bandwidth-aware SCC output (fixes #1120) - [`317c66f`](https://github.com/CCExtractor/ccextractor/commit/317c66f14ea2ece2ec0c8139b1ed25758278e6d5) Fix clang-format style issues - [`aaf937a`](https://github.com/CCExtractor/ccextractor/commit/aaf937a135f5505c849084de0c872d6c15065686) Fix rustfmt style issues in lib_ccxr - [`22d5d35`](https://github.com/CCExtractor/ccextractor/commit/22d5d3515830360a3513b471fdabe8a384f1f451) Fix SCC accurate timing: separate load/display timestamps, skip clear commands, pass YouTube validation - [`f40294c`](https://github.com/CCExtractor/ccextractor/commit/f40294cc5c32e3764feea318bc39d255d6394bfb) minor fix ### 📊 Changes **10 files changed** (+270 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `src/lib_ccx/ccx_common_option.c` (+3 -2) 📝 `src/lib_ccx/ccx_common_option.h` (+2 -1) 📝 `src/lib_ccx/ccx_encoders_common.c` (+3 -0) 📝 `src/lib_ccx/ccx_encoders_common.h` (+8 -3) 📝 `src/lib_ccx/ccx_encoders_scc.c` (+234 -7) 📝 `src/rust/lib_ccxr/src/common/options.rs` (+4 -1) 📝 `src/rust/src/args.rs` (+7 -0) 📝 `src/rust/src/common.rs` (+3 -0) 📝 `src/rust/src/parser.rs` (+5 -0) 📝 `windows/ccextractor.sln` (+1 -1) </details> ### 📄 Description **In raising this pull request, I confirm the following (please check boxes):** - [x] I have read and understood the [contributors guide](https://github.com/CCExtractor/ccextractor/blob/master/.github/CONTRIBUTING.md). - [x] I have checked that another pull request for this purpose does not exist. - [x] I have considered, and confirmed that this submission will be valuable to others. - [x] I accept that this submission may not be used, and the pull request closed at the will of the maintainer. - [x] I give this submission freely, and claim no ownership to its content. - [x] I have mentioned this change in the [changelog](https://github.com/CCExtractor/ccextractor/blob/master/docs/CHANGES.TXT). **My familiarity with the project is as follows (check one):** - [ ] I have never used CCExtractor. - [x] 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. --- ## Summary This PR implements bandwidth-aware timing for SCC (Scenarist Closed Caption) output to ensure YouTube and broadcast compliance, addressing issue #1221. ## Problem SCC files generated by CCExtractor were being rejected by YouTube due to timing violations. The EIA-608 standard specifies a transmission bandwidth of 2 bytes per frame, but CCExtractor was not accounting for the time required to transmit captions before their display time, causing overlapping transmissions and compliance issues. ## Solution Added a new `--scc-accurate-timing` command-line option that implements: 1. **Byte counting**: Calculates the exact byte size of each caption including control codes, preambles, mid-row codes, text, and padding 2. **Pre-roll calculation**: Determines when caption transmission must start based on byte size and frame rate to ensure it completes before display time 3. **Collision detection & resolution**: Detects overlapping caption transmissions and shifts captions forward to resolve conflicts 4. **Frame-perfect EOC timing**: Ensures End-of-Caption codes are sent one frame before display time ## Changes Made ### C Code - `ccx_common_option.h/c`: Added `scc_accurate_timing` option (default: off) - `ccx_encoders_common.h/c`: Added timing state tracking (`scc_last_transmission_end`, `scc_last_display_end`) - [ccx_encoders_scc.c]: Implemented core timing logic: - [calculate_caption_bytes()]: Byte counting - [calculate_preroll_time()]: Pre-roll timing calculation - [resolve_collision()]: Collision detection and resolution - Modified [write_cc_buffer_as_scenarist()]: Integrated accurate timing when flag is enabled ### Rust Code - [args.rs]: Added `--scc-accurate-timing` CLI argument - [parser.rs]: Added argument parsing logic - [options.rs]: Added field to Options struct - [common.rs]: Updated C/Rust FFI bindings ## Usage ```bash ccextractor input.ts -out=scc --scc-accurate-timing -o output.scc --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 17:23:49 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#2771