[PR #1859] [MERGED] fix(mcc): Add MCC output support for raw caption files #2628

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

📋 Pull Request Information

Original PR: https://github.com/CCExtractor/ccextractor/pull/1859
Author: @cfsmp3
Created: 12/20/2025
Status: Merged
Merged: 12/20/2025
Merged by: @cfsmp3

Base: masterHead: fix/issue-1542-mcc-output-from-raw


📝 Commits (1)

  • d0d46fc fix(mcc): Add MCC output support for raw caption files

📊 Changes

1 file changed (+65 additions, -3 deletions)

View changed files

📝 src/lib_ccx/general_loop.c (+65 -3)

📄 Description

Summary

Fixes #1542 - MCC output now works with raw caption input files.

Previously, when using -out=mcc with raw input files (-in=raw), CCExtractor would print "Output format not supported" repeatedly and produce no output. This was because the raw file processing path decoded CEA-608 data to text, but MCC format requires raw cc_data bytes wrapped in CDP (Caption Distribution Packet) format.

Changes

  • Added process_raw_for_mcc() helper function in general_loop.c that:

    • Converts 2-byte raw pairs to 3-byte cc_data format (marker + 2 data bytes)
    • Wraps each CC pair in CDP format via mcc_encode_cc_data()
    • Maintains proper timing at 29.97fps
    • Skips broadcast headers (0xff 0xff)
  • Modified raw_loop() to detect MCC output format and use the new code path instead of the normal decoder path

Test plan

Test 1: Basic raw file to MCC conversion

# Before fix:
$ ./linux/ccextractor --in=raw --out=mcc /tmp/test113_raw.raw -o /tmp/test.mcc
# Output: "Output format not supported" (123 times), exit code 10, empty file

# After fix:
$ ./linux/ccextractor --in=raw --out=mcc /tmp/test113_raw.raw -o /tmp/test.mcc
# Output: Success, 238KB MCC file with 5316 lines

Test 2: MCC file content verification

$ head -50 /tmp/test.mcc | tail -10
UUID=76931FAC-9DAB-42B3-AC24-8B87D6AE33F9
Creation Program=CCExtractor
Creation Date=Saturday, December 20, 2025
Creation Time=11:52:38
Time Code Rate=30

00:00:00:00	T0FS0F4F43ZZ72E104808074ZZDC
00:00:00:01	T0FS0F4F43Z0172E104808074Z01DE
00:00:00:02	T0FS0F4F43Z0272E104808074Z02E0

Test 3: Timing progression validation

$ tail -5 /tmp/test.mcc
00:02:55:15	T0FS0F4F43149172E104808074149126
00:02:55:16	T0FS0F4F43149272E104808074149228
00:02:55:17	T0FS0F4F43149372E10480807414932A
00:02:55:18	T0FS0F4F43149472E10480807414942C
00:02:55:19	T0FS0F4F43149572E10480807414952E

Timing correctly progresses from 00:00:00:00 to 00:02:55:19 (matching Max PTS)

Test 4: Caption data verification

The MCC output contains actual CEA-608 control codes and text:

# Around 5 seconds where captions start:
00:00:05:09	T0FS0F4F43Z9F72E104942674Z9FD4   # 9426 = roll-up command
00:00:05:10	T0FS0F4F43ZA072E10494AD74ZA05D   # 94AD = positioning
00:00:05:13	T0FS0F4F43ZA372E1045BC174ZA33E   # 5BC1 = "[A" text
00:00:05:14	T0FS0F4F43ZA472E1044C4C74ZA4BC   # 4C4C = "LL" text

Matches raw file hex dump: 9426 94ad 9470 9470 5bc1 4c4c → "[ALL..."

Test 5: Large file (18 hours of content)

$ ./linux/ccextractor --in=raw --out=mcc /tmp/issue_1565/DTV3.raw -o /tmp/test_large.mcc
# Result: 87MB MCC file, 1,942,013 lines, timing to 17:58:52

Processes 18 hours of raw caption data correctly

Test 6: Regression test - SRT output still works

$ ./linux/ccextractor --in=raw --out=srt /tmp/test113_raw.raw -o /tmp/test.srt
$ head -10 /tmp/test.srt
1
00:00:00,001 --> 00:00:01,429
[ALL SHOUTG]                    
>> H OFFGET HER F.              
>>TOP IT.                       

SRT output still works correctly

Test 7: All Rust tests pass

$ cargo test
test result: ok. 299 passed; 0 failed; 0 ignored

Test 8: Code quality checks

$ clang-format --style=file -i src/lib_ccx/general_loop.c  # ✅ No issues
$ cargo fmt --check                                         # ✅ No issues  
$ cargo clippy                                              # ✅ No warnings

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/CCExtractor/ccextractor/pull/1859 **Author:** [@cfsmp3](https://github.com/cfsmp3) **Created:** 12/20/2025 **Status:** ✅ Merged **Merged:** 12/20/2025 **Merged by:** [@cfsmp3](https://github.com/cfsmp3) **Base:** `master` ← **Head:** `fix/issue-1542-mcc-output-from-raw` --- ### 📝 Commits (1) - [`d0d46fc`](https://github.com/CCExtractor/ccextractor/commit/d0d46fc176a7318e7bf74fc06d9e202376537f57) fix(mcc): Add MCC output support for raw caption files ### 📊 Changes **1 file changed** (+65 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `src/lib_ccx/general_loop.c` (+65 -3) </details> ### 📄 Description ## Summary Fixes #1542 - MCC output now works with raw caption input files. Previously, when using `-out=mcc` with raw input files (`-in=raw`), CCExtractor would print "Output format not supported" repeatedly and produce no output. This was because the raw file processing path decoded CEA-608 data to text, but MCC format requires raw cc_data bytes wrapped in CDP (Caption Distribution Packet) format. ## Changes - Added `process_raw_for_mcc()` helper function in `general_loop.c` that: - Converts 2-byte raw pairs to 3-byte cc_data format (marker + 2 data bytes) - Wraps each CC pair in CDP format via `mcc_encode_cc_data()` - Maintains proper timing at 29.97fps - Skips broadcast headers (0xff 0xff) - Modified `raw_loop()` to detect MCC output format and use the new code path instead of the normal decoder path ## Test plan ### Test 1: Basic raw file to MCC conversion ```bash # Before fix: $ ./linux/ccextractor --in=raw --out=mcc /tmp/test113_raw.raw -o /tmp/test.mcc # Output: "Output format not supported" (123 times), exit code 10, empty file # After fix: $ ./linux/ccextractor --in=raw --out=mcc /tmp/test113_raw.raw -o /tmp/test.mcc # Output: Success, 238KB MCC file with 5316 lines ``` ### Test 2: MCC file content verification ``` $ head -50 /tmp/test.mcc | tail -10 UUID=76931FAC-9DAB-42B3-AC24-8B87D6AE33F9 Creation Program=CCExtractor Creation Date=Saturday, December 20, 2025 Creation Time=11:52:38 Time Code Rate=30 00:00:00:00 T0FS0F4F43ZZ72E104808074ZZDC 00:00:00:01 T0FS0F4F43Z0172E104808074Z01DE 00:00:00:02 T0FS0F4F43Z0272E104808074Z02E0 ``` ### Test 3: Timing progression validation ``` $ tail -5 /tmp/test.mcc 00:02:55:15 T0FS0F4F43149172E104808074149126 00:02:55:16 T0FS0F4F43149272E104808074149228 00:02:55:17 T0FS0F4F43149372E10480807414932A 00:02:55:18 T0FS0F4F43149472E10480807414942C 00:02:55:19 T0FS0F4F43149572E10480807414952E ``` ✅ Timing correctly progresses from 00:00:00:00 to 00:02:55:19 (matching Max PTS) ### Test 4: Caption data verification The MCC output contains actual CEA-608 control codes and text: ``` # Around 5 seconds where captions start: 00:00:05:09 T0FS0F4F43Z9F72E104942674Z9FD4 # 9426 = roll-up command 00:00:05:10 T0FS0F4F43ZA072E10494AD74ZA05D # 94AD = positioning 00:00:05:13 T0FS0F4F43ZA372E1045BC174ZA33E # 5BC1 = "[A" text 00:00:05:14 T0FS0F4F43ZA472E1044C4C74ZA4BC # 4C4C = "LL" text ``` ✅ Matches raw file hex dump: `9426 94ad 9470 9470 5bc1 4c4c` → "[ALL..." ### Test 5: Large file (18 hours of content) ```bash $ ./linux/ccextractor --in=raw --out=mcc /tmp/issue_1565/DTV3.raw -o /tmp/test_large.mcc # Result: 87MB MCC file, 1,942,013 lines, timing to 17:58:52 ``` ✅ Processes 18 hours of raw caption data correctly ### Test 6: Regression test - SRT output still works ```bash $ ./linux/ccextractor --in=raw --out=srt /tmp/test113_raw.raw -o /tmp/test.srt $ head -10 /tmp/test.srt 1 00:00:00,001 --> 00:00:01,429 [ALL SHOUTG] >> H OFFGET HER F. >>TOP IT. ``` ✅ SRT output still works correctly ### Test 7: All Rust tests pass ```bash $ cargo test test result: ok. 299 passed; 0 failed; 0 ignored ``` ### Test 8: Code quality checks ```bash $ clang-format --style=file -i src/lib_ccx/general_loop.c # ✅ No issues $ cargo fmt --check # ✅ No issues $ cargo clippy # ✅ No warnings ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <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:10 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#2628