Skip to content

Record package creates invalid files that are too small/corrupted #394

@bloemy7

Description

@bloemy7

Package version: 5.1.2

Environment

  • OS: iOS, Android and web
  • Browser: chrome

Describe the bug

We are using the Record package in a production app and seeing daily dozens of recordings that upload to a server as corrupted files. This happens both for opus as well as aacLc.
The files will be super small: 5210 bytes, 4525 bytes, etc. and are simply corrupted - as in, they are not valid.
So, to decide on the encoder, we do this:

    String fileExtension = ".m4a";
    if (_recorder != null &&
        await _recorder!.isEncoderSupported(AudioEncoder.aacLc)) {
      codec = AudioEncoder.aacLc;
      fileExtension = ".m4a";
    } else if (_recorder != null &&
        await _recorder!.isEncoderSupported(AudioEncoder.opus)) {
      codec = AudioEncoder.opus;
      fileExtension = ".opus";
    } else if (_recorder != null &&
        await _recorder!.isEncoderSupported(AudioEncoder.pcm16bits)) {
      codec = AudioEncoder.pcm16bits;
      fileExtension = ".pcm";
    }

to try and cover all platforms.

And here is the rest of the config:

int bitRate = 32000; // 32 kbps
    int sampleRate = 16000; // 16 kHz
    RecordConfig config = RecordConfig(
        encoder: codec,
        numChannels: 1,
        bitRate: bitRate,
        sampleRate: sampleRate);
    await _recorder?.start(config, path: _filePath!);

Are we doing something obviously wrong here?

To Reproduce

Steps to reproduce the behavior: I don't have clear steps to reproduce since it doesn't happen for me - it happens in roughly 1-2% of the cases, but our app heavily depends on recordings so this is a real issue.

Expected behavior

Always generate a valid audio file.

Additional context

This happens on all platforms. Would love some help here, thanks a lot!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions