Skip to content

feat: add api to concatenate audio files#1045

Open
Traviskn wants to merge 8 commits intosoftware-mansion:mainfrom
Traviskn:file-concatenator
Open

feat: add api to concatenate audio files#1045
Traviskn wants to merge 8 commits intosoftware-mansion:mainfrom
Traviskn:file-concatenator

Conversation

@Traviskn
Copy link
Copy Markdown
Contributor

@Traviskn Traviskn commented May 2, 2026

Refs #1043

⚠️ Breaking changes ⚠️

  • None

Introduced changes

  • Add concatAudioFiles(inputPaths, outputPath): Promise<string> exported from the package root, joining a list of compatible local audio files into a single output file. Pairs naturally with the recorder's rotateIntervalBytes option to stitch rotated segments back into one file after recording.
  • Implement the underlying engine in C++ (core/utils/AudioFileConcatenator) using the bundled FFmpeg, exposed to JS through a new AudioFileUtilsHostObject and wired up in AudioAPIModuleInstaller as the createAudioFileUtils JSI global.
  • Add a web stub that rejects with a clear "not supported on web" error, plus mock + Jest coverage in tests/mock.test.ts, and a C++ unit test (common/cpp/test/src/utils/AudioFileConcatenatorTest.cpp).
  • Add docs page packages/audiodocs/docs/utils/file-concatenation.mdx and cross-link it from the rotateIntervalBytes section of the audio recorder docs.
  • Minor: exclude common/cpp/test/build from format:*:common and cpplint.sh so local C++ test builds don't trip linting/formatting.

Checklist

  • Linked relevant issue (discussion Concatenate/Combine multiple audio files into 1 #1043)
  • Updated relevant documentation
  • Added/Conducted relevant tests
  • Performed self-review of the code
  • Updated Web Audio API coverage
  • Added support for web (stub that rejects with a clear message)
  • Updated old arch android spec file

@mdydek mdydek added feature New feature labels May 4, 2026
Copy link
Copy Markdown
Collaborator

@mdydek mdydek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some changes needed before proper review, but at first glance it looks solid

Comment thread packages/audiodocs/docs/utils/file-concatenation.mdx
 - remove unneeded AudioFileConcatenator class
 - move declaration of classes to the .h file
 - add method comments
@Traviskn
Copy link
Copy Markdown
Contributor Author

Traviskn commented May 4, 2026

Updated this PR with the recommended changes!

Copy link
Copy Markdown
Collaborator

@mdydek mdydek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

impressive work, wonderful contribution! Only few nitpicks from the linter

Copy link
Copy Markdown
Collaborator

@mdydek mdydek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately, have to revert approve, code looks good, but it concats only m4a files (ffmpeg is not setup for wav and flac formats, miniaudio handles them and it fails because it meets unknown data), can you add also concatenating those formats, miniaudio operates on higher level than ffmpeg so it should be fairly simple. Also it would make us less dependent on ffmpeg, which is always better

Traviskn added 2 commits May 5, 2026 21:18
fixes the error "Unable to install vendored xcframework libavcodec
for Pod RNAudioAPI, because it contains both static and dynamic frameworks."
@Traviskn
Copy link
Copy Markdown
Contributor Author

Traviskn commented May 6, 2026

Unfortunately miniaudio only supports WAV encoding (mentioned in the features list on their README and verified in code https://github.com/mackron/miniaudio), so while I was able to use it for WAV files I still needed to use ffmpeg for concatenating other file formats. I tested WAV and FLAC and both were working. I also ran into a consistent cocoa pods error when installing into a local test app and included a fix in the download-prebuilt-binaries.sh script

Comment thread packages/audiodocs/docs/utils/file-concatenation.mdx Outdated
@Traviskn
Copy link
Copy Markdown
Contributor Author

Traviskn commented May 7, 2026

The latest push should address all the comments/requested changes. Let me know if any more changes are needed, happy to make any adjustments!


if (!isFFmpegOutputPath(normalizedOutputPath)) {
return Err(
"concatAudioFiles supports WAV output with miniaudio and M4A/MP4/CAF output with FFmpeg.");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you tested CAF concatenation? because in my testing it is not working (I think it is not supposed to in the first place), i can manage to get it working only with wav and m4a, if that is also yours case, just update mentions to exclude caf

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i managed to get it working with broader ffmpeg build, so this the last thing to correct

Copy link
Copy Markdown
Contributor Author

@Traviskn Traviskn May 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry I must have missed that, I'll update this to not mention CAF. Thanks for testing and catching that!

Copy link
Copy Markdown
Contributor Author

@Traviskn Traviskn May 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed mentions of CAF files and removed an explicit check for CAF file extensions in the latest push

@Traviskn Traviskn requested a review from mdydek May 8, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants