How lavanyajc/ccextractor works
Project type and purpose
• CCExtractor is an open-source, cross-platform subtitle extraction tool. It ships as a command-line executable (ccextractor) and platform-specific GUIs (Windows/Mac). Its core functionality is written in C (lib_ccx), with a modern Rust port (lib_ccxr) and various packaging/build scripts.
• Use cases: extract closed captions from TV streams or files, translate them, hard-sub burn, output in multiple subtitle formats.
File structure
• Top-level “src” directory holds:
• ccextractor.c / .h — CLI entry point
• lib_ccx/ — the main C library modules (demuxers, decoders, encoders, OCR, HardsubX, networking, utility)
• rust/ — Rust port with two crates: lib_ccxr (core logic) and the Rust binary wrapper
• thirdparty/ — bundled external dependencies (freetype, libpng, zlib, protobuf-c, utf8proc, etc.)
• Platform subdirectories: linux/, mac/, windows/ contain build scripts, installers, GUIs.
• docker/ & Vagrantfile provide reproducible dev/test environments.
• package_creators/ automates distribution packaging (RPM, Debian, Arch, tarballs).
README for technical stack
• Core languages: C, Rust, small Python tools.
• Build tools: CMake, Bazel (BUILD files), Make, autoconf/automake.
• Packaging & CI: GitHub Actions, Travis, AppImage, Windows Installer (WiX), Homebrew/MacPorts.
Main components and interactions (to represent
• CLI executable (“ccextractor”)
• Windows GUI (InstallCCExtractorMacGUI.app for Mac, .sln/.vcxproj for Windows)
• Rust wrapper (in rust/src) for new CLI
• Demuxers → Bitstream parser → CC decoders (608, 708, ISDB, teletext) → Timing & sequencing
• Optional modules: OCR engine, HardsubX classifier/decoder, networking input
• Output encoders: SRT, WebVTT, SCC, SAMI, MPL2, transcripts, burned-in PNG (uses libpng+freetype)
• freetype (font metrics/rendering)
• libpng (image output)
• zlib (compression)
• protobuf-c (data serialization for internal messages)
• utf8proc, iconv, system libs
• Build systems: CMake, Bazel, Make + autoconf
• CI/CD: GitHub workflows, Travis, Sample-Platform
• Distribution: Docker image, Vagrant VM, platform installers, package_creators scripts
Relationships & data flow
• Input media (file/stream) → Front-end → Core library demuxer
• Core demuxer → CC decoder → timing/sequencing
• Sequenced captions → Output encoders → Subtitle files or burned video frames
• Encoders → Third-party libs (freetype+libpng for PNG burn; zlib for compression)
• Rust wrapper calls into the same core functionality (via C FFI or direct Rust implementation).
Architectural patterns & principles
• Modular pipeline: clearly separated stages (demux → decode → process → encode)
• Pluggable I/O: supports local files, network streams
• Dual implementation: C reference library and Rust port for safety/performance
• Cross-platform abstraction: platform layers for Windows/Mac/Linux build & GUI