flutter_sound icon indicating copy to clipboard operation
flutter_sound copied to clipboard

[HELP] AudioCodecInitialize failed on iOS

Open Mateis opened this issue 4 years ago • 12 comments

In my app, when hitting the Record button on iOS I get the error in console: ' AudioCodecInitialize failed '.

I'm using flutter_sound 6.1.2 codec I'm using is Codec.aacADTS

It does work on Android.

Any idea where I should start seeking a solution?

Mateis avatar Jan 17 '21 17:01 Mateis

Perhaps you can try to specify a "compiled with version 10.0" inside your Podfile.

You can try also to use Flutter Sound 7.5.1, to see if better... If you want help you must post your logs.

Larpoux avatar Jan 17 '21 20:01 Larpoux

Thank you. Upgrading to 7.5.1 didn't solve.

These are the logs I see in Xcode (maybe I can find more detailed logs somehow):

2021-01-18 09:19:04.864801+0100 Runner[38044:1167257] flutter: recorder
2021-01-18 09:19:04.869950+0100 Runner[38044:1167257] flutter: ----------------------------
2021-01-18 09:19:04.900248+0100 Runner[38044:1165917] IOS:--> setAudioFocus
2021-01-18 09:19:04.900654+0100 Runner[38044:1165917] IOS:--> initializeFlautoPlayer
2021-01-18 09:19:04.901031+0100 Runner[38044:1165917] IOS:<-- setAudioFocus
2021-01-18 09:19:09.178168+0100 Runner[38044:1167257] flutter: Tap down
2021-01-18 09:19:09.187082+0100 Runner[38044:1167257] flutter: Tap up?
2021-01-18 09:19:12.350076+0100 Runner[38044:1165917]  AudioCodecInitialize failed
2021-01-18 09:19:12.361405+0100 Runner[38044:1167257] flutter: startRecorder
2021-01-18 09:19:15.369086+0100 Runner[38044:1169538] [ServicesDaemonManager] interruptionHandler is called. -[FontServicesDaemonManager connection]_block_invoke
2021-01-18 09:19:19.617847+0100 Runner[38044:1167257] flutter: Tap down
2021-01-18 09:19:19.622080+0100 Runner[38044:1165917]  AudioCodecInitialize failed
2021-01-18 09:19:19.625306+0100 Runner[38044:1167257] flutter: stopRecorder
2021-01-18 09:19:19.626730+0100 Runner[38044:1167257] flutter: ----------------------------
2021-01-18 09:19:19.627058+0100 Runner[38044:1167257] flutter: postwave
2021-01-18 09:19:19.627534+0100 Runner[38044:1167257] flutter: ----------------------------

Mateis avatar Jan 18 '21 08:01 Mateis

Perhaps you can try to specify a "compiled with version 10.0" inside your Podfile.

You can try also to use Flutter Sound 7.5.1, to see if better... If you want help you must post your logs.

I am using version 10 (in podfile). Also did not fix

Mateis avatar Jan 18 '21 13:01 Mateis

The message AudioCodecInitialize failed does not seem to be printed by Flutter Sound. Is it you who print this ? And Why ?

Larpoux avatar Jan 18 '21 13:01 Larpoux

The message AudioCodecInitialize failed does not seem to be printed by Flutter Sound. Is it you who print this ? And Why ?

No i'm not printing it (as in i didn't define it in the code somewhere to do it). It happens automatically

I'll try run the example app - to check if it gives the same problem.

Mateis avatar Jan 18 '21 16:01 Mateis

warning: the following paths have collided (e.g. case-sensitive paths
on a case-insensitive filesystem) and only one from the same
colliding group is in the working tree:

 'doc/pages/flutter-sound/api/wave_header/WaveHeader/writeInt.html'
 'doc/pages/flutter-sound/api/wave_header/WaveHeader/writeint.html'

Those two files are generated by dartdoc, It means that someone ( me 👎 ! ) created two functions with almost the same name (probably doing the same thing). Not clean 👎

Larpoux avatar Jan 18 '21 16:01 Larpoux

I am sorry, but actually I am overloaded with too many (unpleasant) tasks. I do not help you as much as I would like. I really need to setup good tools to manage such an important project. And of course, several other developers are terribly missing.

Larpoux avatar Jan 18 '21 16:01 Larpoux

I am in the process of transferring everything out of Github. Github is not Open Source, and τ must not use not Open Source Software.

Larpoux avatar Jan 18 '21 16:01 Larpoux

Alright! I really appreciate your time and help. I'll continue debug myself, so you can focus on other tasks!

I tested recording with the example app on iOS. That works. So it must be my code that has something wrong

Mateis avatar Jan 18 '21 16:01 Mateis

I found the issue. It relates to this issue: https://github.com/Canardoux/tau/issues/91

The issue happens when a sampleRate is defined. My code:

      await soundRecorder.startRecorder(
        //audioSource : AudioSource.defaultSource,
        toFile      : path,
        codec       : _codec,
        bitRate     : 24000,
        sampleRate  : 44100,
      );

When I leave out the sample rate parameter, recording works.

Now, I do want higher quality recording (and not the default 16000). Any tips how to achieve that?

Mateis avatar Jan 24 '21 21:01 Mateis

I am very glad that you located the reason of your issue. 👍 I am going to look that.

Note: I thought that "sampleRate" was only for PCM. And "bitRate" was for streaming codecs. But I can be wrong.

Things must be cleaned in this area.

Larpoux avatar Jan 25 '21 08:01 Larpoux

This issue is stale because it has been open 90 days with no activity. Leave a comment or this will be closed in 7 days.

github-actions[bot] avatar Dec 18 '23 01:12 github-actions[bot]