[PR #1818] fix: Enable stdout output for CEA-708 captions on Windows #2564

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

Original Pull Request: https://github.com/CCExtractor/ccextractor/pull/1818

State: closed
Merged: Yes


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

**Original Pull Request:** https://github.com/CCExtractor/ccextractor/pull/1818 **State:** closed **Merged:** Yes --- ## 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 - [x] All 270 Rust tests pass - [x] Added `test_writer_output_with_valid_fd` - verifies stdout mode works when fd is pre-set - [x] Added `test_writer_output_missing_filename_and_fd` - verifies proper error handling (not panic) - [x] Verified subtitles extract correctly to stdout on Linux - [x] Windows fix uses proper `GetStdHandle(STD_OUTPUT_HANDLE)` API 🤖 Generated with [Claude Code](https://claude.com/claude-code)
claunia added the pull-request label 2026-01-29 17:22:47 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#2564