Add APE+CUE splitting via ffmpeg convert-then-split#133
Open
mprachar wants to merge 1 commit intogolift:mainfrom
Open
Add APE+CUE splitting via ffmpeg convert-then-split#133mprachar wants to merge 1 commit intogolift:mainfrom
mprachar wants to merge 1 commit intogolift:mainfrom
Conversation
APE (Monkey's Audio) files paired with CUE sheets are now split into individual FLAC tracks, matching the existing FLAC+CUE behavior. Since no pure-Go APE codec exists, the approach converts APE to a temporary FLAC via ffmpeg (compression level 0 for speed), then runs the proven splitFLAC pipeline unchanged. The temp file is cleaned up after splitting. Changes: - ExtractCUE now dispatches .ape files to convertAndSplitAPE() - New convertToFLAC() shells out to ffmpeg with graceful error when ffmpeg is not installed (ErrFFmpegNotFound) - resolveCueAudioPath now tries .ape alongside .flac in all fallback paths (wav->ape, basename->ape) - ErrUnsupportedAudio message updated to mention APE - Tests: full APE split, ffmpeg-not-found error path, wav->ape resolution, basename fallback (all ffmpeg tests skip when unavailable) Closes Unpackerr/unpackerr#605 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Mar 24, 2026
Contributor
|
Thanks for putting time into this. We need to remove the call to ffmpeg before merging. Might be a while since no one is making an APE library for Go. |
Author
|
I see, is there a problem with that dependency that doesn’t affect ‘lil ol me using it at home? It’s been working great.
Best Regards,
Mike
|
Contributor
|
This module is used by others. I do not wish to add calls to |
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.
Summary
ffmpeg(compression level 0), then split using the existingsplitFLAC()pipeline — zero changes to the proven FLAC splitting pathErrFFmpegNotFoundinstead of silently failingresolveCueAudioPath()now tries.apealongside.flacin all fallback pathsMotivation
Closes Unpackerr/unpackerr#605 — APE+CUE albums are common in music downloads but were silently ignored by the
.flac-only format gate. Lidarr cannot import single-image APE files, so they sit in completed directories forever.Approach: Convert-Then-Split (vs alternatives)
A pure-Go APE codec doesn't exist (and a prior attempt was described as "pretty bleak"). This PR takes the minimal-risk approach:
.apeaudio file via CUE sheet resolutionffmpeg -c:a flac -compression_level 0splitFLAC()— sample-accurate, battle-testedThe conversion is lossless (APE → PCM → FLAC is a bit-for-bit round-trip). Compression level 0 minimizes conversion time since the file is split immediately anyway.
Changes
cue.go.flac→splitFLAC(),.ape→convertAndSplitAPE()cue.goconvertToFLAC()— ffmpeg shell-out with temp dir cleanupcue.goresolveCueAudioPath()— adds.apeto all fallback resolution pathserrors.goErrFFmpegNotFound; updatedErrUnsupportedAudiomessagecue_test.goNew tests
TestCueAPEConvertAndSplit— full end-to-end: generate FLAC → convert to APE → split via CUE → verify FLAC tracks + VorbisComment tagsTestCueAPENoFFmpeg— verifiesErrFFmpegNotFoundwhen PATH is overriddenTestCueWavReferenceAPEFile— CUE says.wavbut only.apeexistsTestCueBaseNameAPEFallback— CUE filename mismatch, resolved via basename +.apeTest plan
go test ./...passes (existing FLAC tests unaffected)Prerequisites
Systems using APE splitting need
ffmpeginstalled with APE decoder support:🤖 Generated with Claude Code