record 4.4.4 icon indicating copy to clipboard operation
record: ^4.4.4 copied to clipboard

Audio recorder from microphone to a given file path with multiple codecs, bit rate and sampling rate options.

Audio recorder from microphone to a given file path.

No external dependencies:

  • On Android, MediaRecorder is used.
  • On iOS, AVAudioRecorder is used.
  • On macOS, AVCaptureSession is used.
  • On web, well... your browser!

External dependencies:

  • On Windows and linux, encoding is provided by fmedia.
  • On linux, fmedia must be installed separately.

Options #

  • bit rate (where applicable)
  • sampling rate
  • encoder
  • Number of channels
  • Input device selection

Platforms #

Android #

<uses-permission android:name="android.permission.RECORD_AUDIO" />
<!-- Optional, you'll have to check this permission by yourself. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  • min SDK: 19 (maybe higher => encoder dependent)

iOS #

<key>NSMicrophoneUsageDescription</key>
<string>We need to access to the microphone to record audio file</string>
  • min SDK: 11.0

macOS #

<key>NSMicrophoneUsageDescription</key>
<string>We need to access to the microphone to record audio file</string>
  • In capabilities, activate "Audio input" in debug AND release schemes

  • min SDK: 10.15

Platform feature parity matrix #

FeatureAndroidiOSwebWindowsmacOSlinux
pause/resume✔️✔️✔️✔️✔️✔️
amplitude(dBFS)✔️✔️✔️
permission check✔️✔️✔️✔️
num of channels✔️✔️✔️✔️✔️✔️
device selection(auto BT/mic)✔️✔️✔️✔️
EncoderAndroidiOSwebWindowsmacOSlinux
aacLc✔️✔️?✔️✔️✔️
aacEld✔️✔️?✔️
aacHe✔️✔️?✔️✔️✔️
amrNb✔️✔️?✔️
amrWb✔️✔️?✔️
opus✔️✔️?✔️✔️✔️
vorbisOgg?(optional)?✔️✔️
wav✔️?✔️✔️
flac✔️?✔️✔️✔️
pcm8bit✔️✔️?✔️
pcm16bit✔️✔️?✔️

For every encoder, you should be really careful with given sampling rates. For example, opus could or could not be recorded at 44100Hz.

If a given encoder is not supported when starting recording on platform, the fallbacks are:

Platformencoder
AndroidAAC LC
iOSAAC LC
webOPUS OGG (not guaranteed => choice is made by the browser)
WindowsAAC LC
macOSAAC LC
linuxAAC LC

Encoding API levels documentation #

Android #

iOS #

Usage #

// Import package
import 'package:record/record.dart';

final record = Record();

// Check and request permission
if (await record.hasPermission()) {
  // Start recording
  await record.start(
    path: 'aFullPath/myFile.m4a',
    encoder: AudioEncoder.aacLc, // by default
    bitRate: 128000, // by default
    sampleRate: 44100, // by default
  );
}

// Get the state of the recorder
bool isRecording = await record.isRecording();

// Stop recording
await record.stop();

Warnings #

Be sure to check supported values from the given links above.

Roadmap #

  • Allow to choose the capture device.
  • Format vs. container accuracy.
  • Bug fixes.
280
likes
140
pub points
98%
popularity

Publisher

verified publisher iconopenapi4j.org

Audio recorder from microphone to a given file path with multiple codecs, bit rate and sampling rate options.

Repository (GitHub)

Documentation

API reference

License

Icon for licenses.BSD-3-Clause (LICENSE)

Dependencies

flutter, record_linux, record_macos, record_platform_interface, record_web, record_windows

More

Packages that depend on record