Skip to content

feat: encoder - #1183

Open
mdydek wants to merge 36 commits into
mainfrom
feat/encoder-interface
Open

mdydek wants to merge 36 commits into
mainfrom
feat/encoder-interface

Conversation

@mdydek

@mdydek mdydek commented Jul 21, 2026 •

Copy link
Copy Markdown
Member

Closes #1299, because it uses different resampler, which does not produce this issue

⚠️ Breaking changes ⚠️

  • recorder.start() no longer takes options
  • fileNamePrefix is renamed to fileName, with different meaning. The new field is the exact file name, with nothing appended.
  • enableFileOutput now rejects names it used to accept. The name must be bare: no extension, no path separators, no .., and at most 128 characters. Violations return an error result from enableFileOutput rather than being passed through.

Introduced changes

  • use system apis instead of ffmpeg to encode recorded buffers
  • abstracted file writers and recorders, there is main c++ class, which only calls native classes, but majority of the implementation can be shared

Proposed architecture:
image

Checklist

  • Linked relevant issue
  • Updated relevant documentation
  • Added/Conducted relevant tests
  • Performed self-review of the code
  • Updated Web Audio API coverage
  • Added support for web
  • Updated old arch android spec file

mdydek and others added 4 commits July 21, 2026 13:19
Resolves conflicts between the encoder work and the OS-APIs decoding
refactor (#1177):
- AudioFileConcatenator: main's decoder-factory WAV path + encoder's
  OS remux (M4A/MP4) path; all FFmpeg remux code removed
- AudioEventHandlerRegistry -> IAudioEventHandlerRegistry (#1212) in
  encoder file writers
- AndroidEncoding/AndroidRemux moved to android/src/main/cpp/audioapi/android/
  to match AndroidDecoding placement
- docs/flags updated: recording and concatAudioFiles are FFmpeg-free

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mdydek mdydek changed the title feat: 1st version of encoder feat: encoder Aug 12, 2026
@closetcaiman closetcaiman added the feature New user-facing features or major capabilities label Aug 12, 2026
@github-actions

github-actions Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

WPT non-regression comparison

PASS — no regressions · 0 improved section(s) · overall 3420 → 3420 (0)

Unchanged sections (28)
Spec section Base pass Head pass Delta
Processing model 0 0 0
Other 56 56 0
AnalyserNode 138 138 0
AudioBuffer 140 140 0
AudioBufferSourceNode 218 218 0
AudioContext 58 58 0
AudioNode 261 261 0
AudioParam 680 680 0
BiquadFilterNode 275 275 0
ChannelMergerNode 30 30 0
ChannelSplitterNode 7 7 0
ConstantSourceNode 64 64 0
ConvolverNode 203 203 0
DelayNode 104 104 0
DestinationNode 0 0 0
DynamicsCompressorNode 4 4 0
GainNode 15 15 0
IIRFilterNode 87 87 0
MediaElementAudioSourceNode 0 0 0
MediaStreamAudioDestinationNode 1 1 0
MediaStreamAudioSourceNode 0 0 0
OfflineAudioContext 35 35 0
OscillatorNode 104 104 0
PannerNode 723 723 0
PeriodicWave 33 33 0
ScriptProcessorNode 0 0 0
StereoPannerNode 102 102 0
WaveShaperNode 82 82 0

Baseline: 87cca81bff30ee15f3a407008cdc2ee30527ef89 · Candidate: a84156a7b787d27f59254ba7036c3d6e8a3ac675

Workflow run · this comment is updated on every push.

@mdydek
mdydek marked this pull request as ready for review August 18, 2026 08:35

@closetcaiman closetcaiman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please add description to the PR for fast-access reference to the scope of these changes.

@maciejmakowski2003 maciejmakowski2003 left a comment

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.

could you add an overview of refactor? would be great to get some diagram

Comment thread packages/react-native-audio-api/ios/audioapi/ios/core/IOSAudioRecorder.h Outdated
@github-actions github-actions Bot added the conflicts This PR has conflicts with the base branch. label Sep 11, 2026
@github-actions github-actions Bot removed the conflicts This PR has conflicts with the base branch. label Sep 14, 2026
@github-actions github-actions Bot added the conflicts This PR has conflicts with the base branch. label Sep 14, 2026
@github-actions github-actions Bot removed the conflicts This PR has conflicts with the base branch. label Sep 14, 2026
@github-actions github-actions Bot removed the conflicts This PR has conflicts with the base branch. label Sep 23, 2026
Comment thread packages/audiodocs/docs/utils/file-concatenation.mdx
Comment thread packages/react-native-audio-api/common/cpp/audioapi/core/inputs/AudioRecorder.cpp Outdated
Comment thread packages/react-native-audio-api/common/cpp/audioapi/encoding/EncoderOutputSpec.h Outdated
Comment thread packages/react-native-audio-api/common/cpp/audioapi/utils/AudioFileProperties.h Outdated
Comment thread packages/react-native-audio-api/ios/audioapi/ios/core/utils/FileOptions.h Outdated
Comment thread packages/react-native-audio-api/ios/audioapi/ios/core/utils/IOSInterleaving.h Outdated
@github-actions github-actions Bot added the conflicts This PR has conflicts with the base branch. label Sep 25, 2026
@github-actions github-actions Bot removed the conflicts This PR has conflicts with the base branch. label Sep 25, 2026
Comment thread packages/react-native-audio-api/common/cpp/audioapi/utils/AudioFileProperties.h Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't those be conditionally compiled per platform (like we used to do with decoding)? Now the common header actually considers both platforms.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

hmmm, don't you think that it would introduce some unnecessary noise, it's only option and the name directly suggest that where to use it. Maybe we could introduce some defaults there, to not use them directly in another system (ios properties in android), left for discussion

Comment thread packages/react-native-audio-api/common/cpp/audioapi/core/inputs/AudioRecorder.h Outdated
};
offloader_ = std::make_unique<Offloader>(FILE_WRITER_CHANNEL_CAPACITY, offloaderLambda);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd also consider this worker thread to be a separate class - worth to skim a bit, but if the shared state is too much I'd stick to offloader approach so that it doesn't get messy.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

you mean that runWriterTask should be in a different class?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New user-facing features or major capabilities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AudioRecorder (Android, data-callback mode) silently drops audio; 'when' is frames-accumulated so gaps are undetectable

3 participants