llfbandit / record

Audio recorder from microphone to a given file path. No external dependencies, MediaRecorder is used for Android an AVAudioRecorder for iOS.
https://pub.dev/packages/record
241 stars 204 forks source link

Unexpected stereo output on Android devices when configuring mono audio recording #289

Closed tobit0101 closed 8 months ago

tobit0101 commented 8 months ago

Package version

Environment

Describe the bug

I've encountered an issue with the record package where recording audio in mono configuration results in stereo output on Android devices, specifically tested on a Samsung device. The configuration is intended for mono output with settings: bitrate of 128000, sample rate of 44100, using AAC encoder, and 1 channel. However, the output audio file is in stereo format. This behavior differs from iOS, where the output is correctly in mono. This discrepancy in audio channel output across platforms could affect applications relying on consistent audio formats.

import 'package:record/record.dart';

final recorder = Record();
await recorder.start(
  path: 'path/to/output/file.m4a',
  encoder: AudioEncoder.aacLc,
  bitRate: 128000,
  samplingRate: 44100,
  numChannels: 1,
);

// Later, to stop the recording
await recorder.stop();

To Reproduce

  1. Configure the audio recording to use mono output settings in a Flutter app.
  2. Start the recording with the specified mono configuration.
  3. Stop the recording and inspect the output file's channel configuration.

Expected behavior

Expected Behavior: The recording should be in mono format with a single audio channel, as specified in the configuration.

Actual Behavior: On Android devices, specifically tested on Samsung, the output file is unexpectedly in stereo format with two audio channels, despite the mono configuration. This behavior is inconsistent with iOS, where the output correctly matches the mono configuration.

Logs: logs.log

llfbandit commented 8 months ago

Thanks for the report. Sample rate et num channels properties are not applied for AAC profiles.

tobit0101 commented 7 months ago

Sorry to bother you, when can we expect the release? Would help us very much