Skip to content

Conversation

@x15sr71
Copy link
Contributor

@x15sr71 x15sr71 commented Nov 28, 2025

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.

Description

Fixes #1759 - This PR restores functional XMLTV generation for ATSC broadcast streams, ATSC streams with VCT/TVCT tables now generate XMLTV output correctly.

Problem

The -xmltv parameter was being ignored for ATSC broadcast streams. When processing ATSC transport streams with valid EPG data (EIT tables) and channel information (VCT/TVCT tables), CCExtractor would:

  • Generate SRT caption files (working correctly)
  • NOT generate XMLTV files (the bug)

This made it impossible to extract Electronic Program Guide data from ATSC streams, despite the -xmltv parameter being specified.

Root causes identified:

  1. EPG events stored in fallback storage (TS_PMT_MAP_SIZE) were never output
  2. Inverted buffer boundary check logic prevented complete ATSC EIT parsing
  3. Limited ATSC table ID support (missing extended EIT tables 0xCC-0xD0 and Cable VCT 0xC9)

Solution

Core Fixes

  1. Fixed EPG output logic (EPG_output() function)

    • Modified to always check fallback storage, not only when nb_program == 0
    • ATSC streams store events in fallback due to VCT source ID mapping, but these were being ignored
    • Now correctly outputs events from both regular program storage and fallback storage
  2. Fixed critical buffer boundary check (CHECK_OFFSET macro)

    • Corrected inverted logic from < to >
    • Before: if (offset + val < offset_end) (allowed buffer overruns)
    • After: if (offset + (val) > offset_end) (prevents overruns)
    • Applied to both EIT and VCT parsing functions
  3. Extended ATSC table support (EPG_parse_table() function)

    • Added support for extended EIT table IDs: 0xCC, 0xCD, 0xCE, 0xCF, 0xD0
    • Added Cable VCT variant: 0xC9
    • Ensures comprehensive ATSC EPG data extraction

Testing

Tested with 1 2 sample files provided by @TPeterson94070:

  • channel5FullTS.ts - 5 channels with VCT/TVCT tables
  • ch12FullTS.ts - Additional ATSC test case
  • ch29FullTS.ts - 5 programs with extended EIT data (Nov 26-28, 2025)

Before this fix:

./ccextractor channel5FullTS.ts --xmltv 1
  • Output: Only .srt file generated
  • No XMLTV file created (bug)

After this fix:

./ccextractor channel5FullTS.ts --xmltv 1
  • Output: Both .srt AND .xml files generated
  • XMLTV file contains:
    • Channel listings extracted from VCT
    • Program schedules parsed from EIT-0/1/2/3
    • UTC timestamps, titles, and subtitles properly captured
    • Unique ts-meta-id values matching EIT event IDs

Known Limitations

  1. ATSC EIT timestamps appear incorrect in some streams (e.g., year showing as 2047). This is due to pre-existing limitations in ATSC date/time decoding logic.

  2. XMLTV output uses numeric channel IDs instead of full ATSC channel names. VCT short_name and major/minor channel numbers are not currently mapped.

  3. Some EIT events appear under channel="0". This happens when service_id does not map to a VCT-defined program.

Backward Compatibility

  • No breaking changes to existing DVB/SDT functionality
  • DVB streams continue to work as before
  • SRT caption extraction unchanged for all stream types
  • Only adds/fixes ATSC XMLTV generation

Note on Known Limitations:

This PR focuses solely on fixing the core issue: restoring XMLTV generation for ATSC streams. The three accuracy issues mentioned above (incorrect dates, channel naming, orphaned programs) are data quality problems that existed in the codebase previously and are not directly caused by or related to the primary bug fix in this PR.

I believe these should be addressed in follow-up PRs for better separation of concerns. However, if maintainers prefer the date/time conversion issue (year 2047 bug) to be fixed in this PR due to its impact on usability, I'm happy to include it. Please advise on your preferred approach.

@ccextractor-bot
Copy link
Collaborator

CCExtractor CI platform finished running the test files on linux. Below is a summary of the test results, when compared to test for commit 42d7509...:
Report Name Tests Passed
Broken 13/13
CEA-708 14/14
DVB 7/7
DVD 3/3
DVR-MS 2/2
General 27/27
Hardsubx 1/1
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 86/86
Teletext 21/21
WTV 13/13
XDS 34/34

Congratulations: Merging this PR would fix the following tests:


All tests passing on the master branch were passed completely.

Check the result page for more info.

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.

ccextractor appears to ignore -xmltv parameter

2 participants