Skip to content

Conversation

@cfsmp3
Copy link
Contributor

@cfsmp3 cfsmp3 commented Dec 14, 2025

Summary

Fixes #1693 - ccextractorwinfull.exe can't print captions to stdout

The CEA-708 decoder crashed on Windows when using --stdout because the dtvcc_writer was not properly initialized for stdout output.

Changes

  1. Fixed Windows stdout handle initialization (ccx_encoders_common.c):

    • Use GetStdHandle(STD_OUTPUT_HANDLE) instead of NULL for fhandle
    • This allows the Rust writer to detect stdout mode properly
  2. Changed env_logger target from Stdout to Stderr (lib.rs):

    • Debug messages no longer pollute stdout when using --stdout
    • This prevents mixing debug output with subtitle content
  3. Removed redundant debug statement (service_decoder.rs):

    • The bare debug!("{}", self.current_window) was noisy and duplicated by a more detailed debug statement below it

Test plan

  • All 270 Rust tests pass
  • Added test_writer_output_with_valid_fd - verifies stdout mode works when fd is pre-set
  • Added test_writer_output_missing_filename_and_fd - verifies proper error handling (not panic)
  • Verified subtitles extract correctly to stdout on Linux
  • Windows fix uses proper GetStdHandle(STD_OUTPUT_HANDLE) API

🤖 Generated with Claude Code

Fixes #1693 - ccextractorwinfull.exe can't print captions to stdout

The CEA-708 decoder crashed on Windows when using --stdout because the
dtvcc_writer was not properly initialized for stdout output:

1. Fixed Windows stdout handle initialization in ccx_encoders_common.c:
   - Use GetStdHandle(STD_OUTPUT_HANDLE) instead of NULL for fhandle
   - This allows the Rust writer to detect stdout mode properly

2. Changed env_logger target from Stdout to Stderr in lib.rs:
   - Debug messages no longer pollute stdout when using --stdout
   - This prevents mixing debug output with subtitle content

3. Removed redundant debug statement in service_decoder.rs:
   - The bare `debug!("{}", self.current_window)` was noisy and
     duplicated by a more detailed debug statement below it

Added tests:
- test_writer_output_with_valid_fd: Verifies stdout mode works
- test_writer_output_missing_filename_and_fd: Verifies proper error handling

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@syehoonkim
Copy link

@cfsmp3 Thanks for fixing this issue. It looks like there are still some conflicts, and I’m wondering if you plan to resolve them. Thanks again.

Resolved conflict in src/rust/src/lib.rs:
- Kept stderr target change from this branch (for --stdout option)
- Merged safety documentation from master
@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 a0809ca...:
Report Name Tests Passed
Broken 13/13
CEA-708 8/14
DVB 7/7
DVD 3/3
DVR-MS 2/2
General 27/27
Hardsubx 0/1
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 77/86
Teletext 17/21
WTV 12/13
XDS 34/34

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


All tests passing on the master branch were passed completely.

Check the result page for more info.

@cfsmp3 cfsmp3 merged commit 083c126 into master Dec 18, 2025
29 of 31 checks passed
@cfsmp3 cfsmp3 deleted the fix/issue-1693-stdout-crash branch December 18, 2025 12:11
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.

ccextractorwinfull.exe can't print captions to stdout

4 participants