audio_waveforms icon indicating copy to clipboard operation
audio_waveforms copied to clipboard

Recorded audio file from IOS can't play in Android (None of the available extractors .. could read the stream)

Open JonesWest opened this issue 2 years ago • 7 comments

Hi,

I record an audio file on IOS using standard RecorderController settings: controller = RecorderController();, I then upload it to cloud storage.

I then download the file from storage using DefaultCacheManager:

      var file = await DefaultCacheManager().getSingleFile(widget.path);
      finalPath = 'file://${file.path}';

And use the local path to play the audio:

    await controller.preparePlayer(
      path: finalPath,
      shouldExtractWaveform: true,
      noOfSamples: playerStyle.getSamplesForWidth(100),
      volume: 1.0,
    );

For audio files recorded on android this works great when played on both Android, IOS and browser. But when trying to play files recorded on IOS I get this on Android:


E/ExoPlayerImplInternal(29012):   com.google.android.exoplayer2.ExoPlaybackException: Source error
E/ExoPlayerImplInternal(29012):       at com.google.android.exoplayer2.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:632)
E/ExoPlayerImplInternal(29012):       at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:602)
E/ExoPlayerImplInternal(29012):       at android.os.Handler.dispatchMessage(Handler.java:102)
E/ExoPlayerImplInternal(29012):       at android.os.Looper.loop(Looper.java:214)
E/ExoPlayerImplInternal(29012):       at android.os.HandlerThread.run(HandlerThread.java:65)
E/ExoPlayerImplInternal(29012):   Caused by: com.google.android.exoplayer2.source.UnrecognizedInputFormatException: None of the available extractors (FlvExtractor, FlacExtractor, WavExtractor, FragmentedMp4Extractor, Mp4Extractor, AmrExtractor, PsExtractor, OggExtractor, TsExtractor, MatroskaExtractor, AdtsExtractor, Ac3Extractor, Ac4Extractor, Mp3Extractor, AviExtractor, JpegExtractor) could read the stream.
E/ExoPlayerImplInternal(29012):       at com.google.android.exoplayer2.source.BundledExtractorsAdapter.init(BundledExtractorsAdapter.java:92)
E/ExoPlayerImplInternal(29012):       at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1017)
E/ExoPlayerImplInternal(29012):       at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:412)
E/ExoPlayerImplInternal(29012):       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/ExoPlayerImplInternal(29012):       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/ExoPlayerImplInternal(29012):       at java.lang.Thread.run(Thread.java:764)

The local file name ends up being: file:///data/user/0/com.mytestapp/cache/libCachedImageData/19032dc0-c677-11ed-9aac-dfd9b830655d.octet-stream

I don't know if the the file ending could confuse Android? But files recorded on Android ends with a similar file ending. Also I have issues playing the audio in browser too (Angular Application).

Hope someone can help.

JonesWest avatar Mar 19 '23 17:03 JonesWest

When playing the IOS audio file in standard HTML5 this error occurs in the Chrome devtools: Skærmbillede 2023-03-19 kl  19 47 06

For Android recordings everything is good: Skærmbillede 2023-03-19 kl  19 48 16

JonesWest avatar Mar 19 '23 18:03 JonesWest

Hey @JonesWest, your issue is I think related to file extension only. octet-stream indicated arbitrary binary data. Also your issue looks similar to this. So before you upload your file specify its mime type. for this case contentType. You can find mime type using mime. Then cloud storage might store it as audio/... instead of application/octet-stream and it might provide appropriate extension when you download the file.

Please do let me know if this works because answer in question was for firebase storage.

ujas-m-simformsolutions avatar Mar 20 '23 06:03 ujas-m-simformsolutions

Hey @ujas-m-simformsolutions Thank you for getting back to me 🙏

I have tried all different types of file extensions etc.. Unfortunately, it doesn't help. Also in the browser we have the same issue, even though the browser is reading the file directly from cloud storage with .m4a extension and correct mime types.

Also, as a work around we're now running flutter_sound plugin to simultaneously to make the actual recording on IOS (and then still use this plugin for visuals):

      // If IOS use the flutter_sound lib to make the actual recording:
      if (Platform.isIOS) {
        flutterSoundRecorder = FlutterSoundRecorder();
        await flutterSoundRecorder!.openRecorder();
        await flutterSoundRecorder!
            .startRecorder(toFile: recordedFilePath, codec: Codec.aacMP4);
      }

File names, exentions, mime types are the same, and it works great on both android and browser. Maybe some meta data or similar is missing on the files outputtet from this library?

JonesWest avatar Mar 21 '23 17:03 JonesWest

Thank you for reporting this. I will look into this.

ujas-m-simformsolutions avatar Mar 24 '23 09:03 ujas-m-simformsolutions

facing the same issue but for me, if i record on ios it is working on both, and if i record in android it works only in android and the audio i get on firebase after uploading on firebase is not streamable

sonigeez avatar Jun 22 '23 09:06 sonigeez

encountered the same issue just now.. the same exact scenario. audio recorded on ios wont play on android. the file stored on firebase is not streamable but playable on desktop using vlc. any updates regarding this issue?

allanguintu avatar Sep 10 '23 08:09 allanguintu

adding '.m4a' extension to the filename before saving it to firebase solved it for me, recording works both ways like this.

dshpindler avatar Jan 05 '24 13:01 dshpindler