[PR #1822] fix(ts): Add fallback for TS files without PAT/PMT tables #2575

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

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

State: closed
Merged: Yes


Summary

  • Adds fallback mechanism for TS files that lack PAT/PMT tables
  • Enables packet analysis mode when no PAT is found after ~1000 packets
  • Detects video streams from PES headers (stream_id 0xE0-0xEF)
  • Identifies MPEG-2 vs H.264 stream type from elementary stream data
  • Registers detected video PIDs for caption extraction

Problem

Some DVR recordings (e.g., Channel Master DVR+) create transport stream files that contain valid video and audio data with embedded CEA-608/708 captions, but lack PAT (Program Association Table) and PMT (Program Map Table).

Without these tables, CCExtractor couldn't identify which PIDs contain video streams, resulting in "No captions were found in input" even though tools like VLC could display the captions.

Solution

The fix adds a fallback mechanism that:

  1. Monitors for PAT packets during TS parsing
  2. After reading ~188KB without finding a PAT, enables packet analysis mode
  3. Analyzes PES headers to detect video streams (stream_id 0xE0-0xEF)
  4. Registers detected video PIDs with update_capinfo() for caption extraction
  5. Also scans for GA94 caption markers to identify caption-carrying PIDs

This allows CCExtractor to extract captions from TS files without PAT/PMT, matching the behavior when FFmpeg is enabled as a fallback parser.

Test plan

  • Test with DVR+ sample files without PAT/PMT (dracula.ts, stanley.ts, football.ts)
  • Verify captions are extracted correctly
  • Test with Avidemux-processed files (with PAT/PMT) to ensure no regression
  • Verify extracted captions match between original and PAT/PMT-added versions

Fixes #805

🤖 Generated with Claude Code

**Original Pull Request:** https://github.com/CCExtractor/ccextractor/pull/1822 **State:** closed **Merged:** Yes --- ## Summary - Adds fallback mechanism for TS files that lack PAT/PMT tables - Enables packet analysis mode when no PAT is found after ~1000 packets - Detects video streams from PES headers (stream_id 0xE0-0xEF) - Identifies MPEG-2 vs H.264 stream type from elementary stream data - Registers detected video PIDs for caption extraction ## Problem Some DVR recordings (e.g., Channel Master DVR+) create transport stream files that contain valid video and audio data with embedded CEA-608/708 captions, but lack PAT (Program Association Table) and PMT (Program Map Table). Without these tables, CCExtractor couldn't identify which PIDs contain video streams, resulting in "No captions were found in input" even though tools like VLC could display the captions. ## Solution The fix adds a fallback mechanism that: 1. Monitors for PAT packets during TS parsing 2. After reading ~188KB without finding a PAT, enables packet analysis mode 3. Analyzes PES headers to detect video streams (stream_id 0xE0-0xEF) 4. Registers detected video PIDs with `update_capinfo()` for caption extraction 5. Also scans for GA94 caption markers to identify caption-carrying PIDs This allows CCExtractor to extract captions from TS files without PAT/PMT, matching the behavior when FFmpeg is enabled as a fallback parser. ## Test plan - [x] Test with DVR+ sample files without PAT/PMT (dracula.ts, stanley.ts, football.ts) - [x] Verify captions are extracted correctly - [x] Test with Avidemux-processed files (with PAT/PMT) to ensure no regression - [x] Verify extracted captions match between original and PAT/PMT-added versions Fixes #805 🤖 Generated with [Claude Code](https://claude.com/claude-code)
claunia added the pull-request label 2026-01-29 17:22:51 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#2575