Fix infinite loop in TS processing no subtitles (Issue #1754) #1901
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Title: Fix infinite binary output loop for TS files with no subtitles (#1754)
Description:
Summary
This PR fixes a bug where processing certain Transport Stream (.ts) files that contain video streams but no subtitles would cause ccextractor to enter an infinite loop, continuously outputting binary data without making progress.
Related Issue
Fixes #1754
Changes
src/lib_ccx/general_loop.c
Implemented a safeguard in
process_non_multiprogram_general_loop
If the video decoder (process_m2v) returns 0 bytes consumed but the buffer still contains data (> 8 bytes), the logic now forcibly consumes the buffer.
This prevents the demuxer from getting stuck re-processing the same invalid or problematic video data indefinitely while waiting for a caption block that never arrives.
Verification
Verified using a synthetic .ts file generated to contain valid MPEG-2 Video PES headers but no subtitle data.
Before: The process would hang or output infinite binary data.
After: The process correctly identifies the video stream, finds no captions, and exits gracefully with EXIT_NO_CAPTIONS (Code 10).
Ran full build to ensure no regressions in standard general_loop behavior.