[BUG] Error in switch_to_next_file() #833

Closed
opened 2026-01-29 16:54:40 +00:00 by claunia · 3 comments
Owner

Originally created by @shri-acha on GitHub (Jun 10, 2025).

I got an error while trying to run an example video i got from on the web.

I'd like some help with solving it.

I've tried to wander around the codebase and found out that below:

if (ctx->inputsize > 0 && ((ctx->demux_ctx->past + bytesinbuffer) < ctx->inputsize) && is_decoder_processed_enough(ctx) == CCX_FALSE)

line handles the error, and also as the log mentions it, the file being read is probably hasn't been parsed.

Output Images:
Image
Video Used:
Example Video

Originally created by @shri-acha on GitHub (Jun 10, 2025). I got an error while trying to run an example video i got from on the web. I'd like some help with solving it. I've tried to wander around the codebase and found out that below: ```c if (ctx->inputsize > 0 && ((ctx->demux_ctx->past + bytesinbuffer) < ctx->inputsize) && is_decoder_processed_enough(ctx) == CCX_FALSE) ``` line handles the error, and also as the log mentions it, the file being read is probably hasn't been parsed. Output Images: ![Image](https://github.com/user-attachments/assets/aaf27432-28fd-44df-9867-3d138f25b77d) Video Used: [Example Video](https://cdmdemo.contentdm.oclc.org/utils/getfile/collection/p15700coll2/id/7/filename/video1.ogg)
Author
Owner

@tmdeveloper007 commented on GitHub (Oct 28, 2025):

What is the problem ?

The error occurs in the switch_to_next_file() function in file_functions.c:283
when CCExtractor detects that file processing ended prematurely. The condition
that triggers this error is:

if (ctx->inputsize > 0 && ((ctx->demux_ctx->past + bytesinbuffer) <
ctx->inputsize) && is_decoder_processed_enough(ctx) == CCX_FALSE)

This means ---->

  • File has a known size (> 0)
  • The amount of data processed (demux_ctx->past + buffer) is less than the
    total file size
  • The decoder hasn't signaled that it's "processed enough" (not reached
    user-defined limits)
@tmdeveloper007 commented on GitHub (Oct 28, 2025): What is the problem ? The error occurs in the switch_to_next_file() function in file_functions.c:283 when CCExtractor detects that file processing ended prematurely. The condition that triggers this error is: if (ctx->inputsize > 0 && ((ctx->demux_ctx->past + bytesinbuffer) < ctx->inputsize) && is_decoder_processed_enough(ctx) == CCX_FALSE) This means ----> - File has a known size (> 0) - The amount of data processed (demux_ctx->past + buffer) is less than the total file size - The decoder hasn't signaled that it's "processed enough" (not reached user-defined limits)
Author
Owner

@AnujRewar commented on GitHub (Oct 29, 2025):

In my terminal it is showing like this

Image
@AnujRewar commented on GitHub (Oct 29, 2025): In my terminal it is showing like this <img width="948" height="615" alt="Image" src="https://github.com/user-attachments/assets/acf22b6c-483a-4a67-8020-c92b07ea95f4" />
Author
Owner

@DhanushVarma-2 commented on GitHub (Nov 9, 2025):

Hi , I've identified the root cause of this bug and am ready to implement a fix.
Problem Analysis:

The issue is in the is_decoder_processed_enough() function in src/lib_ccx/lib_ccx.c. The current logic is:

if (dec_ctx->processed_enough == CCX_TRUE && ctx->multiprogram == CCX_FALSE)
return CCX_TRUE;
The bug: When multiprogram mode is enabled, this function always returns CCX_FALSE, even when decoders have actually processed enough data.

This causes the condition in switch_to_next_file() to incorrectly trigger the "premature ending" error:

if (ctx->inputsize > 0 &&
((ctx->demux_ctx->past + bytesinbuffer) < ctx->inputsize) &&
is_decoder_processed_enough(ctx) == CCX_FALSE) ← Always true in multiprogram mode

Proposed Fix:

I will modify the is_decoder_processed_enough() function to properly handle multiprogram mode. The function should check if ANY decoder has processed enough data, regardless of multiprogram setting.

I'm working on the implementation now and will submit a PR shortly.

@DhanushVarma-2 commented on GitHub (Nov 9, 2025): Hi , I've identified the root cause of this bug and am ready to implement a fix. Problem Analysis: The issue is in the is_decoder_processed_enough() function in src/lib_ccx/lib_ccx.c. The current logic is: if (dec_ctx->processed_enough == CCX_TRUE && ctx->multiprogram == CCX_FALSE) return CCX_TRUE; The bug: When multiprogram mode is enabled, this function always returns CCX_FALSE, even when decoders have actually processed enough data. This causes the condition in switch_to_next_file() to incorrectly trigger the "premature ending" error: if (ctx->inputsize > 0 && ((ctx->demux_ctx->past + bytesinbuffer) < ctx->inputsize) && is_decoder_processed_enough(ctx) == CCX_FALSE) ← Always true in multiprogram mode Proposed Fix: I will modify the is_decoder_processed_enough() function to properly handle multiprogram mode. The function should check if ANY decoder has processed enough data, regardless of multiprogram setting. I'm working on the implementation now and will submit a PR shortly.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#833