Skip to content

Repository files navigation

Audio recorder from microphone to a given file path or stream.

No external dependencies:

  • On Android, AudioRecord and MediaCodec or MediaRecorder.
  • On iOS and macOS, AVFoundation.
  • On Windows, MediaFoundation.
  • On web, well... your browser! (and its underlying platform).

External dependencies:

  • On linux, encoding is provided by parecord and ffmpeg. It must be installed separately.

Platform feature parity matrix

FeatureAndroidiOSwebWindowsmacOSlinux
pause/resume✔️✔️✔️✔️✔️✔️
amplitude(dBFS)✔️✔️✔️✔️✔️
permission check✔️✔️✔️✔️
num of channels✔️✔️✔️✔️✔️✔️
device selection✔️ 1 / 2(auto BT/mic)✔️✔️✔️✔️
auto gain✔️ 2✔️ 3✔️✔️ 3
echo cancel✔️ 2✔️ 3✔️✔️ 3
noise suppresion✔️ 2✔️

File

EncoderAndroidiOSwebWindowsmacOSlinux
aacLc✔️✔️?✔️✔️✔️
aacEld✔️✔️?✔️
aacHe✔️?
amrNb✔️?✔️
amrWb✔️?
opus✔️?✔️
wav✔️ 2✔️✔️✔️✔️✔️
flac✔️ 2✔️?✔️✔️✔️
pcm16bits✔️ 2✔️✔️✔️✔️

?: from my testings:

EncoderFirefoxChrome basedSafari
aacLc✔️*
opus✔️*✔️*
wav✔️✔️✔️
pcm16bits✔️✔️✔️

* Sample rate output is determined by your settings in OS. Bit depth is likely 32 bits.

wav and pcm16bits are provided by the package directly.

Stream

EncoderAndroidiOSwebWindowsmacOSlinux
aacLc *✔️ 2
aacEld *✔️ 2
aacHe *✔️ 2
pcm16bits✔️ 2✔️✔️✔️✔️

* AAC is streamed with raw AAC with ADTS headers, so it's directly readable through a file!

  1. Bluetooth telephony device link (SCO) is automatically done but there's no phone call management.
  2. Unsupported on legacy Android recorder.
  3. Stream mode only.

Usage

import'package:record/record.dart';
final record =AudioRecorder();
// Check and request permission if neededif (await record.hasPermission()) {
// Start recording to fileawait record.start(constRecordConfig(), path:'aFullPath/myFile.m4a');
// ... or to streamfinal stream =await record.startStream(constRecordConfig(encoder:AudioEncoder.pcm16bits));
}
// Stop recording...final path =await record.stop();
// ... or cancel it (and implicitly remove file/blob).await record.cancel();
record.dispose(); // As always, don't forget this one.

Setup, permissions and others

Android

Setup.

  • min SDK: 23 (amrNb/amrWb: 26, Opus: 29)

iOS

<key>NSMicrophoneUsageDescription</key>
<string>Some message to describe why you need this permission</string>
  • min SDK: 12.0

macOS

<key>NSMicrophoneUsageDescription</key>
<string>Some message to describe why you need this permission</string>
  • In capabilities, activate "Audio input" in debug AND release schemes.
  • or directly in *.entitlements files
<key>com.apple.security.device.audio-input</key>
<true/>
  • min SDK: 10.15

About

Audio recorder from microphone to a given file path. No external dependencies, MediaRecorder is used for Android an AVAudioRecorder for iOS.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages