[PR #1769] [FIX]: Add HEVC/H.265 stream type recognition to prevent crashes on ATSC 3.0 streams #2497

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

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

State: closed
Merged: Yes


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.

Summary

This PR adds recognition for HEVC/H.265 video streams (stream type 0x24) in MPEG-TS files, fixing crashes when processing ATSC 3.0 broadcasts. This is a partial fix for issue #1639.

Problem

When CCExtractor encounters HEVC-encoded streams (commonly used in ATSC 3.0 broadcasts), it crashes with:

Error: In process_data: datanode->buffer is of unknown data type!

This occurs because the codebase did not recognize stream type 0x24 (HEVC/H.265), causing it to be treated as an unknown stream type.

Changes Made

1. Added HEVC enum constant (ccx_common_constants.h)

  • Added CCX_STREAM_TYPE_VIDEO_HEVC = 0x24 to the stream type enumeration

2. Updated stream type handling (ts_functions.c)

  • get_buffer_type_str(): Returns "HEVC" for HEVC streams (for logging/display)
  • get_buffer_type(): Maps HEVC to CCX_H264 buffer type (HEVC uses similar NAL unit structure)
  • init_ts(): Added "HEVC video" description to the stream type lookup table

3. Updated PMT parsing (ts_tables.c)

  • get_printable_stream_type(): Converts raw 0x24 stream type to CCX_STREAM_TYPE_VIDEO_HEVC
  • parse_PMT(): Extended video stream detection to include HEVC alongside H.264 and MPEG2
  • Added informative message: "Detected HEVC video stream (0x24) - enabling ATSC CC parsing."
  • Removed commented-out dead code for cleaner maintenance

Testing

Tested with ATSC 3.0 TS file from issue #1639. Results:

Before:

Error: In process_data: datanode->buffer is of unknown data type!

After:

Detected HEVC video stream (0x24) - enabling ATSC CC parsing.
HEVC video stream [0x24]  -  PID: 49
...
No captions were found in input.

The crash is fixed and HEVC streams are properly recognized.

Limitations

Important: While this PR fixes the crash and enables HEVC stream recognition, it does not extract captions from HEVC streams. Users will see:

No captions were found in input.

This is because:

  1. HEVC captions may be embedded in SEI (Supplemental Enhancement Information) messages with different structure than H.264
  2. The sample file contains STPP (Subtitling and Timed Text) format data (codec_tag=0x50505453 per ffprobe), which requires a separate parser
  3. Caption extraction from HEVC requires additional development.
    This PR is foundational work - as currently CCextractor cannot extract captions from HEVC if the system doesn't even recognize HEVC streams. This prevents crashes and enables future caption extraction work.

Files Changed

  • src/lib_ccx/ccx_common_constants.h - Added HEVC enum value
  • src/lib_ccx/ts_functions.c - Added HEVC handling in 3 functions
  • src/lib_ccx/ts_tables.c - Added HEVC detection and PMT parsing support

Note to maintainers: This is a stepping-stone PR. It doesn't solve the full caption extraction problem, but it's a necessary prerequisite. ATSC 3.0 adoption is growing in the US, and at minimum, CCExtractor should not crash when encountering these streams. I'm happy to address any feedback or make adjustments as needed.

**Original Pull Request:** https://github.com/CCExtractor/ccextractor/pull/1769 **State:** closed **Merged:** Yes --- **In raising this pull request, I confirm the following (please check boxes):** - [x] I have read and understood the [contributors guide](https://github.com/CCExtractor/ccextractor/blob/master/.github/CONTRIBUTING.md). - [x] I have checked that another pull request for this purpose does not exist. - [x] I have considered, and confirmed that this submission will be valuable to others. - [x] I accept that this submission may not be used, and the pull request closed at the will of the maintainer. - [x] I give this submission freely, and claim no ownership to its content. - [x] **I have mentioned this change in the [changelog](https://github.com/CCExtractor/ccextractor/blob/master/docs/CHANGES.TXT).** **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. - [x] I am an active contributor to CCExtractor. --- ## Summary This PR adds recognition for HEVC/H.265 video streams (stream type `0x24`) in MPEG-TS files, fixing crashes when processing ATSC 3.0 broadcasts. This is a **partial fix** for issue #1639. ## Problem When CCExtractor encounters HEVC-encoded streams (commonly used in ATSC 3.0 broadcasts), it crashes with: ``` Error: In process_data: datanode->buffer is of unknown data type! ``` This occurs because the codebase did not recognize stream type `0x24` (HEVC/H.265), causing it to be treated as an unknown stream type. ## Changes Made ### 1. Added HEVC enum constant (`ccx_common_constants.h`) - Added `CCX_STREAM_TYPE_VIDEO_HEVC = 0x24` to the stream type enumeration ### 2. Updated stream type handling (`ts_functions.c`) - **`get_buffer_type_str()`**: Returns `"HEVC"` for HEVC streams (for logging/display) - **`get_buffer_type()`**: Maps HEVC to `CCX_H264` buffer type (HEVC uses similar NAL unit structure) - **`init_ts()`**: Added `"HEVC video"` description to the stream type lookup table ### 3. Updated PMT parsing (`ts_tables.c`) - **`get_printable_stream_type()`**: Converts raw `0x24` stream type to `CCX_STREAM_TYPE_VIDEO_HEVC` - **`parse_PMT()`**: Extended video stream detection to include HEVC alongside H.264 and MPEG2 - Added informative message: `"Detected HEVC video stream (0x24) - enabling ATSC CC parsing."` - Removed commented-out dead code for cleaner maintenance ## Testing Tested with ATSC 3.0 TS file from issue #1639. Results: **Before:** ``` Error: In process_data: datanode->buffer is of unknown data type! ``` **After:** ``` Detected HEVC video stream (0x24) - enabling ATSC CC parsing. HEVC video stream [0x24] - PID: 49 ... No captions were found in input. ``` The crash is fixed and HEVC streams are properly recognized. ## Limitations **Important:** While this PR fixes the crash and enables HEVC stream recognition, **it does not extract captions from HEVC streams**. Users will see: ``` No captions were found in input. ``` This is because: 1. HEVC captions may be embedded in SEI (Supplemental Enhancement Information) messages with different structure than H.264 2. The sample file contains STPP (Subtitling and Timed Text) format data (`codec_tag=0x50505453` per ffprobe), which requires a separate parser 3. Caption extraction from HEVC requires additional development. This PR is **foundational work** - as currently CCextractor cannot extract captions from HEVC if the system doesn't even recognize HEVC streams. This prevents crashes and enables future caption extraction work. ## Files Changed - `src/lib_ccx/ccx_common_constants.h` - Added HEVC enum value - `src/lib_ccx/ts_functions.c` - Added HEVC handling in 3 functions - `src/lib_ccx/ts_tables.c` - Added HEVC detection and PMT parsing support --- **Note to maintainers:** This is a stepping-stone PR. It doesn't solve the full caption extraction problem, but it's a necessary prerequisite. ATSC 3.0 adoption is growing in the US, and at minimum, CCExtractor should not crash when encountering these streams. I'm happy to address any feedback or make adjustments as needed.
claunia added the pull-request label 2026-01-29 17:22:27 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#2497