Skip to content

fix(rust): correctly count and store multiple input files#1811

Merged
cfsmp3 merged 1 commit intomasterfrom
fix/multi-file-processing
Dec 14, 2025
Merged

fix(rust): correctly count and store multiple input files#1811
cfsmp3 merged 1 commit intomasterfrom
fix/multi-file-processing

Conversation

@cfsmp3
Copy link
Copy Markdown
Contributor

@cfsmp3 cfsmp3 commented Dec 14, 2025

Summary

  • Fix bug where num_input_files was always set to 1 regardless of how many input files were provided
  • Fix bug where input files were stored at wrong indices (0, 10, 20... instead of 0, 1, 2...)

Root Cause

Two bugs in the Rust argument parsing code prevented multi-file processing from working:

Bug 1: Incorrect iteration in common.rs:216

// BUG: .iter() on Option<Vec<String>> yields 0 or 1 items (the Vec itself), not Vec contents
options.inputfile.iter().filter(|s| !s.is_empty()).count()

// FIX: Iterate over the Vec contents
options.inputfile.as_ref().unwrap().iter().filter(|s| !s.is_empty()).count()

Bug 2: Wrong indexing in parser.rs:append_file_to_queue()

The function used inputfile.len() as the index for new files, but after resize(10, String::new()), the length becomes 10 even with only 1 file. This caused the second file to go to index 10, third to index 20, etc.

Fixed by simply using push() instead of manual index calculation.

Test plan

  • Build ccextractor with fixes
  • Test with multiple input files: ccextractor file1.mpg file2.mpg file3.mpg -o output.srt
  • Verify all files are opened (check for "Opening file:" messages)
  • Verify no crash occurs
  • Run cargo clippy - no warnings on changed files

Fixes #1810

🤖 Generated with Claude Code

Fix two bugs that prevented multi-file processing from working:

1. In common.rs: `options.inputfile.iter()` was iterating over the
   Option itself (yielding 0 or 1 items) instead of the Vec contents,
   causing num_input_files to always be 1.

2. In parser.rs: append_file_to_queue() was using vec.len() as the
   index for new files after resizing with empty strings, causing
   files to be placed at positions 0, 10, 20... instead of 0, 1, 2...

Fixes #1810

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@ccextractor-bot
Copy link
Copy Markdown
Collaborator

CCExtractor CI platform finished running the test files on linux. Below is a summary of the test results, when compared to test for commit 1b0808b...:
Report Name Tests Passed
Broken 13/13
CEA-708 14/14
DVB 7/7
DVD 3/3
DVR-MS 2/2
General 27/27
Hardsubx 1/1
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 84/86
Teletext 21/21
WTV 13/13
XDS 28/34

Your PR breaks these cases:

Congratulations: Merging this PR would fix the following tests:


It seems that not all tests were passed completely. This is an indication that the output of some files is not as expected (but might be according to you).

Check the result page for more info.

@cfsmp3 cfsmp3 merged commit 134cd75 into master Dec 14, 2025
29 of 31 checks passed
@cfsmp3 cfsmp3 deleted the fix/multi-file-processing branch December 19, 2025 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multi-file processing broken: only first file is processed

2 participants