Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The data specified for the media type is invalid, inconsistent #345

Closed
amorenew opened this issue Jun 12, 2024 · 5 comments
Closed

The data specified for the media type is invalid, inconsistent #345

amorenew opened this issue Jun 12, 2024 · 5 comments

Comments

@amorenew
Copy link

Package version
record: ^5.1.1

Environment

  • OS: Windows

Describe the bug

        const encoder = AudioEncoder.aacLc;
        const config = RecordConfig(
          encoder: encoder,
          numChannels: 1,
          sampleRate: 22000,
          bitRate: 64000,
        );

I tried to add sampleRate or bitRate in RecordConfig for aacLc encoder but it make the following crash

[ERROR:flutter/shell/common/shell.cc(1055)] The 'xyz.luan/audioplayers/events/6b7b4f61-3d62-47d8-bb98-3646bf2ece58' channel sent a message from native to Flutter on a non-platform thread. Platform channel messages must be sent on the platform thread. Failure to do so may result in data loss or crashes, and must be fixed in the plugin or application code creating that channel.
See https://docs.flutter.dev/platform-integration/platform-channels#channels-and-platform-threading for more information.
Reloaded 1 of 1174 libraries in 272ms (compile: 30 ms, reload: 109 ms, reassemble: 71 ms).
flutter: [      id: {0.0.1.00000000}.{758c6ba1-9bf2-4673-bd62-433f1dd9f412}
flutter:       label: Internal Digital Microphone (Apple Audio Device)
flutter:       ,       id: {0.0.1.00000000}.{a18e32ef-542f-4cc2-8941-49368042bf21}
flutter:       label: Headset Microphone (Apple Audio Device)
flutter:       ]
flutter: PlatformException(Record, null, The data specified for the media type is invalid, inconsistent, or not supported by this object., null)

To Reproduce

Steps to reproduce the behavior:

  1. Go to example
  2. In audio_recorder.dart use AudioEncoder.aacLc and add bitRate:64000

Expected behavior

I expected the sampleRate and bitRate to work fine for all encoder types, especially aacLc

@amorenew
Copy link
Author

I tried amr encoder const encoder = AudioEncoder.amrNb; with
const config = RecordConfig(
encoder: encoder,
numChannels: 1 );

and I got this new error

[ERROR:flutter/shell/common/shell.cc(1055)] The 'xyz.luan/audioplayers/events/162f1aed-f774-42d7-95b3-fb4508dbfffe' channel sent a message from native to Flutter on a non-platform thread. Platform channel messages must be sent on the platform thread. Failure to do so may result in data loss or crashes, and must be fixed in the plugin or application code creating that channel.
See https://docs.flutter.dev/platform-integration/platform-channels#channels-and-platform-threading for more information.
flutter: AudioPlayers Exception: AudioPlayerException(
	DeviceFileSource(path: C:\Users\Omega\Documents\audio_1718221349435.m4a, mimeType: null), 
	PlatformException(4, MediaEngine error, No suitable transform was found to encode or decode the content., null)
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(4, MediaEngine error, No suitable transform was found to encode or decode the content., null)

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(4, MediaEngine error, No suitable transform was found to encode or decode the content., null)

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(4, MediaEngine error, No suitable transform was found to encode or decode the content., null)

@amorenew
Copy link
Author

so

  • amrNB didn't work even with the default config
  • aaclc didn't work but with custom bitRate
  • wav works fine for windows

@llfbandit
Copy link
Owner

Ok so for AAC, the message is pretty clear, you can't record with the values you gave.
You can refer to this doc for available values.

And for AMR, I'm not responsible of audio playing.

@llfbandit llfbandit closed this as not planned Won't fix, can't repro, duplicate, stale Jun 12, 2024
@amorenew
Copy link
Author

Thanks a lot for your effort and support
I tried for ACC encoder the following form Wikipedia and it work fine

bitRate: 96000,
sampleRate: 44100

Thanks a lot

@amorenew
Copy link
Author

recording by amrNb was the best encoder as it is more suitable for speech recording while it has the minimum size for that case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants