Skip to content

Audio codec properties not respected in release builds on iOS #741

@felixspitzer

Description

@felixspitzer

Before submitting a new issue

  • I tested using the latest version of the library, as the bug might be already fixed.
  • I tested using a supported version of react native.
  • I checked for possible duplicate issues, with possible answers.

Bug summary

We are setting the number of channels for iOS and Android through the given properties. While all the config settings work as expected in debug builds, non of them are respected in release builds of the app.

const newFilename = await audioRecorderPlayer.startRecorder(tempFilename, { AudioSourceAndroid: 0, AVFormatIDKeyIOS: 'aac', AVEncodingOptionIOS: 'aac', OutputFormatAndroid: 5, AudioEncoderAndroid: 3, AudioSamplingRate: 22050, AudioEncodingBitRate: 64000, AudioChannels: 2, AVEncoderAudioQualityKeyIOS: AVEncoderAudioQualityIOSType.medium, AVSampleRateKeyIOS: 22050, AVNumberOfChannelsKeyIOS: 2, })

When I analyze the debug audio through afinfo terminal on my Mac I get the following output

`
File: /Users/felix/Downloads/sound_1763736577.8996592.m4a
File type ID: m4af
Num Tracks: 1

Data format: 2 ch, 22050 Hz, aac (0x00000000) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0 bytes/frame
no channel layout.
estimated duration: 10.864036 sec
audio bytes: 76637
audio packets: 236
bit rate: 55940 bits per second
packet size upper bound: 451
maximum packet size: 451
audio data file offset: 32768
optimized
audio 239552 valid frames + 2112 priming + 0 remainder = 241664
format list:
[ 0] format: 2 ch, 22050 Hz, aac (0x00000000) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0 bytes/frame
Channel layout: Stereo (L R)
`

The same settings, but using the release build audio file result in this output

`
File: /Users/felix/Downloads/sound_1763737051.74795.m4a
File type ID: m4af
Num Tracks: 1

Data format: 5 ch, 44100 Hz, aac (0x00000000) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0 bytes/frame
Channel layout: 5.0 (C L R Ls Rs)
estimated duration: 10.354649 sec
audio bytes: 229256
audio packets: 448
bit rate: 176307 bits per second
packet size upper bound: 713
maximum packet size: 713
audio data file offset: 57344
optimized
audio 456640 valid frames + 2112 priming + 0 remainder = 458752
format list:
[ 0] format: 5 ch, 44100 Hz, aac (0x00000000) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0 bytes/frame
Channel layout: 5.0 (C L R Ls Rs)
`

Our main issue that the audio channel count and the sampling rate are not as we need them to be for the audio to be handled correctly after recording.

Library version

0.2.9

Project type

React Native (bare workflow)

React Native version

0.81.4

Expo SDK version (if applicable)

No response

Environment info

System:
  OS: macOS 26.1
  CPU: (12) arm64 Apple M2 Max
  Memory: 556.05 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.19.0
    path: /Users/felix/.nvm/versions/node/v22.19.0/bin/node
  Yarn:
    version: 1.22.22
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.9.3
    path: /Users/felix/.nvm/versions/node/v22.19.0/bin/npm
  Watchman:
    version: 2025.03.03.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 25.1
      - iOS 26.1
      - macOS 26.1
      - tvOS 26.1
      - visionOS 26.1
      - watchOS 26.1
  Android SDK: Not Found
IDEs:
  Android Studio: 2025.2 AI-252.25557.131.2521.14432022
  Xcode:
    version: 26.1.1/17B100
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.9
    path: /usr/bin/javac
  Ruby:
    version: 3.2.2
    path: /Users/felix/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 20.0.0
    wanted: 20.0.0
  react:
    installed: 19.1.0
    wanted: 19.1.0
  react-native:
    installed: 0.81.4
    wanted: 0.81.4
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

Steps to reproduce

  1. Run config above in debug build
  2. Run config above in release build

Reproducible example repository

will provide one shortly

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bugSomething isn't working📱 iOSRelated to iOS

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions