Multi-file processing broken: only first file is processed #853

Closed
opened 2026-01-29 16:55:21 +00:00 by claunia · 0 comments
Owner

Originally created by @cfsmp3 on GitHub (Dec 14, 2025).

Bug Description

When multiple input files are provided on the command line, only the first file is processed. The remaining files are silently ignored.

Steps to Reproduce

ccextractor file1.mpg file2.mpg file3.mpg -o output.srt

Expected Behavior

All files should be processed and their captions concatenated into a single output file.

Actual Behavior

Only the first file is processed. The output file contains captions only from the first input file.

Evidence

I tested with three files:

  • File 1: produces 26,632 bytes of output individually
  • File 2: produces 11,547 bytes of output individually
  • File 3: produces 255,493 bytes of output individually

When processed together with multi-file input, the output is exactly 26,632 bytes - matching only the first file.

Root Cause

The bug is in src/rust/src/common.rs at line 216:

(*ccx_s_options).num_input_files =
    options.inputfile.iter().filter(|s| !s.is_empty()).count() as _;

The problem is that options.inputfile is of type Option<Vec<String>>. Calling .iter() on an Option yields 0 or 1 items (the inner value if Some), not the contents of the Vec. This causes num_input_files to always be 1 when there are any input files, regardless of how many files are actually provided.

Fix

The correct code should iterate over the Vec contents:

(*ccx_s_options).num_input_files =
    options.inputfile.as_ref().map_or(0, |v| v.iter().filter(|s| !s.is_empty()).count()) as _;

Version

CCExtractor 0.95 (commit d4949ccf)

Note

This bug was discovered while attempting to verify issue #1377 (memory corruption when processing multiple files). That original issue cannot be tested because this bug prevents multiple files from ever being processed.

Originally created by @cfsmp3 on GitHub (Dec 14, 2025). ## Bug Description When multiple input files are provided on the command line, only the first file is processed. The remaining files are silently ignored. ## Steps to Reproduce ```bash ccextractor file1.mpg file2.mpg file3.mpg -o output.srt ``` ## Expected Behavior All files should be processed and their captions concatenated into a single output file. ## Actual Behavior Only the first file is processed. The output file contains captions only from the first input file. ## Evidence I tested with three files: - File 1: produces 26,632 bytes of output individually - File 2: produces 11,547 bytes of output individually - File 3: produces 255,493 bytes of output individually When processed together with multi-file input, the output is exactly 26,632 bytes - matching only the first file. ## Root Cause The bug is in `src/rust/src/common.rs` at line 216: ```rust (*ccx_s_options).num_input_files = options.inputfile.iter().filter(|s| !s.is_empty()).count() as _; ``` The problem is that `options.inputfile` is of type `Option<Vec<String>>`. Calling `.iter()` on an `Option` yields 0 or 1 items (the inner value if `Some`), not the contents of the `Vec`. This causes `num_input_files` to always be 1 when there are any input files, regardless of how many files are actually provided. ## Fix The correct code should iterate over the Vec contents: ```rust (*ccx_s_options).num_input_files = options.inputfile.as_ref().map_or(0, |v| v.iter().filter(|s| !s.is_empty()).count()) as _; ``` ## Version CCExtractor 0.95 (commit d4949ccf) ## Note This bug was discovered while attempting to verify issue #1377 (memory corruption when processing multiple files). That original issue cannot be tested because this bug prevents multiple files from ever being processed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#853