Fix cryptic combine crash and segment ordering past 1000 files#175
Open
s0len wants to merge 2 commits into
Open
Fix cryptic combine crash and segment ordering past 1000 files#175s0len wants to merge 2 commits into
s0len wants to merge 2 commits into
Conversation
The re-encode fallback could silently produce nothing (e.g. a transient ffmpeg error on a chunk). The code then removed the accumulated input and moved a non-existent output_file, crashing with a cryptic FileNotFoundError and discarding combine progress. Verify ffmpeg actually wrote output before moving; otherwise raise FailedCombining and log ffmpeg stderr at debug. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
zfill(int(log10(n))) under-pads once the file count crosses a power of ten (e.g. 3307 files -> 3-digit padding), so 'Part 1000' sorts lexically before 'Part 999' and segments combine out of order. Add 1 so the width covers the largest index. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
Looks good to me and verified locally. Thanks for your work @jo1gi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
While downloading a ~3300-segment Nextory audiobook with
--combine, the combine step crashed with a confusingFileNotFoundError: output_file.aacand discarded the in-progress merge. Two distinct issues:1.
combine_audiofilescrashes cryptically when ffmpeg writes no outputThe re-encode fallback in
output.pycould finish without producingoutput_file(e.g. a transient ffmpeg error on a chunk). The code then ranos.remove(tmp_input)followed byshutil.move(tmp_output, tmp_input)on a file that was never created — crashing with aFileNotFoundErrorand deleting the accumulated combine progress.Now the fallback result is checked: if ffmpeg produced no output, raise
FailedCombining(logging ffmpeg's stderr at debug level) and leavetmp_inputintact, instead of crashing and losing progress.2. Segment filenames under-pad past powers of ten
create_filepathusedzfill(int(log10(len(files)))). For 3307 files that pads to 3 digits, soPart 1000…Part 3306sort lexically beforePart 999, scrambling the concat order.+ 1makes the padding width cover the largest index.Testing
Built and installed locally; a full
--combine -f mp4download of a 3307-segment book now completes end-to-end and produces a valid 2h19m mp4.🤖 Generated with Claude Code